Skip to content

Commit b48aa69

Browse files
authored
allow passing custom fireblocks params (#146)
* add `ukavaToKava` to utils * update fireblocks sdk * allow passing custom `fireblocksApiBaseUrl`, `fireblocksAuthProvider` and `fireblocksSdkOptions` * bump version to 1.11 * fix lint
1 parent 9e9ce3c commit b48aa69

File tree

4 files changed

+92
-27
lines changed

4 files changed

+92
-27
lines changed

bun.lockb

21.2 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kilnfi/sdk",
3-
"version": "3.1.10",
3+
"version": "3.1.11",
44
"autor": "Kiln <[email protected]> (https://kiln.fi)",
55
"license": "BUSL-1.1",
66
"description": "JavaScript sdk for Kiln API",
@@ -35,7 +35,7 @@
3535
"homepage": "https://github.com/kilnfi/sdk-js#readme",
3636
"dependencies": {
3737
"@types/bun": "^1.1.11",
38-
"fireblocks-sdk": "^4.2.0",
38+
"fireblocks-sdk": "^5.32.0",
3939
"openapi-fetch": "^0.12.0",
4040
"viem": "^2.21.29"
4141
},

src/fireblocks.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { type AssetTypeResponse, FireblocksSDK, type PublicKeyResponse, SigningAlgorithm } from 'fireblocks-sdk';
1+
import {
2+
type AssetTypeResponse,
3+
FireblocksSDK,
4+
type PublicKeyResponse,
5+
type SDKOptions,
6+
SigningAlgorithm,
7+
} from 'fireblocks-sdk';
8+
import type { IAuthProvider } from 'fireblocks-sdk/dist/src/iauth-provider.js';
29
import type { Client } from 'openapi-fetch';
310
import { FireblocksSigner } from './fireblocks_signer.js';
411
import type { components, paths } from './openapi/schema.js';
@@ -10,6 +17,9 @@ export type FireblocksIntegration = {
1017
vaultId: number;
1118
name?: string;
1219
fireblocksDestinationId?: string;
20+
fireblocksApiBaseUrl?: string;
21+
fireblocksAuthProvider?: IAuthProvider;
22+
fireblocksSdkOptions?: SDKOptions;
1323
};
1424

1525
export class FireblocksService {
@@ -24,7 +34,13 @@ export class FireblocksService {
2434
* @param integration
2535
*/
2636
getSdk(integration: FireblocksIntegration): FireblocksSDK {
27-
return new FireblocksSDK(integration.fireblocksSecretKey, integration.fireblocksApiKey);
37+
return new FireblocksSDK(
38+
integration.fireblocksSecretKey,
39+
integration.fireblocksApiKey,
40+
integration.fireblocksApiBaseUrl,
41+
integration.fireblocksAuthProvider,
42+
integration.fireblocksSdkOptions,
43+
);
2844
}
2945

3046
/**

src/utils.ts

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,155 @@
1-
import { formatEther, formatUnits, parseUnits } from 'viem';
1+
import { formatUnits, parseUnits } from 'viem';
22

3-
// Convert wei to ETH
3+
/**
4+
* Convert wei to ETH
5+
*/
46
export const weiToEth = (wei: bigint): string => {
5-
return formatEther(BigInt(wei));
7+
return formatUnits(wei, 18);
68
};
79

8-
// Convert wei to POL
10+
/**
11+
* Convert wei to POL
12+
*/
913
export const weiToPol = (wei: bigint): string => {
1014
return formatUnits(wei, 18);
1115
};
1216

13-
// Convert lamports to SOL
17+
/**
18+
* Convert lamports to SOL
19+
*/
1420
export const lamportsToSol = (lamports: bigint): string => {
1521
return formatUnits(lamports, 9);
1622
};
1723

18-
// Convert SOL to lamports
24+
/**
25+
* Convert SOL to lamports
26+
*/
1927
export const solToLamports = (sol: string): bigint => {
2028
return parseUnits(sol, 9);
2129
};
2230

23-
// Convert XTZ to mutez
31+
/**
32+
* Convert XTZ to mutez
33+
*/
2434
export const xtzToMutez = (xtz: string): bigint => {
2535
return parseUnits(xtz, 6);
2636
};
2737

28-
// Convert Cardano lovelace to ADA
38+
/**
39+
* Convert Cardano lovelace to ADA
40+
*/
2941
export const lovelaceToAda = (lovelace: bigint): string => {
3042
return formatUnits(lovelace, 6);
3143
};
3244

33-
// Converts yocto to NEAR
45+
/**
46+
* Converts yocto to NEAR
47+
*/
3448
export const yoctoToNear = (yocto: bigint): string => {
3549
return formatUnits(yocto, 24);
3650
};
3751

38-
// Convert nanoTON to TON
52+
/**
53+
* Convert nanoTON to TON
54+
*/
3955
export const nanotonToTon = (nanoton: bigint): string => {
4056
return formatUnits(nanoton, 9);
4157
};
4258

43-
// Convert uZETA to ZETA
59+
/**
60+
* Convert uZETA to ZETA
61+
*/
4462
export const uzetaToZeta = (uzeta: bigint): string => {
4563
return formatUnits(uzeta, 6);
4664
};
4765

48-
// Convert uINJ to INJ
66+
/**
67+
* Convert uINJ to INJ
68+
*/
4969
export const uinjToInj = (uinj: bigint): string => {
5070
return formatUnits(uinj, 6);
5171
};
5272

53-
// Convert aFET to FET
73+
/**
74+
* Convert aFET to FET
75+
*/
5476
export const afetToFet = (afet: bigint): string => {
5577
return formatUnits(afet, 18);
5678
};
5779

58-
// Convert uFET to FET
80+
/**
81+
* Convert uFET to FET
82+
*/
5983
export const ufetToFet = (ufet: bigint): string => {
6084
return formatUnits(ufet, 6);
6185
};
6286

63-
// Convert mutez to XTZ
87+
/**
88+
* Convert mutez to XTZ
89+
*/
6490
export const mutezToXtz = (mutez: bigint): string => {
6591
return formatUnits(mutez, 6);
6692
};
6793

68-
// Convert uDYDX to DYDX
94+
/**
95+
* Convert uDYDX to DYDX
96+
*/
6997
export const udydxToDydx = (udydx: bigint): string => {
7098
return formatUnits(udydx, 6);
7199
};
72100

73-
// Convert planck to DOT
101+
/**
102+
* Convert planck to DOT
103+
*/
74104
export const planckToDot = (planck: bigint): string => {
75105
return formatUnits(planck, 10);
76106
};
77107

78-
// Convert planck to KSM
108+
/**
109+
* Convert planck to KSM
110+
*/
79111
export const planckToKsm = (planck: bigint): string => {
80112
return formatUnits(planck, 12);
81113
};
82114

83-
// Convert uATOM to ATOM
115+
/**
116+
* Convert uATOM to ATOM
117+
*/
84118
export const uatomToAtom = (uatom: bigint): string => {
85119
return formatUnits(uatom, 6);
86120
};
87121

88-
// Convert u{Cosmos chain token: ATOM, OSMO, etc...} to {Cosmos chain token: ATOM, OSMO, etc...}
122+
/**
123+
* Convert u{Cosmos chain token: ATOM, OSMO, etc...} to {Cosmos chain token: ATOM, OSMO, etc...}
124+
*/
89125
export const uunitToUnit = (uunit: bigint): string => {
90126
return formatUnits(uunit, 6);
91127
};
92128

93-
// Convert uOSMO to OSMO
129+
/**
130+
* Convert uOSMO to OSMO
131+
*/
94132
export const uosmoToOsmo = (uosmo: bigint): string => {
95133
return formatUnits(uosmo, 6);
96134
};
97135

98-
// Convert uTIA to TIA
136+
/**
137+
* Convert uTIA to TIA
138+
*/
99139
export const utiaToTia = (utia: bigint): string => {
100140
return formatUnits(utia, 6);
101141
};
102142

103-
// Convert uusdc to USDC
143+
/**
144+
* Convert uusdc to USDC
145+
*/
104146
export const uusdcToUsdc = (uusdc: bigint): string => {
105147
return formatUnits(uusdc, 6);
106148
};
149+
150+
/**
151+
* Convert uKAVA to KAVA
152+
*/
153+
export const ukavaToKava = (ukava: bigint): string => {
154+
return formatUnits(ukava, 6);
155+
};

0 commit comments

Comments
 (0)