@riocrypto/common-server 1.0.1891 → 1.0.1892

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,17 @@ declare class FireblocksClient {
5
5
  constructor(privateKey: string, apiKey: string);
6
6
  estimateWithdrawFee(crypto: Crypto, address: string, amountCrypto: number): Promise<string | number | undefined>;
7
7
  withdrawFromExchange(rioId: string, crypto: Crypto, address: string, amountCrypto: number): Promise<void>;
8
- withdrawFromVault(rioId: string, crypto: Crypto, address: string, amountCrypto: number, vaultId?: string, notes?: string): Promise<string>;
8
+ withdrawFromVault({ rioId, crypto, destination, amountCrypto, vaultId, notes, }: {
9
+ rioId: string;
10
+ crypto: Crypto;
11
+ destination: {
12
+ address?: string;
13
+ fireblocksWalletId?: string;
14
+ };
15
+ amountCrypto: number;
16
+ vaultId?: string;
17
+ notes?: string;
18
+ }): Promise<string>;
9
19
  getVaultCryptoBalance(vaultId: string, crypto: Crypto): Promise<number>;
10
20
  getVaultCryptoAddress(vaultId: string, crypto: Crypto): Promise<string>;
11
21
  getTotalVaultUSDBalance(vaultId: string): Promise<number>;
@@ -75,8 +75,15 @@ class FireblocksClient {
75
75
  });
76
76
  });
77
77
  }
78
- withdrawFromVault(rioId, crypto, address, amountCrypto, vaultId, notes) {
78
+ withdrawFromVault({ rioId, crypto, destination, amountCrypto, vaultId, notes, }) {
79
79
  return __awaiter(this, void 0, void 0, function* () {
80
+ // Ensure either address or fireblocksWalletId is provided
81
+ if (!destination.address && !destination.fireblocksWalletId) {
82
+ throw new Error("Either address or fireblocksWalletId must be provided.");
83
+ }
84
+ if (destination.address && destination.fireblocksWalletId) {
85
+ throw new Error("Either address or fireblocksWalletId must be provided, not both.");
86
+ }
80
87
  if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
81
88
  throw new Error("Withdrawals are disabled in sandbox mode.");
82
89
  }
@@ -88,10 +95,17 @@ class FireblocksClient {
88
95
  id: vaultId ? vaultId : "2",
89
96
  },
90
97
  destination: {
91
- type: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
92
- oneTimeAddress: {
93
- address,
94
- },
98
+ type: destination.fireblocksWalletId
99
+ ? fireblocks_sdk_1.PeerType.EXTERNAL_WALLET
100
+ : fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
101
+ oneTimeAddress: destination.address
102
+ ? {
103
+ address: destination.address,
104
+ }
105
+ : undefined,
106
+ id: destination.fireblocksWalletId
107
+ ? destination.fireblocksWalletId
108
+ : undefined,
95
109
  },
96
110
  amount: amountCrypto,
97
111
  operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1891",
3
+ "version": "1.0.1892",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "@google-cloud/secret-manager": "^5.3.0",
27
27
  "@google-cloud/storage": "^6.9.5",
28
28
  "@hyperdx/node-opentelemetry": "^0.4.2",
29
- "@riocrypto/common": "^1.0.1695",
29
+ "@riocrypto/common": "^1.0.1696",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^1.6.0",
32
32
  "crypto-js": "^4.2.0",