From 6c41bd7f0e01fb0706dba52994879a38ff1a2270 Mon Sep 17 00:00:00 2001 From: Kiln Bot Date: Wed, 6 Nov 2024 09:36:40 +0000 Subject: [PATCH 1/4] Update OpenAPI schema --- src/openapi/schema.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openapi/schema.ts b/src/openapi/schema.ts index 74f0339..c8fe946 100644 --- a/src/openapi/schema.ts +++ b/src/openapi/schema.ts @@ -7574,7 +7574,7 @@ export interface components { * @description Signed serialized transaction * @example 0x20a40259b763d549dfa1c082776a036dd8dabbe8b5e32ee721be017512dc */ - signed_tx_serialized?: string; + signed_tx_serialized: string; }; ETHBroadcastTxPayload: { /** @@ -10525,7 +10525,7 @@ export interface components { * @description Hex encoded signed transaction * @example 0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063b2b5ef76d483b695bc3b954d9a372ca5f744e00279c8578bc4268d570b701a037fac575ae16bb3ba5702b8d5bd9930953453e2d628368f83a11ab5896d20bbcae0b4a119860afd99da20f3462ba15d8bd1528d73724b83e8cc4cee00787df28a181783c264113ef1870bae5a90987fc5cfcdffaddf23c7dcfd7585c13d10b0301080c373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e1bb5f70b4d3ae65feb6d20587f62ccc8d5e720e99abe3d4415972bbf74a8a88a51f5f3871e65b84cc393458d0f23a413184cf2bb7093ae4e2c99d55b39a575c5f98e3135fcb53e71e6fafcb4da3a3cc36af1c76a1a7e72aa12eae1346d724c6c00000000000000000000000000000000000000000000000000000000000000004792650d1e9a4fe99721617c7d47c8712c14c20a76bf043368c6528c9090531a06a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d10000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517192c568ee08a845f73d29788cf035c3145b21ab344d8062ea940000006a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff4000000f0973e76495f3ffc65798a529de5cba4ec7f47f17669c9fa256923f099a1cda304040303090204040000000402000134000000000080c6a47e8d0300c80000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000602010a7400000000373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006060105080b07000402000000 */ - signed_tx_serialized?: string; + signed_tx_serialized: string; }; SOLBroadcastTxPayload: { /** @@ -13847,7 +13847,7 @@ export interface components { * @description Signed serialized transaction * @example 0x20a40259b763d549dfa1c082776a036dd8dabbe8b5e32ee721be017512dc */ - signed_tx_serialized?: string; + signed_tx_serialized: string; }; MATICBroadcastTxPayload: { /** @@ -14845,7 +14845,7 @@ export interface components { * @description Signed serialized transaction * @example 0x20a40259b763d549dfa1c082776a036dd8dabbe8b5e32ee721be017512dc */ - signed_tx_serialized?: string; + signed_tx_serialized: string; }; POLBroadcastTxPayload: { /** @@ -28685,7 +28685,7 @@ export interface components { * @description Hex encoded signed transaction * @example te6cckEBAgEArQAB4YgA5oNgWZxV/vmCVySWkd/+Ly7CyQyhqFCcRKDOeq9dHGQCwbrVOyBsePyBHxhgq2rFjwPztBlAoqTbAz4Bic+CviWY9yGrfqvCtJ3eixgCVJfmep5AYnuQcOfmcC3TIwG4SU1NGLsz4oOoAAAAAAAcAQBuYn+9vlumg/kDozb4tq5nD1FDm0UHgjwhqQxEfjMglJZP+Lg41+pMaAAAAAAAAAAAAAAAAAAAAKKEVgs= */ - signed_tx_serialized?: string; + signed_tx_serialized: string; }; TONBroadcastTxPayload: { /** @@ -28699,7 +28699,7 @@ export interface components { * @description Hash of the transaction * @example SQ5y4jeRZzU4h/lbyWiLhTrR9A3smK5Vmm/1p9ylDFo= */ - tx_hash?: string; + tx_hash: string; }; /** @example { * "transactions": [ @@ -44312,7 +44312,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: components["schemas"]["CoreStake"]; + data: components["schemas"]["CoreStake"]; }; }; }; @@ -44500,7 +44500,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: { + data: { /** * @description Status of the wallet * @example active @@ -44554,7 +44554,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: { + data: { /** * @description The balance of the account * @example 1000000 @@ -44751,7 +44751,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: components["schemas"]["TONPreparedTx"]; + data: components["schemas"]["TONPreparedTx"]; }; }; }; @@ -44799,7 +44799,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: components["schemas"]["TONBroadcastTx"]; + data: components["schemas"]["TONBroadcastTx"]; }; }; }; @@ -44845,7 +44845,7 @@ export interface operations { }; content: { "application/json; charset=utf-8": { - data?: components["schemas"]["TONTxStatus"]; + data: components["schemas"]["TONTxStatus"]; }; }; }; From d80ccf5254adfd67ed77c52f16241d9375f5e138 Mon Sep 17 00:00:00 2001 From: Martin Saldinger Date: Wed, 6 Nov 2024 10:41:19 +0100 Subject: [PATCH 2/4] nit --- src/fireblocks_signer.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fireblocks_signer.ts b/src/fireblocks_signer.ts index 4b79c6f..e18f5e2 100644 --- a/src/fireblocks_signer.ts +++ b/src/fireblocks_signer.ts @@ -49,7 +49,6 @@ export class FireblocksSigner { /** * Wait for given transaction to be completed * @param fbTx fireblocks transaction - * @private */ protected async waitForTxCompletion(fbTx: CreateTransactionResponse): Promise { try { From de7b32ea792f708bf5ab5aa9f236d70289b27ca2 Mon Sep 17 00:00:00 2001 From: Martin Saldinger Date: Wed, 6 Nov 2024 10:41:53 +0100 Subject: [PATCH 3/4] improve typing of fireblocks --- src/fireblocks.ts | 225 +++++++++++++++++++++++++++++----------------- 1 file changed, 142 insertions(+), 83 deletions(-) diff --git a/src/fireblocks.ts b/src/fireblocks.ts index cfb3784..f2c29ba 100644 --- a/src/fireblocks.ts +++ b/src/fireblocks.ts @@ -4,6 +4,7 @@ import { type PublicKeyResponse, type SDKOptions, SigningAlgorithm, + type TransactionResponse, } from 'fireblocks-sdk'; import type { IAuthProvider } from 'fireblocks-sdk/dist/src/iauth-provider.js'; import type { Client } from 'openapi-fetch'; @@ -31,7 +32,6 @@ export class FireblocksService { /** * Retrieve a fireblocks SDK from a Fireblocks integration - * @param integration */ getSdk(integration: FireblocksIntegration): FireblocksSDK { return new FireblocksSDK( @@ -45,16 +45,14 @@ export class FireblocksService { /** * Retrieve a fireblocks signer from a Fireblocks integration - * @param integration */ getSigner(integration: FireblocksIntegration): FireblocksSigner { const sdk = this.getSdk(integration); return new FireblocksSigner(sdk, integration.vaultId); } + /** * Get fireblocks wallet pubkey compressed - * @param integration - * @param assetId */ async getPubkey(integration: FireblocksIntegration, assetId: string): Promise { const fbSdk = this.getSdk(integration); @@ -70,7 +68,6 @@ export class FireblocksService { /** * List Fireblocks supported assets - * @param integration */ async getAssets(integration: FireblocksIntegration): Promise { const fbSdk = this.getSdk(integration); @@ -79,17 +76,16 @@ export class FireblocksService { /** * Sign a Solana transaction on Fireblocks - * @param integration - * @param tx - * @param assetId - * @param note */ async signSolTx( integration: FireblocksIntegration, tx: components['schemas']['SOLStakeTx'], assetId: 'SOL_TEST' | 'SOL', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['SOLPreparedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -118,6 +114,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -126,11 +126,15 @@ export class FireblocksService { /** * Sign a Cardano transaction on Fireblocks - * @param integration - * @param tx - * @param note */ - async signAdaTx(integration: FireblocksIntegration, tx: components['schemas']['ADAUnsignedTx'], note?: string) { + async signAdaTx( + integration: FireblocksIntegration, + tx: components['schemas']['ADAUnsignedTx'], + note?: string, + ): Promise<{ + signed_tx: { data: components['schemas']['ADASignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -169,6 +173,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -177,17 +185,16 @@ export class FireblocksService { /** * Sign a ATOM transaction on Fireblocks - * @param integration - * @param tx - * @param assetId - * @param note */ async signAtomTx( integration: FireblocksIntegration, tx: components['schemas']['ATOMUnsignedTx'] | components['schemas']['ATOMStakeUnsignedTx'], assetId: 'ATOM_COS' | 'ATOM_COS_TEST', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['ATOMSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -220,6 +227,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -228,15 +239,15 @@ export class FireblocksService { /** * Sign a DYDX transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signDydxTx( integration: FireblocksIntegration, tx: components['schemas']['DYDXUnsignedTx'] | components['schemas']['DYDXStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['DYDXSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -269,6 +280,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -277,15 +292,15 @@ export class FireblocksService { /** * Sign a FET transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signFetTx( integration: FireblocksIntegration, tx: components['schemas']['FETUnsignedTx'] | components['schemas']['FETStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['FETSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -320,6 +335,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -328,15 +347,15 @@ export class FireblocksService { /** * Sign a INJ transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signInjTx( integration: FireblocksIntegration, tx: components['schemas']['INJUnsignedTx'] | components['schemas']['INJStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['INJSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -369,6 +388,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -377,15 +400,15 @@ export class FireblocksService { /** * Sign a KAVA transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signKavaTx( integration: FireblocksIntegration, tx: components['schemas']['KAVAUnsignedTx'] | components['schemas']['KAVAStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['KAVASignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -418,6 +441,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -426,15 +453,15 @@ export class FireblocksService { /** * Sign a OSMO transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signOsmoTx( integration: FireblocksIntegration, tx: components['schemas']['OSMOUnsignedTx'] | components['schemas']['OSMOStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['OSMOSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -467,6 +494,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -475,15 +506,15 @@ export class FireblocksService { /** * Sign a TIA transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signTiaTx( integration: FireblocksIntegration, tx: components['schemas']['TIAUnsignedTx'] | components['schemas']['TIAStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['TIASignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -516,6 +547,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -524,15 +559,15 @@ export class FireblocksService { /** * Sign a ZETA transaction on Fireblocks - * @param integration - * @param tx - * @param note */ async signZetaTx( integration: FireblocksIntegration, tx: components['schemas']['ZETAUnsignedTx'] | components['schemas']['ZETAStakeUnsignedTx'], note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['ZETASignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -567,6 +602,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -575,11 +614,15 @@ export class FireblocksService { /** * Sign a DOT transaction on Fireblocks - * @param integration - * @param tx - * @param note */ - async signDotTx(integration: FireblocksIntegration, tx: components['schemas']['DOTUnsignedTx'], note?: string) { + async signDotTx( + integration: FireblocksIntegration, + tx: components['schemas']['DOTUnsignedTx'], + note?: string, + ): Promise<{ + signed_tx: { data: components['schemas']['DOTSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -602,6 +645,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -610,11 +657,15 @@ export class FireblocksService { /** * Sign a KSM transaction on Fireblocks - * @param integration - * @param tx - * @param note */ - async signKsmTx(integration: FireblocksIntegration, tx: components['schemas']['KSMUnsignedTx'], note?: string) { + async signKsmTx( + integration: FireblocksIntegration, + tx: components['schemas']['KSMUnsignedTx'], + note?: string, + ): Promise<{ + signed_tx: { data: components['schemas']['KSMSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -637,6 +688,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -645,17 +700,16 @@ export class FireblocksService { /** * Sign and broadcast an ETH transaction with given integration using Fireblocks contract call feature - * @param integration - * @param tx - * @param assetId - * @param note */ async signEthTx( integration: FireblocksIntegration, tx: components['schemas']['ETHUnsignedTx'], assetId: 'ETH_TEST6' | 'ETH', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['ETHSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -689,6 +743,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -697,10 +755,6 @@ export class FireblocksService { /** * Sign and broadcast an ETH transaction with given integration using Fireblocks contract call feature - * @param integration - * @param tx - * @param assetId - * @param note */ async signAndBroadcastEthTx( integration: FireblocksIntegration, @@ -722,10 +776,6 @@ export class FireblocksService { /** * Sign and broadcast a POL transaction with given integration using Fireblocks contract call feature - * @param integration - * @param tx - * @param assetId - * @param note */ async signAndBroadcastPolTx( integration: FireblocksIntegration, @@ -747,17 +797,16 @@ export class FireblocksService { /** * Sign a TON transaction on Fireblocks - * @param integration - * @param tx - * @param assetId - * @param note */ async signTonTx( integration: FireblocksIntegration, tx: components['schemas']['TONTx'], assetId: 'TON_TEST' | 'TON', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['TONPreparedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -785,6 +834,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -793,17 +846,16 @@ export class FireblocksService { /** * Sign a XTZ transaction on Fireblocks - * @param integration - * @param tx - * @param assetId - * @param note */ async signXtzTx( integration: FireblocksIntegration, tx: components['schemas']['XTZUnsignedTx'], assetId: 'XTZ_TEST' | 'XTZ', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['XTZSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -830,6 +882,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, @@ -838,17 +894,16 @@ export class FireblocksService { /** * Sign a NEAR transaction on Fireblocks - * @param integration - * @param tx - * @param assetId - * @param note */ async signNearTx( integration: FireblocksIntegration, tx: components['schemas']['NEARTx'], assetId: 'NEAR_TEST' | 'NEAR', note?: string, - ) { + ): Promise<{ + signed_tx: { data: components['schemas']['NEARSignedTx'] }; + fireblocks_tx: TransactionResponse; + }> { const payload = { rawMessageData: { messages: [ @@ -875,6 +930,10 @@ export class FireblocksService { }, }); + if (preparedTx.error) { + throw new Error('Failed to prepare transaction'); + } + return { signed_tx: preparedTx.data, fireblocks_tx: fbTx, From fa7959c15636a38a72d9bb74db3db86e6e0ab969 Mon Sep 17 00:00:00 2001 From: Martin Saldinger Date: Wed, 6 Nov 2024 10:42:00 +0100 Subject: [PATCH 4/4] bump to 3.1.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9096a5b..c2e5183 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kilnfi/sdk", - "version": "3.1.13", + "version": "3.1.14", "autor": "Kiln (https://kiln.fi)", "license": "BUSL-1.1", "description": "JavaScript sdk for Kiln API",