@@ -5,7 +5,7 @@ import { Cell } from 'tonweb/dist/types/boc/cell';
55import { BaseKey , BaseTransaction , Entry , Recipient , TransactionRecipient , TransactionType } from '@bitgo/sdk-core' ;
66import { BaseCoin as CoinConfig } from '@bitgo/statics' ;
77import { TransactionExplanation , TxData } from './iface' ;
8- import { WITHDRAW_OPCODE , WALLET_ID , JETTON_TRANSFER_OPCODE } from './constants' ;
8+ import { WITHDRAW_OPCODE , WALLET_ID , JETTON_TRANSFER_OPCODE , VESTING_CONTRACT_WALLET_ID } from './constants' ;
99
1010export class Transaction extends BaseTransaction {
1111 public recipient : Recipient ;
@@ -19,6 +19,7 @@ export class Transaction extends BaseTransaction {
1919 sender : string ;
2020 publicKey : string ;
2121 isV3ContractMessage : boolean ;
22+ sub_wallet_id : number ;
2223 protected unsignedMessage : string ;
2324 protected finalMessage : string ;
2425
@@ -52,6 +53,7 @@ export class Transaction extends BaseTransaction {
5253 amount : this . recipient . amount ,
5354 withdrawAmount : this . withdrawAmount ,
5455 seqno : this . seqno ,
56+ sub_wallet_id : this . sub_wallet_id ,
5557 expirationTime : this . expireTime ,
5658 publicKey : this . publicKey ,
5759 signature : this . _signatures [ 0 ] ,
@@ -72,7 +74,14 @@ export class Transaction extends BaseTransaction {
7274 }
7375
7476 async build ( ) : Promise < void > {
75- const signingMessage = this . createSigningMessage ( WALLET_ID , this . seqno , this . expireTime ) ;
77+ if ( ! this . sub_wallet_id ) {
78+ if ( this . isV3ContractMessage ) {
79+ this . sub_wallet_id = VESTING_CONTRACT_WALLET_ID ;
80+ } else {
81+ this . sub_wallet_id = WALLET_ID ;
82+ }
83+ }
84+ const signingMessage = this . createSigningMessage ( this . sub_wallet_id , this . seqno , this . expireTime ) ;
7685 const sendMode = 3 ; // default sendMode
7786 signingMessage . bits . writeUint8 ( sendMode ) ;
7887 const outMsg = this . createOutMsg ( this . recipient . address , this . recipient . amount , this . message ) ;
@@ -189,6 +198,7 @@ export class Transaction extends BaseTransaction {
189198 this . message = parsed . payload ;
190199 this . _signatures . push ( parsed . signature ) ;
191200 this . bounceable = parsed . bounce ;
201+ this . sub_wallet_id = parsed . walletId ;
192202 } catch ( e ) {
193203 throw new Error ( 'invalid raw transaction' ) ;
194204 }
@@ -263,7 +273,7 @@ export class Transaction extends BaseTransaction {
263273 // signing message
264274
265275 const walletId = slice . loadUint ( 32 ) . toNumber ( ) ;
266- if ( walletId !== WALLET_ID ) throw new Error ( 'invalid walletId' ) ;
276+ if ( walletId !== WALLET_ID && walletId !== VESTING_CONTRACT_WALLET_ID ) throw new Error ( 'invalid walletId' ) ;
267277
268278 const expireAt = slice . loadUint ( 32 ) . toNumber ( ) ;
269279
0 commit comments