66 AddressVersion ,
77 bufferCV ,
88 ClarityType ,
9- createAssetInfo ,
10- FungibleConditionCode ,
11- makeStandardFungiblePostCondition ,
9+ ContractCallPayload ,
10+ Pc ,
1211 PostCondition ,
1312 PostConditionMode ,
1413 tupleCV ,
@@ -19,7 +18,6 @@ import { Transaction } from './transaction';
1918import { getSTXAddressFromPubKeys , isValidAmount } from './utils' ;
2019import { SbtcWithdrawParams } from './iface' ;
2120import { CONTRACT_NAME_SBTC_WITHDRAWAL , FUNCTION_NAME_INITIATE_WITHDRAWAL } from './constants' ;
22- import { ContractCallPayload } from '@stacks/transactions/dist/payload' ;
2321import { AbstractContractBuilder } from './abstractContractBuilder' ;
2422import { decodeBtcAddress , isValidBtcAddress } from './btcAddressUtils' ;
2523
@@ -85,8 +83,8 @@ export class SbtcWithdrawBuilder extends AbstractContractBuilder {
8583 if ( args [ 1 ] . type !== ClarityType . Tuple ) {
8684 throw new BuildTransactionError ( 'Expected tuple for recipient argument' ) ;
8785 }
88- const versionBuf = args [ 1 ] . data [ 'version' ] ;
89- const hashbytesBuf = args [ 1 ] . data [ 'hashbytes' ] ;
86+ const versionBuf = args [ 1 ] . value [ 'version' ] ;
87+ const hashbytesBuf = args [ 1 ] . value [ 'hashbytes' ] ;
9088 if ( versionBuf ?. type !== ClarityType . Buffer || hashbytesBuf ?. type !== ClarityType . Buffer ) {
9189 throw new BuildTransactionError ( 'Expected buffer fields in recipient tuple' ) ;
9290 }
@@ -121,16 +119,16 @@ export class SbtcWithdrawBuilder extends AbstractContractBuilder {
121119 if ( recipientTuple ?. type !== ClarityType . Tuple ) {
122120 return undefined ;
123121 }
124- const versionBuf = recipientTuple . data [ 'version' ] ;
125- const hashbytesBuf = recipientTuple . data [ 'hashbytes' ] ;
122+ const versionBuf = recipientTuple . value [ 'version' ] ;
123+ const hashbytesBuf = recipientTuple . value [ 'hashbytes' ] ;
126124 if ( versionBuf ?. type !== ClarityType . Buffer || hashbytesBuf ?. type !== ClarityType . Buffer ) {
127125 return undefined ;
128126 }
129127 return {
130128 amount : this . _withdrawParams . amount ,
131129 maxFee : this . _withdrawParams . maxFee ,
132- recipientVersion : versionBuf . buffer [ 0 ] ,
133- recipientHashBytes : Buffer . from ( hashbytesBuf . buffer ) ,
130+ recipientVersion : Buffer . from ( versionBuf . value , 'hex' ) [ 0 ] ,
131+ recipientHashBytes : Buffer . from ( hashbytesBuf . value , 'hex' ) ,
134132 } ;
135133 }
136134
@@ -174,19 +172,18 @@ export class SbtcWithdrawBuilder extends AbstractContractBuilder {
174172 const sbtcContractAddress = network . sbtcWithdrawalContractAddress ;
175173
176174 return [
177- makeStandardFungiblePostCondition (
175+ Pc . principal (
178176 getSTXAddressFromPubKeys (
179177 this . _fromPubKeys ,
180178 this . _coinConfig . network . type === NetworkType . MAINNET
181179 ? AddressVersion . MainnetMultiSig
182180 : AddressVersion . TestnetMultiSig ,
183- this . _fromPubKeys . length > 1 ? AddressHashMode . SerializeP2SH : AddressHashMode . SerializeP2PKH ,
181+ this . _fromPubKeys . length > 1 ? AddressHashMode . P2SH : AddressHashMode . P2PKH ,
184182 this . _numberSignatures
185- ) . address ,
186- FungibleConditionCode . Equal ,
187- amount . toString ( ) ,
188- createAssetInfo ( sbtcContractAddress , SBTC_TOKEN_CONTRACT_NAME , SBTC_TOKEN_ASSET_NAME )
189- ) ,
183+ ) . address
184+ )
185+ . willSendEq ( amount . toString ( ) )
186+ . ft ( `${ sbtcContractAddress } .${ SBTC_TOKEN_CONTRACT_NAME } ` , SBTC_TOKEN_ASSET_NAME ) ,
190187 ] ;
191188 }
192189}
0 commit comments