@@ -1141,16 +1141,13 @@ export class FireblocksService {
11411141 }
11421142
11431143 /**
1144- * Sign a DOT transaction on Fireblocks
1144+ * Create a DOT transaction in Fireblocks without waiting for completion
11451145 */
1146- async signDotTx (
1146+ async createDotTx (
11471147 integration : FireblocksIntegration ,
11481148 tx : components [ 'schemas' ] [ 'DOTUnsignedTx' ] ,
11491149 note ?: string ,
1150- ) : Promise < {
1151- signed_tx : { data : components [ 'schemas' ] [ 'DOTSignedTx' ] } ;
1152- fireblocks_tx : TransactionResponse ;
1153- } > {
1150+ ) : Promise < TransactionResponse > {
11541151 const payload = {
11551152 rawMessageData : {
11561153 messages : [
@@ -1163,13 +1160,28 @@ export class FireblocksService {
11631160
11641161 const fbSigner = this . getSigner ( integration ) ;
11651162 const fbNote = note ? note : 'DOT tx from @kilnfi/sdk' ;
1166- const fbTx = await fbSigner . sign ( payload , 'DOT' , fbNote ) ;
1163+ return await fbSigner . createTransaction ( payload , 'DOT' , fbNote ) ;
1164+ }
11671165
1168- if ( ! fbTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ) {
1166+ /**
1167+ * Wait for a DOT transaction to complete and prepare it for broadcast
1168+ */
1169+ async waitForDotTxCompletion (
1170+ integration : FireblocksIntegration ,
1171+ tx : components [ 'schemas' ] [ 'DOTUnsignedTx' ] ,
1172+ fbTx : TransactionResponse ,
1173+ ) : Promise < {
1174+ signed_tx : { data : components [ 'schemas' ] [ 'DOTSignedTx' ] } ;
1175+ fireblocks_tx : TransactionResponse ;
1176+ } > {
1177+ const fbSigner = this . getSigner ( integration ) ;
1178+ const completedTx = await fbSigner . waitForTxCompletion ( fbTx ) ;
1179+
1180+ if ( ! completedTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ) {
11691181 throw new Error ( ERRORS . MISSING_SIGNATURE ) ;
11701182 }
11711183
1172- const signature = `0x00${ fbTx . signedMessages ?. [ 0 ] ?. signature . fullSig } ` ;
1184+ const signature = `0x00${ completedTx . signedMessages ?. [ 0 ] ?. signature . fullSig } ` ;
11731185
11741186 const preparedTx = await this . client . POST ( '/dot/transaction/prepare' , {
11751187 body : {
@@ -1184,21 +1196,33 @@ export class FireblocksService {
11841196
11851197 return {
11861198 signed_tx : preparedTx . data ,
1187- fireblocks_tx : fbTx ,
1199+ fireblocks_tx : completedTx ,
11881200 } ;
11891201 }
11901202
11911203 /**
1192- * Sign a KSM transaction on Fireblocks
1204+ * Sign a DOT transaction on Fireblocks
11931205 */
1194- async signKsmTx (
1206+ async signDotTx (
11951207 integration : FireblocksIntegration ,
1196- tx : components [ 'schemas' ] [ 'KSMUnsignedTx ' ] ,
1208+ tx : components [ 'schemas' ] [ 'DOTUnsignedTx ' ] ,
11971209 note ?: string ,
11981210 ) : Promise < {
1199- signed_tx : { data : components [ 'schemas' ] [ 'KSMSignedTx ' ] } ;
1211+ signed_tx : { data : components [ 'schemas' ] [ 'DOTSignedTx ' ] } ;
12001212 fireblocks_tx : TransactionResponse ;
12011213 } > {
1214+ const fbTx = await this . createDotTx ( integration , tx , note ) ;
1215+ return await this . waitForDotTxCompletion ( integration , tx , fbTx ) ;
1216+ }
1217+
1218+ /**
1219+ * Create a KSM transaction in Fireblocks without waiting for completion
1220+ */
1221+ async createKsmTx (
1222+ integration : FireblocksIntegration ,
1223+ tx : components [ 'schemas' ] [ 'KSMUnsignedTx' ] ,
1224+ note ?: string ,
1225+ ) : Promise < TransactionResponse > {
12021226 const payload = {
12031227 rawMessageData : {
12041228 messages : [
@@ -1211,13 +1235,28 @@ export class FireblocksService {
12111235
12121236 const fbSigner = this . getSigner ( integration ) ;
12131237 const fbNote = note ? note : 'KSM tx from @kilnfi/sdk' ;
1214- const fbTx = await fbSigner . sign ( payload , 'KSM' , fbNote ) ;
1238+ return await fbSigner . createTransaction ( payload , 'KSM' , fbNote ) ;
1239+ }
12151240
1216- if ( ! fbTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ) {
1241+ /**
1242+ * Wait for a KSM transaction to complete and prepare it for broadcast
1243+ */
1244+ async waitForKsmTxCompletion (
1245+ integration : FireblocksIntegration ,
1246+ tx : components [ 'schemas' ] [ 'KSMUnsignedTx' ] ,
1247+ fbTx : TransactionResponse ,
1248+ ) : Promise < {
1249+ signed_tx : { data : components [ 'schemas' ] [ 'KSMSignedTx' ] } ;
1250+ fireblocks_tx : TransactionResponse ;
1251+ } > {
1252+ const fbSigner = this . getSigner ( integration ) ;
1253+ const completedTx = await fbSigner . waitForTxCompletion ( fbTx ) ;
1254+
1255+ if ( ! completedTx . signedMessages ?. [ 0 ] ?. signature ?. fullSig ) {
12171256 throw new Error ( ERRORS . MISSING_SIGNATURE ) ;
12181257 }
12191258
1220- const signature = `0x00${ fbTx . signedMessages ?. [ 0 ] ?. signature . fullSig } ` ;
1259+ const signature = `0x00${ completedTx . signedMessages ?. [ 0 ] ?. signature . fullSig } ` ;
12211260
12221261 const preparedTx = await this . client . POST ( '/ksm/transaction/prepare' , {
12231262 body : {
@@ -1232,10 +1271,25 @@ export class FireblocksService {
12321271
12331272 return {
12341273 signed_tx : preparedTx . data ,
1235- fireblocks_tx : fbTx ,
1274+ fireblocks_tx : completedTx ,
12361275 } ;
12371276 }
12381277
1278+ /**
1279+ * Sign a KSM transaction on Fireblocks
1280+ */
1281+ async signKsmTx (
1282+ integration : FireblocksIntegration ,
1283+ tx : components [ 'schemas' ] [ 'KSMUnsignedTx' ] ,
1284+ note ?: string ,
1285+ ) : Promise < {
1286+ signed_tx : { data : components [ 'schemas' ] [ 'KSMSignedTx' ] } ;
1287+ fireblocks_tx : TransactionResponse ;
1288+ } > {
1289+ const fbTx = await this . createKsmTx ( integration , tx , note ) ;
1290+ return await this . waitForKsmTxCompletion ( integration , tx , fbTx ) ;
1291+ }
1292+
12391293 /**
12401294 * Sign an ETH transaction with given integration using Fireblocks raw signing
12411295 */
0 commit comments