@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.
- package/dist/PayoutsProtocol-BFrXok86.d.ts +181 -0
- package/dist/PayoutsProtocol-Q3wZHcaf.d.mts +181 -0
- package/dist/{WalletManager-wRV8RrnE.d.ts → WalletManager-9bC646Ax.d.ts} +49 -141
- package/dist/{WalletManager-bdFpa_yr.d.mts → WalletManager-B4Ag188W.d.mts} +49 -141
- package/dist/{index-C4wdFOtM.d.mts → index-C4SuAZP4.d.ts} +3 -2
- package/dist/{index-DhluuR9H.d.mts → index-D9vwxETQ.d.mts} +17 -1
- package/dist/{index-DhluuR9H.d.ts → index-D9vwxETQ.d.ts} +17 -1
- package/dist/{index-Cq024jR8.d.ts → index-DkB0ouBN.d.mts} +3 -2
- package/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +36 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -57
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.d.mts +149 -171
- package/dist/protocols/index.d.ts +149 -171
- package/dist/protocols/index.js +889 -0
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs +889 -1
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -5
- package/dist/react/index.d.ts +4 -5
- package/dist/react/index.js +29 -60
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +23 -54
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +30 -18
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +24 -12
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +4 -5
- package/dist/wallet/index.d.ts +4 -5
- package/dist/wallet/index.js +36 -63
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +30 -57
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +17 -19
package/dist/wallet/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { Wallet, HDNodeWallet } from 'ethers';
|
|
|
2
2
|
import { createPublicClient, http, formatEther } from 'viem';
|
|
3
3
|
import { mainnet, sepolia } from 'viem/chains';
|
|
4
4
|
import { generateMnemonic, validateMnemonic, mnemonicToSeedSync } 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/
|
|
9
|
-
import { ripemd160 } from '@noble/hashes/
|
|
8
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
9
|
+
import { ripemd160 } from '@noble/hashes/legacy.js';
|
|
10
10
|
|
|
11
11
|
// src/config/networks.ts
|
|
12
12
|
var NETWORKS = {
|
|
@@ -136,16 +136,18 @@ var ZUBARI_CONTRACTS = {
|
|
|
136
136
|
// Ethereum Sepolia (11155111) - Deployed 2024-12-09
|
|
137
137
|
registry: "0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3",
|
|
138
138
|
nft: "0xdc37e25650D685e4c38124aC314477Ea5f508a9e",
|
|
139
|
-
marketplace:
|
|
140
|
-
//
|
|
139
|
+
marketplace: "0x48D0F3b6552A8CcDA7528db5aE8be004fCC3D3D9",
|
|
140
|
+
// ZubariMarket deployed 2024-12-22
|
|
141
141
|
tips: "0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85",
|
|
142
142
|
subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
|
|
143
143
|
payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
|
|
144
144
|
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
145
145
|
paymaster: ZERO_ADDRESS,
|
|
146
|
-
//
|
|
146
|
+
// Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
|
|
147
147
|
accountFactory: ZERO_ADDRESS,
|
|
148
148
|
// Not yet deployed
|
|
149
|
+
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
150
|
+
// USDC on Sepolia
|
|
149
151
|
usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
|
|
150
152
|
// USDT on Sepolia
|
|
151
153
|
weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
|
|
@@ -161,6 +163,8 @@ var ZUBARI_CONTRACTS = {
|
|
|
161
163
|
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
162
164
|
paymaster: ZERO_ADDRESS,
|
|
163
165
|
accountFactory: ZERO_ADDRESS,
|
|
166
|
+
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
167
|
+
// USDC on Ethereum
|
|
164
168
|
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
165
169
|
// USDT on Ethereum
|
|
166
170
|
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
@@ -1168,13 +1172,21 @@ var ZubariWdkService = class {
|
|
|
1168
1172
|
try {
|
|
1169
1173
|
const response = await this.apiClient.deriveAllAddresses(seed, this.config.network);
|
|
1170
1174
|
if (response.success && response.addresses) {
|
|
1175
|
+
const extractAddress = (value) => {
|
|
1176
|
+
if (!value) return null;
|
|
1177
|
+
if (typeof value === "string") return value;
|
|
1178
|
+
if (typeof value === "object" && value !== null && "address" in value) {
|
|
1179
|
+
return value.address;
|
|
1180
|
+
}
|
|
1181
|
+
return null;
|
|
1182
|
+
};
|
|
1171
1183
|
return {
|
|
1172
|
-
ethereum: response.addresses.ethereum
|
|
1173
|
-
bitcoin: response.addresses.bitcoin
|
|
1174
|
-
ton: response.addresses.ton
|
|
1175
|
-
tron: response.addresses.tron
|
|
1176
|
-
solana: response.addresses.solana
|
|
1177
|
-
spark: response.addresses.spark
|
|
1184
|
+
ethereum: extractAddress(response.addresses.ethereum),
|
|
1185
|
+
bitcoin: extractAddress(response.addresses.bitcoin),
|
|
1186
|
+
ton: extractAddress(response.addresses.ton),
|
|
1187
|
+
tron: extractAddress(response.addresses.tron),
|
|
1188
|
+
solana: extractAddress(response.addresses.solana),
|
|
1189
|
+
spark: extractAddress(response.addresses.spark)
|
|
1178
1190
|
};
|
|
1179
1191
|
}
|
|
1180
1192
|
} catch (error) {
|
|
@@ -1760,33 +1772,6 @@ var WalletManager = class _WalletManager {
|
|
|
1760
1772
|
console.warn("Failed to save addresses to storage:", error);
|
|
1761
1773
|
}
|
|
1762
1774
|
}
|
|
1763
|
-
/**
|
|
1764
|
-
* Normalize an address value - extract string from object format if needed
|
|
1765
|
-
* Handles both string addresses and object format {chain, address, path}
|
|
1766
|
-
*/
|
|
1767
|
-
normalizeAddress(value) {
|
|
1768
|
-
if (typeof value === "string") {
|
|
1769
|
-
return value;
|
|
1770
|
-
}
|
|
1771
|
-
if (value && typeof value === "object" && "address" in value) {
|
|
1772
|
-
const addr = value.address;
|
|
1773
|
-
return typeof addr === "string" ? addr : null;
|
|
1774
|
-
}
|
|
1775
|
-
return null;
|
|
1776
|
-
}
|
|
1777
|
-
/**
|
|
1778
|
-
* Normalize all addresses in an object - extract strings from object format
|
|
1779
|
-
*/
|
|
1780
|
-
normalizeAddresses(addresses) {
|
|
1781
|
-
const normalized = {};
|
|
1782
|
-
for (const [chain, value] of Object.entries(addresses)) {
|
|
1783
|
-
const addr = this.normalizeAddress(value);
|
|
1784
|
-
if (addr) {
|
|
1785
|
-
normalized[chain] = addr;
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
return normalized;
|
|
1789
|
-
}
|
|
1790
1775
|
/**
|
|
1791
1776
|
* Load derived addresses from storage
|
|
1792
1777
|
*/
|
|
@@ -1794,11 +1779,8 @@ var WalletManager = class _WalletManager {
|
|
|
1794
1779
|
try {
|
|
1795
1780
|
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1796
1781
|
if (stored) {
|
|
1797
|
-
const
|
|
1798
|
-
console.log("
|
|
1799
|
-
const addresses = this.normalizeAddresses(rawAddresses);
|
|
1800
|
-
console.log("[WalletManager] Normalized addresses:", addresses);
|
|
1801
|
-
await this.saveAddressesToStorage(addresses);
|
|
1782
|
+
const addresses = JSON.parse(stored);
|
|
1783
|
+
console.log("Loaded derived addresses from storage:", Object.keys(addresses));
|
|
1802
1784
|
return addresses;
|
|
1803
1785
|
}
|
|
1804
1786
|
} catch (error) {
|
|
@@ -1836,15 +1818,8 @@ var WalletManager = class _WalletManager {
|
|
|
1836
1818
|
* Returns cached address or null - use deriveAllAddressesAsync to derive addresses
|
|
1837
1819
|
*/
|
|
1838
1820
|
getAddressForChain(chain) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
console.log(`[WalletManager] getAddressForChain(${chain}) cached value:`, cachedValue, "type:", typeof cachedValue);
|
|
1842
|
-
const addr = this.normalizeAddress(cachedValue);
|
|
1843
|
-
console.log(`[WalletManager] getAddressForChain(${chain}) normalized:`, addr);
|
|
1844
|
-
if (addr) {
|
|
1845
|
-
this.derivedAddresses[chain] = addr;
|
|
1846
|
-
return addr;
|
|
1847
|
-
}
|
|
1821
|
+
if (this.derivedAddresses[chain]) {
|
|
1822
|
+
return this.derivedAddresses[chain];
|
|
1848
1823
|
}
|
|
1849
1824
|
if (chain === "ethereum" && this.currentSeed) {
|
|
1850
1825
|
this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
|
|
@@ -1856,7 +1831,7 @@ var WalletManager = class _WalletManager {
|
|
|
1856
1831
|
* Get all derived addresses
|
|
1857
1832
|
*/
|
|
1858
1833
|
getAllAddresses() {
|
|
1859
|
-
return this.
|
|
1834
|
+
return { ...this.derivedAddresses };
|
|
1860
1835
|
}
|
|
1861
1836
|
/**
|
|
1862
1837
|
* Set the selected chain
|
|
@@ -1898,7 +1873,6 @@ var WalletManager = class _WalletManager {
|
|
|
1898
1873
|
let balance = "0";
|
|
1899
1874
|
if (chain === "ethereum") {
|
|
1900
1875
|
const viemChain = this.config.network === "mainnet" ? mainnet : sepolia;
|
|
1901
|
-
console.log(`[WalletManager] Fetching ${chain} balance for ${address} using RPC: ${this.config.rpcUrl}`);
|
|
1902
1876
|
const client = createPublicClient({
|
|
1903
1877
|
chain: viemChain,
|
|
1904
1878
|
transport: http(this.config.rpcUrl, {
|
|
@@ -1913,9 +1887,8 @@ var WalletManager = class _WalletManager {
|
|
|
1913
1887
|
address
|
|
1914
1888
|
});
|
|
1915
1889
|
balance = formatEther(rawBalance);
|
|
1916
|
-
console.log(`[WalletManager] ${chain} balance fetched: ${balance} (raw: ${rawBalance})`);
|
|
1917
1890
|
} catch (error) {
|
|
1918
|
-
console.
|
|
1891
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
1919
1892
|
}
|
|
1920
1893
|
} else if (chain === "bitcoin") {
|
|
1921
1894
|
const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
|