Skip to content

Commit ebf18a6

Browse files
committed
ton flow transaction (#255)
* ton flow transaction * bump version
1 parent 853e138 commit ebf18a6

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kilnfi/sdk",
3-
"version": "4.2.23",
3+
"version": "4.2.24",
44
"autor": "Kiln <[email protected]> (https://kiln.fi)",
55
"license": "BUSL-1.1",
66
"description": "JavaScript sdk for Kiln API",

src/fireblocks.ts

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,31 +1385,44 @@ export class FireblocksService {
13851385
}
13861386

13871387
/**
1388-
* Sign a TON transaction on Fireblocks
1388+
* Create a TON transaction in Fireblocks without waiting for completion
13891389
*/
1390-
async signTonTx(
1390+
async createTonTx(
13911391
integration: FireblocksIntegration,
13921392
tx: components['schemas']['TONTx'],
13931393
assetId: 'TON_TEST' | 'TON',
13941394
note?: string,
1395-
): Promise<{
1396-
signed_tx: { data: components['schemas']['TONPreparedTx'] };
1397-
fireblocks_tx: TransactionResponse;
1398-
}> {
1395+
): Promise<TransactionResponse> {
13991396
const payload = {
14001397
rawMessageData: {
14011398
messages: [
14021399
{
14031400
content: tx.unsigned_tx_hash,
1401+
//TODO : ADD PREHASH LATER IF FB SUPPORT TON HASH ALGORITHM
14041402
},
14051403
],
14061404
},
14071405
};
14081406

14091407
const fbSigner = this.getSigner(integration);
14101408
const fbNote = note ? note : 'TON tx from @kilnfi/sdk';
1411-
const fbTx = await fbSigner.sign(payload, assetId, fbNote);
1412-
const signature = fbTx.signedMessages?.[0]?.signature?.fullSig;
1409+
return await fbSigner.createTransaction(payload, assetId, fbNote);
1410+
}
1411+
1412+
/**
1413+
* Wait for a TON transaction to complete and prepare it for broadcast
1414+
*/
1415+
async waitForTonTxCompletion(
1416+
integration: FireblocksIntegration,
1417+
tx: components['schemas']['TONTx'],
1418+
fbTx: TransactionResponse,
1419+
): Promise<{
1420+
signed_tx: { data: components['schemas']['TONPreparedTx'] };
1421+
fireblocks_tx: TransactionResponse;
1422+
}> {
1423+
const fbSigner = this.getSigner(integration);
1424+
const completedTx = await fbSigner.waitForTxCompletion(fbTx);
1425+
const signature = completedTx.signedMessages?.[0]?.signature?.fullSig;
14131426

14141427
if (!signature) {
14151428
throw new Error(ERRORS.MISSING_SIGNATURE);
@@ -1429,10 +1442,26 @@ export class FireblocksService {
14291442

14301443
return {
14311444
signed_tx: preparedTx.data,
1432-
fireblocks_tx: fbTx,
1445+
fireblocks_tx: completedTx,
14331446
};
14341447
}
14351448

1449+
/**
1450+
* Sign a TON transaction on Fireblocks
1451+
*/
1452+
async signTonTx(
1453+
integration: FireblocksIntegration,
1454+
tx: components['schemas']['TONTx'],
1455+
assetId: 'TON_TEST' | 'TON',
1456+
note?: string,
1457+
): Promise<{
1458+
signed_tx: { data: components['schemas']['TONPreparedTx'] };
1459+
fireblocks_tx: TransactionResponse;
1460+
}> {
1461+
const fbTx = await this.createTonTx(integration, tx, assetId, note);
1462+
return await this.waitForTonTxCompletion(integration, tx, fbTx);
1463+
}
1464+
14361465
/**
14371466
* Sign a XTZ transaction on Fireblocks
14381467
*/

0 commit comments

Comments
 (0)