@@ -1517,16 +1517,13 @@ export class FireblocksService {
15171517 }
15181518
15191519 /**
1520- * Sign a XTZ transaction on Fireblocks
1520+ * Create a XTZ transaction in Fireblocks without waiting for completion
15211521 */
1522- async signXtzTx (
1522+ async createXtzTx (
15231523 integration : FireblocksIntegration ,
15241524 tx : components [ 'schemas' ] [ 'XTZUnsignedTx' ] ,
15251525 note ?: string ,
1526- ) : Promise < {
1527- signed_tx : { data : components [ 'schemas' ] [ 'XTZSignedTx' ] } ;
1528- fireblocks_tx : TransactionResponse ;
1529- } > {
1526+ ) : Promise < TransactionResponse > {
15301527 const payload = {
15311528 rawMessageData : {
15321529 messages : [
@@ -1539,8 +1536,23 @@ export class FireblocksService {
15391536
15401537 const fbSigner = this . getSigner ( integration ) ;
15411538 const fbNote = note ? note : 'XTZ tx from @kilnfi/sdk' ;
1542- const fbTx = await fbSigner . sign ( payload , 'XTZ' , fbNote ) ;
1543- const signature = fbTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ;
1539+ return await fbSigner . createTransaction ( payload , 'XTZ' , fbNote ) ;
1540+ }
1541+
1542+ /**
1543+ * Wait for a XTZ transaction to complete and prepare it for broadcast
1544+ */
1545+ async waitForXtzTxCompletion (
1546+ integration : FireblocksIntegration ,
1547+ tx : components [ 'schemas' ] [ 'XTZUnsignedTx' ] ,
1548+ fbTx : TransactionResponse ,
1549+ ) : Promise < {
1550+ signed_tx : { data : components [ 'schemas' ] [ 'XTZSignedTx' ] } ;
1551+ fireblocks_tx : TransactionResponse ;
1552+ } > {
1553+ const fbSigner = this . getSigner ( integration ) ;
1554+ const completedTx = await fbSigner . waitForTxCompletion ( fbTx ) ;
1555+ const signature = completedTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ;
15441556
15451557 if ( ! signature ) {
15461558 throw new Error ( ERRORS . MISSING_SIGNATURE ) ;
@@ -1559,10 +1571,25 @@ export class FireblocksService {
15591571
15601572 return {
15611573 signed_tx : preparedTx . data ,
1562- fireblocks_tx : fbTx ,
1574+ fireblocks_tx : completedTx ,
15631575 } ;
15641576 }
15651577
1578+ /**
1579+ * Sign a XTZ transaction on Fireblocks (combines createXtzTx and waitForXtzTxCompletion)
1580+ */
1581+ async signXtzTx (
1582+ integration : FireblocksIntegration ,
1583+ tx : components [ 'schemas' ] [ 'XTZUnsignedTx' ] ,
1584+ note ?: string ,
1585+ ) : Promise < {
1586+ signed_tx : { data : components [ 'schemas' ] [ 'XTZSignedTx' ] } ;
1587+ fireblocks_tx : TransactionResponse ;
1588+ } > {
1589+ const fbTx = await this . createXtzTx ( integration , tx , note ) ;
1590+ return await this . waitForXtzTxCompletion ( integration , tx , fbTx ) ;
1591+ }
1592+
15661593 /**
15671594 * Create a NEAR transaction in Fireblocks without waiting for completion
15681595 */
0 commit comments