@zubari/sdk 0.5.3 → 0.5.4

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.
Files changed (45) hide show
  1. package/dist/{PayoutsProtocol-B5z8SEA-.d.ts → PayoutsProtocol-DAa-9A5C.d.ts} +8 -1
  2. package/dist/{PayoutsProtocol-CLiMFe54.d.mts → PayoutsProtocol-DKEQhwYH.d.mts} +8 -1
  3. package/dist/{TransactionService-BtWUjKt_.d.ts → TransactionService-BEkgF1T6.d.ts} +12 -2
  4. package/dist/{TransactionService-Lr_WS6iR.d.mts → TransactionService-CF_C3Kqm.d.mts} +12 -2
  5. package/dist/{WalletManager-DQQwVkoa.d.ts → WalletManager-CeLlZo2y.d.ts} +23 -2
  6. package/dist/{WalletManager-Sbpx4E1-.d.mts → WalletManager-DIx8nENh.d.mts} +23 -2
  7. package/dist/{contracts-B842YprC.d.mts → contracts-JfZDzaV7.d.ts} +11 -2
  8. package/dist/{contracts-s_CDIruh.d.ts → contracts-pugJnFzl.d.mts} +11 -2
  9. package/dist/{index-CTyZlHKg.d.mts → index-c90msmwW.d.mts} +2 -1
  10. package/dist/{index-CTyZlHKg.d.ts → index-c90msmwW.d.ts} +2 -1
  11. package/dist/index.d.mts +5 -5
  12. package/dist/index.d.ts +5 -5
  13. package/dist/index.js +129 -136
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +129 -136
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/protocols/index.d.mts +2 -2
  18. package/dist/protocols/index.d.ts +2 -2
  19. package/dist/protocols/index.js +24 -11
  20. package/dist/protocols/index.js.map +1 -1
  21. package/dist/protocols/index.mjs +24 -11
  22. package/dist/protocols/index.mjs.map +1 -1
  23. package/dist/react/index.d.mts +3 -3
  24. package/dist/react/index.d.ts +3 -3
  25. package/dist/react/index.js +94 -95
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/react/index.mjs +94 -95
  28. package/dist/react/index.mjs.map +1 -1
  29. package/dist/services/index.d.mts +2 -2
  30. package/dist/services/index.d.ts +2 -2
  31. package/dist/services/index.js +72 -66
  32. package/dist/services/index.js.map +1 -1
  33. package/dist/services/index.mjs +72 -66
  34. package/dist/services/index.mjs.map +1 -1
  35. package/dist/storage/index.js +5 -2
  36. package/dist/storage/index.js.map +1 -1
  37. package/dist/storage/index.mjs +5 -2
  38. package/dist/storage/index.mjs.map +1 -1
  39. package/dist/wallet/index.d.mts +3 -3
  40. package/dist/wallet/index.d.ts +3 -3
  41. package/dist/wallet/index.js +103 -125
  42. package/dist/wallet/index.js.map +1 -1
  43. package/dist/wallet/index.mjs +103 -125
  44. package/dist/wallet/index.mjs.map +1 -1
  45. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-Lr_WS6iR.mjs';
2
- import { N as NFTCurrency } from '../index-CTyZlHKg.mjs';
1
+ export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-CF_C3Kqm.mjs';
2
+ import { N as NFTCurrency } from '../index-c90msmwW.mjs';
3
3
 
4
4
  /**
5
5
  * Zubari API Client
@@ -1,5 +1,5 @@
1
- export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-BtWUjKt_.js';
2
- import { N as NFTCurrency } from '../index-CTyZlHKg.js';
1
+ export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-BEkgF1T6.js';
2
+ import { N as NFTCurrency } from '../index-c90msmwW.js';
3
3
 
4
4
  /**
5
5
  * Zubari API Client
@@ -220,9 +220,28 @@ var WdkApiClient = class {
220
220
  constructor(config) {
221
221
  this.config = {
222
222
  baseUrl: config.baseUrl,
223
- timeout: config.timeout || 3e4
223
+ timeout: config.timeout || 3e4,
224
+ authToken: config.authToken
224
225
  };
225
226
  }
227
+ /**
228
+ * Set or update the auth token for authenticated requests
229
+ */
230
+ setAuthToken(token) {
231
+ this.config.authToken = token;
232
+ }
233
+ /**
234
+ * Build headers for API requests, including Authorization when available
235
+ */
236
+ getHeaders() {
237
+ const headers = {
238
+ "Content-Type": "application/json"
239
+ };
240
+ if (this.config.authToken) {
241
+ headers["Authorization"] = `Bearer ${this.config.authToken}`;
242
+ }
243
+ return headers;
244
+ }
226
245
  /**
227
246
  * Generate a new BIP-39 seed phrase using Tether WDK
228
247
  */
@@ -230,9 +249,7 @@ var WdkApiClient = class {
230
249
  try {
231
250
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/generate-seed`, {
232
251
  method: "POST",
233
- headers: {
234
- "Content-Type": "application/json"
235
- }
252
+ headers: this.getHeaders()
236
253
  });
237
254
  return await response.json();
238
255
  } catch (error) {
@@ -249,9 +266,7 @@ var WdkApiClient = class {
249
266
  try {
250
267
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/validate-seed`, {
251
268
  method: "POST",
252
- headers: {
253
- "Content-Type": "application/json"
254
- },
269
+ headers: this.getHeaders(),
255
270
  body: JSON.stringify({ seed })
256
271
  });
257
272
  return await response.json();
@@ -269,9 +284,7 @@ var WdkApiClient = class {
269
284
  try {
270
285
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/derive-address`, {
271
286
  method: "POST",
272
- headers: {
273
- "Content-Type": "application/json"
274
- },
287
+ headers: this.getHeaders(),
275
288
  body: JSON.stringify({ seed, chain, network })
276
289
  });
277
290
  return await response.json();
@@ -289,9 +302,7 @@ var WdkApiClient = class {
289
302
  try {
290
303
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/derive-all`, {
291
304
  method: "POST",
292
- headers: {
293
- "Content-Type": "application/json"
294
- },
305
+ headers: this.getHeaders(),
295
306
  body: JSON.stringify({ seed, network })
296
307
  });
297
308
  return await response.json();
@@ -309,9 +320,7 @@ var WdkApiClient = class {
309
320
  try {
310
321
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/send`, {
311
322
  method: "POST",
312
- headers: {
313
- "Content-Type": "application/json"
314
- },
323
+ headers: this.getHeaders(),
315
324
  body: JSON.stringify({ seed, chain, to, amount, network })
316
325
  });
317
326
  return await response.json();
@@ -330,9 +339,7 @@ var WdkApiClient = class {
330
339
  try {
331
340
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/history`, {
332
341
  method: "POST",
333
- headers: {
334
- "Content-Type": "application/json"
335
- },
342
+ headers: this.getHeaders(),
336
343
  body: JSON.stringify({ seed, chain, network, limit })
337
344
  });
338
345
  return await response.json();
@@ -351,9 +358,7 @@ var WdkApiClient = class {
351
358
  try {
352
359
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/tx-status`, {
353
360
  method: "POST",
354
- headers: {
355
- "Content-Type": "application/json"
356
- },
361
+ headers: this.getHeaders(),
357
362
  body: JSON.stringify({ txHash, chain, network })
358
363
  });
359
364
  return await response.json();
@@ -367,11 +372,14 @@ var WdkApiClient = class {
367
372
  };
368
373
  var DEFAULT_API_URL = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
369
374
  var wdkApiClient = null;
370
- function getWdkApiClient(baseUrl) {
375
+ function getWdkApiClient(baseUrl, authToken) {
371
376
  if (!wdkApiClient || baseUrl && wdkApiClient["config"].baseUrl !== baseUrl) {
372
377
  wdkApiClient = new WdkApiClient({
373
- baseUrl: baseUrl || DEFAULT_API_URL
378
+ baseUrl: baseUrl || DEFAULT_API_URL,
379
+ authToken
374
380
  });
381
+ } else if (authToken !== void 0) {
382
+ wdkApiClient.setAuthToken(authToken);
375
383
  }
376
384
  return wdkApiClient;
377
385
  }
@@ -1074,24 +1082,36 @@ __export(BrowserAddressDerivation_exports, {
1074
1082
  generateSeedPhrase: () => generateSeedPhrase,
1075
1083
  isValidSeed: () => isValidSeed
1076
1084
  });
1085
+
1086
+ // src/config/networks.ts
1077
1087
  var DERIVATION_PATHS = {
1078
- ethereum: "m/44'/60'/0'/0/0",
1079
- bitcoin_mainnet: "m/84'/0'/0'/0/0",
1088
+ bitcoin: "m/84'/0'/0'/0",
1089
+ ethereum: "m/44'/60'/0'/0",
1090
+ ton: "m/44'/607'/0'",
1091
+ tron: "m/44'/195'/0'/0",
1092
+ solana: "m/44'/501'/0'",
1093
+ spark: "m/44'/998'/0'/0"
1094
+ };
1095
+
1096
+ // src/services/BrowserAddressDerivation.ts
1097
+ var DERIVATION_PATHS2 = {
1098
+ ethereum: `${DERIVATION_PATHS.ethereum}/0`,
1099
+ bitcoin_mainnet: `${DERIVATION_PATHS.bitcoin}/0`,
1080
1100
  bitcoin_testnet: "m/84'/1'/0'/0/0",
1081
- ton: "m/44'/607'/0'/0'/0'",
1082
- tron: "m/44'/195'/0'/0/0",
1083
- solana: "m/44'/501'/0'/0'",
1084
- spark: "m/44'/998'/0'/0/0"
1101
+ ton: `${DERIVATION_PATHS.ton}/0'/0'`,
1102
+ tron: `${DERIVATION_PATHS.tron}/0`,
1103
+ solana: `${DERIVATION_PATHS.solana}/0'`,
1104
+ spark: `${DERIVATION_PATHS.spark}/0`
1085
1105
  };
1086
1106
  function deriveEthereumAddress(seed) {
1087
- const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS.ethereum);
1107
+ const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
1088
1108
  return hdNode.address;
1089
1109
  }
1090
1110
  function deriveBitcoinAddress(seed, network = "mainnet") {
1091
1111
  try {
1092
1112
  const seedBytes = bip39.mnemonicToSeedSync(seed);
1093
1113
  const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
1094
- const path = network === "testnet" ? DERIVATION_PATHS.bitcoin_testnet : DERIVATION_PATHS.bitcoin_mainnet;
1114
+ const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
1095
1115
  const child = hdKey.derive(path);
1096
1116
  if (!child.publicKey) {
1097
1117
  throw new Error("Failed to derive public key");
@@ -1117,7 +1137,7 @@ async function deriveSolanaAddress(seed) {
1117
1137
  ]);
1118
1138
  const bs58 = bs58Module.default || bs58Module;
1119
1139
  const seedBytes = bip39.mnemonicToSeedSync(seed);
1120
- const derived = ed25519.derivePath(DERIVATION_PATHS.solana, Buffer.from(seedBytes).toString("hex"));
1140
+ const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
1121
1141
  const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
1122
1142
  return bs58.encode(keypair.publicKey);
1123
1143
  } catch (error) {
@@ -1132,7 +1152,7 @@ async function deriveTonAddress(seed) {
1132
1152
  import('tweetnacl')
1133
1153
  ]);
1134
1154
  const seedBytes = bip39.mnemonicToSeedSync(seed);
1135
- const derived = ed25519.derivePath(DERIVATION_PATHS.ton, Buffer.from(seedBytes).toString("hex"));
1155
+ const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
1136
1156
  const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
1137
1157
  const publicKey = keypair.publicKey;
1138
1158
  const workchain = 0;
@@ -1167,7 +1187,7 @@ function crc16(data) {
1167
1187
  }
1168
1188
  function deriveTronAddress(seed) {
1169
1189
  try {
1170
- const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS.tron);
1190
+ const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
1171
1191
  const ethAddressHex = hdNode.address.slice(2).toLowerCase();
1172
1192
  const addressBytes = new Uint8Array(21);
1173
1193
  addressBytes[0] = 65;
@@ -1185,7 +1205,7 @@ function deriveSparkAddress(seed, network = "mainnet") {
1185
1205
  try {
1186
1206
  const seedBytes = bip39.mnemonicToSeedSync(seed);
1187
1207
  const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
1188
- const child = hdKey.derive(DERIVATION_PATHS.spark);
1208
+ const child = hdKey.derive(DERIVATION_PATHS2.spark);
1189
1209
  if (!child.publicKey) {
1190
1210
  throw new Error("Failed to derive public key");
1191
1211
  }
@@ -1594,11 +1614,6 @@ var ZubariWdkService = class {
1594
1614
  async sendTransaction(seed, chain, to, amount) {
1595
1615
  await this.initialize();
1596
1616
  const startTime = Date.now();
1597
- console.log(`[ZubariWdkService] Sending ${chain} transaction`, {
1598
- to: `${to.slice(0, 10)}...${to.slice(-6)}`,
1599
- amount,
1600
- network: this.config.network
1601
- });
1602
1617
  try {
1603
1618
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
1604
1619
  method: "POST",
@@ -1618,10 +1633,6 @@ var ZubariWdkService = class {
1618
1633
  console.warn(`[ZubariWdkService] Invalid ${chain} tx hash format:`, txHash);
1619
1634
  }
1620
1635
  }
1621
- console.log(`[ZubariWdkService] ${chain} transaction ${data.success ? "SUCCESS" : "FAILED"}`, {
1622
- txHash: txHash ? `${txHash.slice(0, 16)}...` : "N/A",
1623
- elapsed: `${elapsed}ms`
1624
- });
1625
1636
  if (!data.success) {
1626
1637
  const errorCode2 = parseChainError(chain, data.error || "");
1627
1638
  return {
@@ -1644,12 +1655,6 @@ var ZubariWdkService = class {
1644
1655
  const errorData = await response.json().catch(() => ({}));
1645
1656
  const errorMessage = errorData.error || `HTTP ${response.status}`;
1646
1657
  const errorCode = parseChainError(chain, errorMessage);
1647
- console.error(`[ZubariWdkService] ${chain} transaction FAILED`, {
1648
- status: response.status,
1649
- error: errorMessage,
1650
- errorCode,
1651
- elapsed: `${elapsed}ms`
1652
- });
1653
1658
  return {
1654
1659
  success: false,
1655
1660
  error: errorMessage,
@@ -1657,14 +1662,8 @@ var ZubariWdkService = class {
1657
1662
  chain
1658
1663
  };
1659
1664
  } catch (error) {
1660
- const elapsed = Date.now() - startTime;
1661
1665
  const errorMessage = error instanceof Error ? error.message : "Transaction failed";
1662
1666
  const errorCode = parseChainError(chain, errorMessage);
1663
- console.error(`[ZubariWdkService] ${chain} transaction ERROR`, {
1664
- error: errorMessage,
1665
- errorCode,
1666
- elapsed: `${elapsed}ms`
1667
- });
1668
1667
  return {
1669
1668
  success: false,
1670
1669
  error: errorMessage,
@@ -1710,15 +1709,22 @@ var ZubariWdkService = class {
1710
1709
  // Private Helper Methods
1711
1710
  // ==========================================
1712
1711
  getDerivationPath(chain) {
1713
- const paths = {
1714
- bitcoin: this.config.network === "testnet" ? "m/84'/1'/0'/0/0" : "m/84'/0'/0'/0/0",
1715
- ethereum: "m/44'/60'/0'/0/0",
1716
- ton: "m/44'/607'/0'/0'/0'",
1717
- tron: "m/44'/195'/0'/0/0",
1718
- solana: "m/44'/501'/0'/0'",
1719
- spark: "m/44'/998'/0'/0/0"
1720
- };
1721
- return paths[chain];
1712
+ const basePath = DERIVATION_PATHS[chain];
1713
+ if (chain === "bitcoin" && this.config.network === "testnet") {
1714
+ return "m/84'/1'/0'/0/0";
1715
+ }
1716
+ switch (chain) {
1717
+ case "ton":
1718
+ return `${basePath}/0'/0'`;
1719
+ case "solana":
1720
+ return `${basePath}/0'`;
1721
+ case "bitcoin":
1722
+ case "ethereum":
1723
+ case "tron":
1724
+ case "spark":
1725
+ default:
1726
+ return `${basePath}/0`;
1727
+ }
1722
1728
  }
1723
1729
  getChainSymbol(chain) {
1724
1730
  const symbols = {