@@ -1646,14 +1646,11 @@ export class FireblocksService {
16461646 /**
16471647 * Sign a Trx transaction on Fireblocks
16481648 */
1649- async signTrxTx (
1649+ async createTrxTx (
16501650 integration : FireblocksIntegration ,
16511651 tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
16521652 note ?: string ,
1653- ) : Promise < {
1654- signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1655- fireblocks_tx : TransactionResponse ;
1656- } > {
1653+ ) : Promise < TransactionResponse > {
16571654 const payload = {
16581655 rawMessageData : {
16591656 messages : [
@@ -1670,13 +1667,25 @@ export class FireblocksService {
16701667
16711668 const fbSigner = this . getSigner ( integration ) ;
16721669 const fbNote = note ? note : 'TRX tx from @kilnfi/sdk' ;
1673- const fbTx = await fbSigner . sign ( payload , 'TRX' , fbNote ) ;
1670+ return await fbSigner . createTransaction ( payload , 'TRX' , fbNote ) ;
1671+ }
16741672
1675- if ( ! fbTx . signedMessages ?. [ 0 ] ?. signature ) {
1673+ async waitForTrxTxCompletion (
1674+ integration : FireblocksIntegration ,
1675+ tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
1676+ fbTx : TransactionResponse ,
1677+ ) : Promise < {
1678+ signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1679+ fireblocks_tx : TransactionResponse ;
1680+ } > {
1681+ const fbSigner = this . getSigner ( integration ) ;
1682+ const completedTx = await fbSigner . waitForTxCompletion ( fbTx ) ;
1683+
1684+ if ( ! completedTx . signedMessages ?. [ 0 ] ?. signature ) {
16761685 throw new Error ( ERRORS . MISSING_SIGNATURE ) ;
16771686 }
16781687
1679- const signature = `${ fbTx . signedMessages [ 0 ] . signature . fullSig } 0${ fbTx . signedMessages [ 0 ] . signature . v } ` ;
1688+ const signature = `${ completedTx . signedMessages [ 0 ] . signature . fullSig } 0${ completedTx . signedMessages [ 0 ] . signature . v } ` ;
16801689
16811690 const preparedTx = await this . client . POST ( '/trx/transaction/prepare' , {
16821691 body : {
@@ -1691,10 +1700,22 @@ export class FireblocksService {
16911700
16921701 return {
16931702 signed_tx : preparedTx . data ,
1694- fireblocks_tx : fbTx ,
1703+ fireblocks_tx : completedTx ,
16951704 } ;
16961705 }
16971706
1707+ async signTrxTx (
1708+ integration : FireblocksIntegration ,
1709+ tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
1710+ note ?: string ,
1711+ ) : Promise < {
1712+ signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1713+ fireblocks_tx : TransactionResponse ;
1714+ } > {
1715+ const fbTx = await this . createTrxTx ( integration , tx , note ) ;
1716+ return await this . waitForTrxTxCompletion ( integration , tx , fbTx ) ;
1717+ }
1718+
16981719 /**
16991720 * Sign a SEI transaction on Fireblocks
17001721 */
0 commit comments