@zubari/sdk 0.1.21 → 0.1.23

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 (39) hide show
  1. package/dist/PayoutsProtocol-BFrXok86.d.ts +181 -0
  2. package/dist/PayoutsProtocol-Q3wZHcaf.d.mts +181 -0
  3. package/dist/{WalletManager-wRV8RrnE.d.ts → WalletManager-9bC646Ax.d.ts} +49 -141
  4. package/dist/{WalletManager-bdFpa_yr.d.mts → WalletManager-B4Ag188W.d.mts} +49 -141
  5. package/dist/{index-C4wdFOtM.d.mts → index-C4SuAZP4.d.ts} +3 -2
  6. package/dist/{index-DhluuR9H.d.mts → index-D9vwxETQ.d.mts} +17 -1
  7. package/dist/{index-DhluuR9H.d.ts → index-D9vwxETQ.d.ts} +17 -1
  8. package/dist/{index-Cq024jR8.d.ts → index-DkB0ouBN.d.mts} +3 -2
  9. package/dist/index.d.mts +5 -6
  10. package/dist/index.d.ts +5 -6
  11. package/dist/index.js +36 -63
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +30 -57
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/protocols/index.d.mts +149 -171
  16. package/dist/protocols/index.d.ts +149 -171
  17. package/dist/protocols/index.js +889 -0
  18. package/dist/protocols/index.js.map +1 -1
  19. package/dist/protocols/index.mjs +889 -1
  20. package/dist/protocols/index.mjs.map +1 -1
  21. package/dist/react/index.d.mts +4 -5
  22. package/dist/react/index.d.ts +4 -5
  23. package/dist/react/index.js +29 -60
  24. package/dist/react/index.js.map +1 -1
  25. package/dist/react/index.mjs +23 -54
  26. package/dist/react/index.mjs.map +1 -1
  27. package/dist/services/index.d.mts +1 -1
  28. package/dist/services/index.d.ts +1 -1
  29. package/dist/services/index.js +30 -18
  30. package/dist/services/index.js.map +1 -1
  31. package/dist/services/index.mjs +24 -12
  32. package/dist/services/index.mjs.map +1 -1
  33. package/dist/wallet/index.d.mts +4 -5
  34. package/dist/wallet/index.d.ts +4 -5
  35. package/dist/wallet/index.js +36 -63
  36. package/dist/wallet/index.js.map +1 -1
  37. package/dist/wallet/index.mjs +30 -57
  38. package/dist/wallet/index.mjs.map +1 -1
  39. package/package.json +17 -19
package/dist/index.mjs CHANGED
@@ -2,11 +2,11 @@ import { HDNodeWallet, Wallet } from 'ethers';
2
2
  import { createPublicClient, http, formatEther } from 'viem';
3
3
  import { mainnet, sepolia } from 'viem/chains';
4
4
  import { mnemonicToSeedSync, validateMnemonic, generateMnemonic } from '@scure/bip39';
5
- import { wordlist } from '@scure/bip39/wordlists/english';
5
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
6
6
  import { HDKey } from '@scure/bip32';
7
7
  import { bech32, base58check } from '@scure/base';
8
- import { sha256 } from '@noble/hashes/sha256';
9
- import { ripemd160 } from '@noble/hashes/ripemd160';
8
+ import { sha256 } from '@noble/hashes/sha2.js';
9
+ import { ripemd160 } from '@noble/hashes/legacy.js';
10
10
  import { useMemo, useState, useCallback, useEffect } from 'react';
11
11
 
12
12
  var __defProp = Object.defineProperty;
@@ -143,16 +143,18 @@ var ZUBARI_CONTRACTS = {
143
143
  // Ethereum Sepolia (11155111) - Deployed 2024-12-09
144
144
  registry: "0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3",
145
145
  nft: "0xdc37e25650D685e4c38124aC314477Ea5f508a9e",
146
- marketplace: ZERO_ADDRESS,
147
- // Not yet deployed
146
+ marketplace: "0x48D0F3b6552A8CcDA7528db5aE8be004fCC3D3D9",
147
+ // ZubariMarket deployed 2024-12-22
148
148
  tips: "0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85",
149
149
  subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
150
150
  payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
151
151
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
152
152
  paymaster: ZERO_ADDRESS,
153
- // Not yet deployed
153
+ // Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
154
154
  accountFactory: ZERO_ADDRESS,
155
155
  // Not yet deployed
156
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
157
+ // USDC on Sepolia
156
158
  usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
157
159
  // USDT on Sepolia
158
160
  weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
@@ -168,6 +170,8 @@ var ZUBARI_CONTRACTS = {
168
170
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
169
171
  paymaster: ZERO_ADDRESS,
170
172
  accountFactory: ZERO_ADDRESS,
173
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
174
+ // USDC on Ethereum
171
175
  usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
172
176
  // USDT on Ethereum
173
177
  weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
@@ -1214,13 +1218,21 @@ var ZubariWdkService = class {
1214
1218
  try {
1215
1219
  const response = await this.apiClient.deriveAllAddresses(seed, this.config.network);
1216
1220
  if (response.success && response.addresses) {
1221
+ const extractAddress = (value) => {
1222
+ if (!value) return null;
1223
+ if (typeof value === "string") return value;
1224
+ if (typeof value === "object" && value !== null && "address" in value) {
1225
+ return value.address;
1226
+ }
1227
+ return null;
1228
+ };
1217
1229
  return {
1218
- ethereum: response.addresses.ethereum || null,
1219
- bitcoin: response.addresses.bitcoin || null,
1220
- ton: response.addresses.ton || null,
1221
- tron: response.addresses.tron || null,
1222
- solana: response.addresses.solana || null,
1223
- spark: response.addresses.spark || null
1230
+ ethereum: extractAddress(response.addresses.ethereum),
1231
+ bitcoin: extractAddress(response.addresses.bitcoin),
1232
+ ton: extractAddress(response.addresses.ton),
1233
+ tron: extractAddress(response.addresses.tron),
1234
+ solana: extractAddress(response.addresses.solana),
1235
+ spark: extractAddress(response.addresses.spark)
1224
1236
  };
1225
1237
  }
1226
1238
  } catch (error) {
@@ -1809,33 +1821,6 @@ var WalletManager = class _WalletManager {
1809
1821
  console.warn("Failed to save addresses to storage:", error);
1810
1822
  }
1811
1823
  }
1812
- /**
1813
- * Normalize an address value - extract string from object format if needed
1814
- * Handles both string addresses and object format {chain, address, path}
1815
- */
1816
- normalizeAddress(value) {
1817
- if (typeof value === "string") {
1818
- return value;
1819
- }
1820
- if (value && typeof value === "object" && "address" in value) {
1821
- const addr = value.address;
1822
- return typeof addr === "string" ? addr : null;
1823
- }
1824
- return null;
1825
- }
1826
- /**
1827
- * Normalize all addresses in an object - extract strings from object format
1828
- */
1829
- normalizeAddresses(addresses) {
1830
- const normalized = {};
1831
- for (const [chain, value] of Object.entries(addresses)) {
1832
- const addr = this.normalizeAddress(value);
1833
- if (addr) {
1834
- normalized[chain] = addr;
1835
- }
1836
- }
1837
- return normalized;
1838
- }
1839
1824
  /**
1840
1825
  * Load derived addresses from storage
1841
1826
  */
@@ -1843,11 +1828,8 @@ var WalletManager = class _WalletManager {
1843
1828
  try {
1844
1829
  const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
1845
1830
  if (stored) {
1846
- const rawAddresses = JSON.parse(stored);
1847
- console.log("[WalletManager] Raw addresses from storage:", rawAddresses);
1848
- const addresses = this.normalizeAddresses(rawAddresses);
1849
- console.log("[WalletManager] Normalized addresses:", addresses);
1850
- await this.saveAddressesToStorage(addresses);
1831
+ const addresses = JSON.parse(stored);
1832
+ console.log("Loaded derived addresses from storage:", Object.keys(addresses));
1851
1833
  return addresses;
1852
1834
  }
1853
1835
  } catch (error) {
@@ -1885,15 +1867,8 @@ var WalletManager = class _WalletManager {
1885
1867
  * Returns cached address or null - use deriveAllAddressesAsync to derive addresses
1886
1868
  */
1887
1869
  getAddressForChain(chain) {
1888
- const cachedValue = this.derivedAddresses[chain];
1889
- if (cachedValue) {
1890
- console.log(`[WalletManager] getAddressForChain(${chain}) cached value:`, cachedValue, "type:", typeof cachedValue);
1891
- const addr = this.normalizeAddress(cachedValue);
1892
- console.log(`[WalletManager] getAddressForChain(${chain}) normalized:`, addr);
1893
- if (addr) {
1894
- this.derivedAddresses[chain] = addr;
1895
- return addr;
1896
- }
1870
+ if (this.derivedAddresses[chain]) {
1871
+ return this.derivedAddresses[chain];
1897
1872
  }
1898
1873
  if (chain === "ethereum" && this.currentSeed) {
1899
1874
  this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
@@ -1905,7 +1880,7 @@ var WalletManager = class _WalletManager {
1905
1880
  * Get all derived addresses
1906
1881
  */
1907
1882
  getAllAddresses() {
1908
- return this.normalizeAddresses(this.derivedAddresses);
1883
+ return { ...this.derivedAddresses };
1909
1884
  }
1910
1885
  /**
1911
1886
  * Set the selected chain
@@ -1947,7 +1922,6 @@ var WalletManager = class _WalletManager {
1947
1922
  let balance = "0";
1948
1923
  if (chain === "ethereum") {
1949
1924
  const viemChain = this.config.network === "mainnet" ? mainnet : sepolia;
1950
- console.log(`[WalletManager] Fetching ${chain} balance for ${address} using RPC: ${this.config.rpcUrl}`);
1951
1925
  const client = createPublicClient({
1952
1926
  chain: viemChain,
1953
1927
  transport: http(this.config.rpcUrl, {
@@ -1962,9 +1936,8 @@ var WalletManager = class _WalletManager {
1962
1936
  address
1963
1937
  });
1964
1938
  balance = formatEther(rawBalance);
1965
- console.log(`[WalletManager] ${chain} balance fetched: ${balance} (raw: ${rawBalance})`);
1966
1939
  } catch (error) {
1967
- console.error(`[WalletManager] Failed to fetch ${chain} balance from ${this.config.rpcUrl}:`, error);
1940
+ console.warn(`Failed to fetch ${chain} balance:`, error);
1968
1941
  }
1969
1942
  } else if (chain === "bitcoin") {
1970
1943
  const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");