File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,19 @@ export class Utils implements BaseUtils {
111111 const contractAddress = new TonWeb . Address ( '0:' + TonWeb . utils . bytesToHex ( stateInitHash ) ) ;
112112 return contractAddress . toString ( true , true , true ) ;
113113 }
114+
115+ /**
116+ * Converts a TON address into a Base64 encoded BOC (Bag of Cells) string.
117+ * This is required when passing an address as a 'slice' argument to `runGetMethod`.
118+ * @param address - The TON address (friendly or raw)
119+ * @returns Base64 string of the serialized address cell
120+ */
121+ async getAddressBoc ( address : string ) : Promise < string > {
122+ const cell = new TonWeb . boc . Cell ( ) ;
123+ cell . bits . writeAddress ( new TonWeb . Address ( address ) ) ;
124+ const boc = await cell . toBoc ( false ) ;
125+ return TonWeb . utils . bytesToBase64 ( boc ) ;
126+ }
114127}
115128
116129const DUMMY_PRIVATE_KEY = '43e8594854cb53947c4a1a2fab926af11e123f6251dcd5bd0dfb100604186430' ; // This dummy private key is used only for fee estimation
Original file line number Diff line number Diff line change @@ -200,3 +200,9 @@ export const signedTonWhalesFullWithdrawalTransaction = {
200200 'e9565e2211801ecf93f8955513786583367845f293f85430798f931395993829e3ce1b537d63203dddec00e00d6cba76e6def382f1c4ebbdb1737ff1c5f8cf0d' ,
201201 bounceable : true ,
202202} ;
203+
204+ export const getMemberStackFixture = {
205+ friendlyAddress : 'EQBkD52LACNxGgaoAxm5Nhs0SN6gg8hNaceNYifev88Y7qoZ' ,
206+ rawAddress : '0:640f9d8b0023711a06a80319b9361b3448dea083c84d69c78d6227debfcf18ee' ,
207+ boc : 'te6cckEBAQEAJAAAQ4AMgfOxYARuI0DVAGM3JsNmiRvUEHkJrTjxrET71/njHdDqtWeh' ,
208+ } ;
Original file line number Diff line number Diff line change @@ -604,6 +604,18 @@ describe('TON:', function () {
604604 } ) ;
605605 } ) ;
606606
607+ describe ( 'getAddressBoc' , function ( ) {
608+ it ( 'should return the correct BOC for a friendly address' , async function ( ) {
609+ const result = await utils . getAddressBoc ( testData . getMemberStackFixture . friendlyAddress ) ;
610+ result . should . equal ( testData . getMemberStackFixture . boc ) ;
611+ } ) ;
612+
613+ it ( 'should return the correct BOC for a raw address' , async function ( ) {
614+ const result = await utils . getAddressBoc ( testData . getMemberStackFixture . rawAddress ) ;
615+ result . should . equal ( testData . getMemberStackFixture . boc ) ;
616+ } ) ;
617+ } ) ;
618+
607619 describe ( 'Ton recover - Non-BitGo and Unsigned Sweep Transactions' , function ( ) {
608620 let sandbox : sinon . SinonSandbox ;
609621 beforeEach ( ( ) => {
You can’t perform that action at this time.
0 commit comments