Skip to content

Commit 598930d

Browse files
authored
add fireblocks tx in response of sign() functions (#82)
1 parent 12ca4bc commit 598930d

File tree

19 files changed

+50
-23
lines changed

19 files changed

+50
-23
lines changed

src/services/ada.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export class AdaService extends Service {
138138
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
139139
signed_messages: signedMessages,
140140
});
141+
142+
data.data.fireblocks_tx = fbTx;
141143
return data;
142144
} catch (err: any) {
143145
throw new Error(err);

src/services/atom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export class AtomService extends Service {
150150
};
151151
const fbNote = note ? note : 'ATOM tx from @kilnfi/sdk';
152152
const signer = this.getFbSigner(integration);
153-
const signedTx = await signer.signWithFB(payload, this.testnet ? 'ATOM_COS_TEST' : 'ATOM_COS', fbNote);
154-
const signature: string = signedTx.signedMessages![0].signature.fullSig;
153+
const fbTx = await signer.signWithFB(payload, this.testnet ? 'ATOM_COS_TEST' : 'ATOM_COS', fbNote);
154+
const signature: string = fbTx.signedMessages![0].signature.fullSig;
155155
const { data } = await api.post<AtomSignedTx>(
156156
`/v1/atom/transaction/prepare`,
157157
{
@@ -160,6 +160,7 @@ export class AtomService extends Service {
160160
tx_auth_info: tx.data.tx_auth_info,
161161
signature: signature,
162162
});
163+
data.data.fireblocks_tx = fbTx;
163164
return data;
164165
}
165166

src/services/dot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,16 @@ export class DotService extends Service {
382382

383383
const fbSigner = this.getFbSigner(integration);
384384
const fbNote = note ? note : 'DOT tx from @kilnfi/sdk';
385-
const fbSignatures = await fbSigner.signWithFB(payload, this.testnet ? 'WND' : 'DOT', fbNote);
386-
const signature = `0x00${fbSignatures.signedMessages![0].signature.fullSig}`;
385+
const fbTx = await fbSigner.signWithFB(payload, this.testnet ? 'WND' : 'DOT', fbNote);
386+
const signature = `0x00${fbTx.signedMessages![0].signature.fullSig}`;
387387

388388
const { data } = await api.post<DotSignedTx>(
389389
`/v1/dot/transaction/prepare`,
390390
{
391391
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
392392
signature: signature,
393393
});
394+
data.data.fireblocks_tx = fbTx;
394395
return data;
395396
} catch (err: any) {
396397
throw new Error(err);

src/services/eth.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class EthService extends Service {
8888
const fbSigner = this.getFbSigner(integration);
8989
const assetId = this.testnet ? 'ETH_TEST6' : 'ETH';
9090
const fbNote = note ? note : 'ETH tx from @kilnfi/sdk';
91-
const signatures = await fbSigner.signWithFB(
91+
const fbTx = await fbSigner.signWithFB(
9292
payload,
9393
assetId,
9494
fbNote,
@@ -97,10 +97,11 @@ export class EthService extends Service {
9797
`/v1/eth/transaction/prepare`,
9898
{
9999
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
100-
r: `0x${signatures?.signedMessages?.[0].signature.r}`,
101-
s: `0x${signatures?.signedMessages?.[0].signature.s}`,
102-
v: signatures?.signedMessages?.[0].signature.v ?? 0,
100+
r: `0x${fbTx?.signedMessages?.[0].signature.r}`,
101+
s: `0x${fbTx?.signedMessages?.[0].signature.s}`,
102+
v: fbTx?.signedMessages?.[0].signature.v ?? 0,
103103
});
104+
data.data.fireblocks_tx = fbTx;
104105
return data;
105106
} catch (err: any) {
106107
throw new Error(err);

src/services/matic.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,16 @@ export class MaticService extends Service {
186186

187187
const fbSigner = this.getFbSigner(integration);
188188
const fbNote = note ? note : 'MATIC tx from @kilnfi/sdk';
189-
const signatures = await fbSigner.signWithFB(payload, this.testnet ? 'ETH_TEST3' : 'ETH', fbNote);
189+
const fbTx = await fbSigner.signWithFB(payload, this.testnet ? 'ETH_TEST3' : 'ETH', fbNote);
190190
const { data } = await api.post<MaticSignedTx>(
191191
`/v1/matic/transaction/prepare`,
192192
{
193193
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
194-
r: `0x${signatures?.signedMessages?.[0].signature.r}`,
195-
s: `0x${signatures?.signedMessages?.[0].signature.s}`,
196-
v: signatures?.signedMessages?.[0].signature.v ?? 0,
194+
r: `0x${fbTx?.signedMessages?.[0].signature.r}`,
195+
s: `0x${fbTx?.signedMessages?.[0].signature.s}`,
196+
v: fbTx?.signedMessages?.[0].signature.v ?? 0,
197197
});
198+
data.data.fireblocks_tx = fbTx;
198199
return data;
199200
} catch (err: any) {
200201
throw new Error(err);

src/services/near.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ export class NearService extends Service {
240240

241241
const fbSigner = this.getFbSigner(integration);
242242
const fbNote = note ? note : 'NEAR tx from @kilnfi/sdk';
243-
const signatures = await fbSigner.signWithFB(payload, this.testnet ? 'NEAR_TEST' : 'NEAR', fbNote);
244-
const signature = signatures.signedMessages![0];
243+
const fbTx = await fbSigner.signWithFB(payload, this.testnet ? 'NEAR_TEST' : 'NEAR', fbNote);
244+
const signature = fbTx.signedMessages![0];
245245

246246
const signedTx = new transactions.SignedTransaction({
247247
transaction: tx.data.tx,
@@ -253,6 +253,7 @@ export class NearService extends Service {
253253

254254
return {
255255
data: {
256+
fireblocks_tx: fbTx,
256257
tx: signedTx,
257258
},
258259
};

src/services/osmo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export class OsmoService extends Service {
150150
};
151151
const fbNote = note ? note : 'OSMO tx from @kilnfi/sdk';
152152
const signer = this.getFbSigner(integration);
153-
const signedTx = await signer.signWithFB(payload, this.testnet ? 'OSMO_TEST' : 'OSMO', fbNote);
154-
const signature: string = signedTx.signedMessages![0].signature.fullSig;
153+
const fbTx = await signer.signWithFB(payload, this.testnet ? 'OSMO_TEST' : 'OSMO', fbNote);
154+
const signature: string = fbTx.signedMessages![0].signature.fullSig;
155155
const { data } = await api.post<OsmoSignedTx>(
156156
`/v1/osmo/transaction/prepare`,
157157
{
@@ -160,6 +160,7 @@ export class OsmoService extends Service {
160160
tx_auth_info: tx.data.tx_auth_info,
161161
signature: signature,
162162
});
163+
data.data.fireblocks_tx = fbTx;
163164
return data;
164165
}
165166

src/services/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class Service {
1212

1313
/**
1414
* Retrieve a fireblocks SDK from a Fireblocks integration
15-
* @param integration: Fireblocks integration
15+
* @param integration
1616
*/
1717
getFbSdk(integration: FireblocksIntegration): FireblocksSDK {
1818
try {
@@ -24,7 +24,7 @@ export class Service {
2424

2525
/**
2626
* Retrieve a fireblocks signer from a Fireblocks integration
27-
* @param integration: Fireblocks integration
27+
* @param integration
2828
*/
2929
getFbSigner(integration: FireblocksIntegration): FbSigner {
3030
try {

src/services/sol.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ export class SolService extends Service {
171171

172172
const fbSigner = this.getFbSigner(integration);
173173
const fbNote = note ? note : 'SOL tx from @kilnfi/sdk';
174-
const fbSignatures = await fbSigner.signWithFB(payload, this.testnet ? 'SOL_TEST' : 'SOL', fbNote);
174+
const fbTx = await fbSigner.signWithFB(payload, this.testnet ? 'SOL_TEST' : 'SOL', fbNote);
175175
const signatures: string[] = [];
176-
fbSignatures.signedMessages?.forEach((signedMessage: any) => {
176+
fbTx.signedMessages?.forEach((signedMessage: any) => {
177177
if (signedMessage.derivationPath[3] == 0) {
178178
signatures.push(signedMessage.signature.fullSig);
179179
}
@@ -185,6 +185,7 @@ export class SolService extends Service {
185185
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
186186
signatures: signatures,
187187
});
188+
data.data.fireblocks_tx = fbTx;
188189
return data;
189190
} catch (err: any) {
190191
throw new Error(err);

src/services/xtz.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ export class XtzService extends Service {
8080

8181
const fbSigner = this.getFbSigner(integration);
8282
const fbNote = note ? note : 'XTZ tx from @kilnfi/sdk';
83-
const signedTx = await fbSigner.signWithFB(payload, this.testnet ? 'XTZ_TEST' : 'XTZ', fbNote);
84-
const signature: string = signedTx.signedMessages![0].signature.fullSig;
83+
const fbTx = await fbSigner.signWithFB(payload, this.testnet ? 'XTZ_TEST' : 'XTZ', fbNote);
84+
const signature: string = fbTx.signedMessages![0].signature.fullSig;
8585
const { data } = await api.post<XtzSignedTx>(
8686
`/v1/xtz/transaction/prepare`,
8787
{
8888
unsigned_tx_serialized: tx.data.unsigned_tx_serialized,
8989
signature: signature,
9090
});
91+
data.data.fireblocks_tx = fbTx;
9192
return data;
9293
}
9394

0 commit comments

Comments
 (0)