@@ -1673,14 +1673,11 @@ export class FireblocksService {
16731673 /**
16741674 * Sign a Trx transaction on Fireblocks
16751675 */
1676- async signTrxTx (
1676+ async createTrxTx (
16771677 integration : FireblocksIntegration ,
16781678 tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
16791679 note ?: string ,
1680- ) : Promise < {
1681- signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1682- fireblocks_tx : TransactionResponse ;
1683- } > {
1680+ ) : Promise < TransactionResponse > {
16841681 const payload = {
16851682 rawMessageData : {
16861683 messages : [
@@ -1697,13 +1694,25 @@ export class FireblocksService {
16971694
16981695 const fbSigner = this . getSigner ( integration ) ;
16991696 const fbNote = note ? note : 'TRX tx from @kilnfi/sdk' ;
1700- const fbTx = await fbSigner . sign ( payload , 'TRX' , fbNote ) ;
1697+ return await fbSigner . createTransaction ( payload , 'TRX' , fbNote ) ;
1698+ }
17011699
1702- if ( ! fbTx . signedMessages ?. [ 0 ] ?. signature ) {
1700+ async waitForTrxTxCompletion (
1701+ integration : FireblocksIntegration ,
1702+ tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
1703+ fbTx : TransactionResponse ,
1704+ ) : Promise < {
1705+ signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1706+ fireblocks_tx : TransactionResponse ;
1707+ } > {
1708+ const fbSigner = this . getSigner ( integration ) ;
1709+ const completedTx = await fbSigner . waitForTxCompletion ( fbTx ) ;
1710+
1711+ if ( ! completedTx . signedMessages ?. [ 0 ] ?. signature ) {
17031712 throw new Error ( ERRORS . MISSING_SIGNATURE ) ;
17041713 }
17051714
1706- const signature = `${ fbTx . signedMessages [ 0 ] . signature . fullSig } 0${ fbTx . signedMessages [ 0 ] . signature . v } ` ;
1715+ const signature = `${ completedTx . signedMessages [ 0 ] . signature . fullSig } 0${ completedTx . signedMessages [ 0 ] . signature . v } ` ;
17071716
17081717 const preparedTx = await this . client . POST ( '/trx/transaction/prepare' , {
17091718 body : {
@@ -1718,10 +1727,22 @@ export class FireblocksService {
17181727
17191728 return {
17201729 signed_tx : preparedTx . data ,
1721- fireblocks_tx : fbTx ,
1730+ fireblocks_tx : completedTx ,
17221731 } ;
17231732 }
17241733
1734+ async signTrxTx (
1735+ integration : FireblocksIntegration ,
1736+ tx : components [ 'schemas' ] [ 'TRXUnsignedTx' ] ,
1737+ note ?: string ,
1738+ ) : Promise < {
1739+ signed_tx : { data : components [ 'schemas' ] [ 'TRXPreparedTx' ] } ;
1740+ fireblocks_tx : TransactionResponse ;
1741+ } > {
1742+ const fbTx = await this . createTrxTx ( integration , tx , note ) ;
1743+ return await this . waitForTrxTxCompletion ( integration , tx , fbTx ) ;
1744+ }
1745+
17251746 /**
17261747 * Sign a SEI transaction on Fireblocks
17271748 */
0 commit comments