@zubari/sdk 0.1.21 → 0.1.22

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 +22 -57
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +16 -51
  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 +15 -54
  24. package/dist/react/index.js.map +1 -1
  25. package/dist/react/index.mjs +9 -48
  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 +16 -12
  30. package/dist/services/index.js.map +1 -1
  31. package/dist/services/index.mjs +10 -6
  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 +22 -57
  36. package/dist/wallet/index.js.map +1 -1
  37. package/dist/wallet/index.mjs +16 -51
  38. package/dist/wallet/index.mjs.map +1 -1
  39. package/package.json +4 -4
@@ -4,11 +4,11 @@ var ethers = require('ethers');
4
4
  var viem = require('viem');
5
5
  var chains = require('viem/chains');
6
6
  var bip39 = require('@scure/bip39');
7
- var english = require('@scure/bip39/wordlists/english');
7
+ var english_js = require('@scure/bip39/wordlists/english.js');
8
8
  var bip32 = require('@scure/bip32');
9
9
  var base = require('@scure/base');
10
- var sha256 = require('@noble/hashes/sha256');
11
- var ripemd160 = require('@noble/hashes/ripemd160');
10
+ var sha2_js = require('@noble/hashes/sha2.js');
11
+ var legacy_js = require('@noble/hashes/legacy.js');
12
12
 
13
13
  // src/config/networks.ts
14
14
  var NETWORKS = {
@@ -138,16 +138,18 @@ var ZUBARI_CONTRACTS = {
138
138
  // Ethereum Sepolia (11155111) - Deployed 2024-12-09
139
139
  registry: "0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3",
140
140
  nft: "0xdc37e25650D685e4c38124aC314477Ea5f508a9e",
141
- marketplace: ZERO_ADDRESS,
142
- // Not yet deployed
141
+ marketplace: "0x48D0F3b6552A8CcDA7528db5aE8be004fCC3D3D9",
142
+ // ZubariMarket deployed 2024-12-22
143
143
  tips: "0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85",
144
144
  subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
145
145
  payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
146
146
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
147
147
  paymaster: ZERO_ADDRESS,
148
- // Not yet deployed
148
+ // Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
149
149
  accountFactory: ZERO_ADDRESS,
150
150
  // Not yet deployed
151
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
152
+ // USDC on Sepolia
151
153
  usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
152
154
  // USDT on Sepolia
153
155
  weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
@@ -163,6 +165,8 @@ var ZUBARI_CONTRACTS = {
163
165
  entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
164
166
  paymaster: ZERO_ADDRESS,
165
167
  accountFactory: ZERO_ADDRESS,
168
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
169
+ // USDC on Ethereum
166
170
  usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
167
171
  // USDT on Ethereum
168
172
  weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
@@ -845,7 +849,7 @@ function deriveBitcoinAddress(seed, network = "testnet") {
845
849
  if (!child.publicKey) {
846
850
  throw new Error("Failed to derive public key");
847
851
  }
848
- const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
852
+ const pubKeyHash = legacy_js.ripemd160(sha2_js.sha256(child.publicKey));
849
853
  const witnessVersion = 0;
850
854
  const words = base.bech32.toWords(pubKeyHash);
851
855
  words.unshift(witnessVersion);
@@ -886,7 +890,7 @@ async function deriveTonAddress(seed) {
886
890
  const publicKey = keypair.publicKey;
887
891
  const workchain = 0;
888
892
  const flags = 17;
889
- const hash = sha256.sha256(publicKey);
893
+ const hash = sha2_js.sha256(publicKey);
890
894
  const addressData = new Uint8Array(34);
891
895
  addressData[0] = flags;
892
896
  addressData[1] = workchain;
@@ -923,7 +927,7 @@ function deriveTronAddress(seed) {
923
927
  for (let i = 0; i < 20; i++) {
924
928
  addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
925
929
  }
926
- const tronBase58check = base.base58check(sha256.sha256);
930
+ const tronBase58check = base.base58check(sha2_js.sha256);
927
931
  return tronBase58check.encode(addressBytes);
928
932
  } catch (error) {
929
933
  console.error("TRON address derivation failed:", error);
@@ -938,7 +942,7 @@ function deriveSparkAddress(seed, network = "testnet") {
938
942
  if (!child.publicKey) {
939
943
  throw new Error("Failed to derive public key");
940
944
  }
941
- const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
945
+ const pubKeyHash = legacy_js.ripemd160(sha2_js.sha256(child.publicKey));
942
946
  const witnessVersion = 0;
943
947
  const words = base.bech32.toWords(pubKeyHash);
944
948
  words.unshift(witnessVersion);
@@ -996,10 +1000,10 @@ async function deriveAllAddresses(seed, network = "testnet") {
996
1000
  return addresses;
997
1001
  }
998
1002
  function isValidSeed(seed) {
999
- return bip39.validateMnemonic(seed, english.wordlist);
1003
+ return bip39.validateMnemonic(seed, english_js.wordlist);
1000
1004
  }
1001
1005
  function generateSeedPhrase() {
1002
- return bip39.generateMnemonic(english.wordlist);
1006
+ return bip39.generateMnemonic(english_js.wordlist);
1003
1007
  }
1004
1008
 
1005
1009
  // src/services/ZubariWdkService.ts
@@ -1762,33 +1766,6 @@ var WalletManager = class _WalletManager {
1762
1766
  console.warn("Failed to save addresses to storage:", error);
1763
1767
  }
1764
1768
  }
1765
- /**
1766
- * Normalize an address value - extract string from object format if needed
1767
- * Handles both string addresses and object format {chain, address, path}
1768
- */
1769
- normalizeAddress(value) {
1770
- if (typeof value === "string") {
1771
- return value;
1772
- }
1773
- if (value && typeof value === "object" && "address" in value) {
1774
- const addr = value.address;
1775
- return typeof addr === "string" ? addr : null;
1776
- }
1777
- return null;
1778
- }
1779
- /**
1780
- * Normalize all addresses in an object - extract strings from object format
1781
- */
1782
- normalizeAddresses(addresses) {
1783
- const normalized = {};
1784
- for (const [chain, value] of Object.entries(addresses)) {
1785
- const addr = this.normalizeAddress(value);
1786
- if (addr) {
1787
- normalized[chain] = addr;
1788
- }
1789
- }
1790
- return normalized;
1791
- }
1792
1769
  /**
1793
1770
  * Load derived addresses from storage
1794
1771
  */
@@ -1796,11 +1773,8 @@ var WalletManager = class _WalletManager {
1796
1773
  try {
1797
1774
  const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
1798
1775
  if (stored) {
1799
- const rawAddresses = JSON.parse(stored);
1800
- console.log("[WalletManager] Raw addresses from storage:", rawAddresses);
1801
- const addresses = this.normalizeAddresses(rawAddresses);
1802
- console.log("[WalletManager] Normalized addresses:", addresses);
1803
- await this.saveAddressesToStorage(addresses);
1776
+ const addresses = JSON.parse(stored);
1777
+ console.log("Loaded derived addresses from storage:", Object.keys(addresses));
1804
1778
  return addresses;
1805
1779
  }
1806
1780
  } catch (error) {
@@ -1838,15 +1812,8 @@ var WalletManager = class _WalletManager {
1838
1812
  * Returns cached address or null - use deriveAllAddressesAsync to derive addresses
1839
1813
  */
1840
1814
  getAddressForChain(chain) {
1841
- const cachedValue = this.derivedAddresses[chain];
1842
- if (cachedValue) {
1843
- console.log(`[WalletManager] getAddressForChain(${chain}) cached value:`, cachedValue, "type:", typeof cachedValue);
1844
- const addr = this.normalizeAddress(cachedValue);
1845
- console.log(`[WalletManager] getAddressForChain(${chain}) normalized:`, addr);
1846
- if (addr) {
1847
- this.derivedAddresses[chain] = addr;
1848
- return addr;
1849
- }
1815
+ if (this.derivedAddresses[chain]) {
1816
+ return this.derivedAddresses[chain];
1850
1817
  }
1851
1818
  if (chain === "ethereum" && this.currentSeed) {
1852
1819
  this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
@@ -1858,7 +1825,7 @@ var WalletManager = class _WalletManager {
1858
1825
  * Get all derived addresses
1859
1826
  */
1860
1827
  getAllAddresses() {
1861
- return this.normalizeAddresses(this.derivedAddresses);
1828
+ return { ...this.derivedAddresses };
1862
1829
  }
1863
1830
  /**
1864
1831
  * Set the selected chain
@@ -1900,7 +1867,6 @@ var WalletManager = class _WalletManager {
1900
1867
  let balance = "0";
1901
1868
  if (chain === "ethereum") {
1902
1869
  const viemChain = this.config.network === "mainnet" ? chains.mainnet : chains.sepolia;
1903
- console.log(`[WalletManager] Fetching ${chain} balance for ${address} using RPC: ${this.config.rpcUrl}`);
1904
1870
  const client = viem.createPublicClient({
1905
1871
  chain: viemChain,
1906
1872
  transport: viem.http(this.config.rpcUrl, {
@@ -1915,9 +1881,8 @@ var WalletManager = class _WalletManager {
1915
1881
  address
1916
1882
  });
1917
1883
  balance = viem.formatEther(rawBalance);
1918
- console.log(`[WalletManager] ${chain} balance fetched: ${balance} (raw: ${rawBalance})`);
1919
1884
  } catch (error) {
1920
- console.error(`[WalletManager] Failed to fetch ${chain} balance from ${this.config.rpcUrl}:`, error);
1885
+ console.warn(`Failed to fetch ${chain} balance:`, error);
1921
1886
  }
1922
1887
  } else if (chain === "bitcoin") {
1923
1888
  const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");