@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZubariWalletConfig, N as NetworkType, A as Account,
|
|
2
|
-
import './WalletManager-
|
|
1
|
+
import { Z as ZubariWalletConfig, N as NetworkType, A as Account, b as NetworkBalance, S as SendParams, T as TxResult } from './index-D9vwxETQ.js';
|
|
2
|
+
import './WalletManager-9bC646Ax.js';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -11,6 +11,7 @@ interface ContractAddresses {
|
|
|
11
11
|
entryPoint: string;
|
|
12
12
|
paymaster: string;
|
|
13
13
|
accountFactory: string;
|
|
14
|
+
usdc: string;
|
|
14
15
|
usdt: string;
|
|
15
16
|
weth: string;
|
|
16
17
|
}
|
|
@@ -74,11 +74,27 @@ interface NFT {
|
|
|
74
74
|
isLazyMinted: boolean;
|
|
75
75
|
}
|
|
76
76
|
interface ListingParams {
|
|
77
|
+
nftContract: string;
|
|
77
78
|
tokenId: string;
|
|
78
79
|
price: bigint;
|
|
79
80
|
paymentToken: string;
|
|
80
81
|
duration: number;
|
|
81
82
|
}
|
|
83
|
+
interface Listing {
|
|
84
|
+
listingId: string;
|
|
85
|
+
nftContract: string;
|
|
86
|
+
tokenId: string;
|
|
87
|
+
seller: string;
|
|
88
|
+
price: bigint;
|
|
89
|
+
paymentToken: string;
|
|
90
|
+
expiresAt: number;
|
|
91
|
+
isActive: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface BuyParams {
|
|
94
|
+
listingId: string;
|
|
95
|
+
price: bigint;
|
|
96
|
+
paymentToken: string;
|
|
97
|
+
}
|
|
82
98
|
interface TipData {
|
|
83
99
|
recipient: string;
|
|
84
100
|
amount: bigint;
|
|
@@ -153,4 +169,4 @@ declare class ZubariError extends Error {
|
|
|
153
169
|
constructor(code: ZubariErrorCode, message: string, details?: unknown | undefined);
|
|
154
170
|
}
|
|
155
171
|
|
|
156
|
-
export { type Account as A, type EarningsBreakdown as E, type
|
|
172
|
+
export { type Account as A, type BuyParams as B, type EarningsBreakdown as E, type ListingParams as L, type NetworkType as N, type RevenueSplit as R, type SendParams as S, type TxResult as T, type ZubariWalletConfig as Z, type Listing as a, type NetworkBalance as b, type TokenBalance as c, type NFTMetadata as d, type LazyMintVoucher as e, type NFT as f, type TipData as g, type TipResult as h, type TipStats as i, type SubscriptionPlan as j, type Subscription as k, type SwapQuote as l, type SwapParams as m, type ZubariErrorCode as n, ZubariError as o };
|
|
@@ -74,11 +74,27 @@ interface NFT {
|
|
|
74
74
|
isLazyMinted: boolean;
|
|
75
75
|
}
|
|
76
76
|
interface ListingParams {
|
|
77
|
+
nftContract: string;
|
|
77
78
|
tokenId: string;
|
|
78
79
|
price: bigint;
|
|
79
80
|
paymentToken: string;
|
|
80
81
|
duration: number;
|
|
81
82
|
}
|
|
83
|
+
interface Listing {
|
|
84
|
+
listingId: string;
|
|
85
|
+
nftContract: string;
|
|
86
|
+
tokenId: string;
|
|
87
|
+
seller: string;
|
|
88
|
+
price: bigint;
|
|
89
|
+
paymentToken: string;
|
|
90
|
+
expiresAt: number;
|
|
91
|
+
isActive: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface BuyParams {
|
|
94
|
+
listingId: string;
|
|
95
|
+
price: bigint;
|
|
96
|
+
paymentToken: string;
|
|
97
|
+
}
|
|
82
98
|
interface TipData {
|
|
83
99
|
recipient: string;
|
|
84
100
|
amount: bigint;
|
|
@@ -153,4 +169,4 @@ declare class ZubariError extends Error {
|
|
|
153
169
|
constructor(code: ZubariErrorCode, message: string, details?: unknown | undefined);
|
|
154
170
|
}
|
|
155
171
|
|
|
156
|
-
export { type Account as A, type EarningsBreakdown as E, type
|
|
172
|
+
export { type Account as A, type BuyParams as B, type EarningsBreakdown as E, type ListingParams as L, type NetworkType as N, type RevenueSplit as R, type SendParams as S, type TxResult as T, type ZubariWalletConfig as Z, type Listing as a, type NetworkBalance as b, type TokenBalance as c, type NFTMetadata as d, type LazyMintVoucher as e, type NFT as f, type TipData as g, type TipResult as h, type TipStats as i, type SubscriptionPlan as j, type Subscription as k, type SwapQuote as l, type SwapParams as m, type ZubariErrorCode as n, ZubariError as o };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZubariWalletConfig, N as NetworkType, A as Account,
|
|
2
|
-
import './WalletManager-
|
|
1
|
+
import { Z as ZubariWalletConfig, N as NetworkType, A as Account, b as NetworkBalance, S as SendParams, T as TxResult } from './index-D9vwxETQ.mjs';
|
|
2
|
+
import './WalletManager-B4Ag188W.mjs';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -11,6 +11,7 @@ interface ContractAddresses {
|
|
|
11
11
|
entryPoint: string;
|
|
12
12
|
paymaster: string;
|
|
13
13
|
accountFactory: string;
|
|
14
|
+
usdc: string;
|
|
14
15
|
usdt: string;
|
|
15
16
|
weth: string;
|
|
16
17
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-
|
|
2
|
-
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-
|
|
1
|
+
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-DkB0ouBN.mjs';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-B4Ag188W.mjs';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
|
|
4
|
-
export { ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './
|
|
4
|
+
export { Z as ZubariNFTProtocol, c as ZubariPayoutsProtocol, b as ZubariSubscriptionProtocol, a as ZubariTipsProtocol } from './PayoutsProtocol-Q3wZHcaf.mjs';
|
|
5
|
+
export { A as Account, E as EarningsBreakdown, e as LazyMintVoucher, L as ListingParams, f as NFT, d as NFTMetadata, b as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, k as Subscription, j as SubscriptionPlan, m as SwapParams, l as SwapQuote, g as TipData, h as TipResult, i as TipStats, c as TokenBalance, T as TxResult, o as ZubariError, n as ZubariErrorCode, Z as ZubariWalletConfig } from './index-D9vwxETQ.mjs';
|
|
5
6
|
export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.mjs';
|
|
6
|
-
export { A as Account, E as EarningsBreakdown, L as LazyMintVoucher, e as ListingParams, d as NFT, c as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, j as Subscription, i as SubscriptionPlan, l as SwapParams, k as SwapQuote, f as TipData, g as TipResult, h as TipStats, T as TokenBalance, b as TxResult, n as ZubariError, m as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DhluuR9H.mjs';
|
|
7
7
|
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
|
|
8
|
-
import '
|
|
9
|
-
import 'node_modules/viem/_types/utils/ccip';
|
|
8
|
+
import 'abitype';
|
|
10
9
|
import 'viem';
|
|
11
10
|
import 'ethers';
|
|
12
11
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-
|
|
2
|
-
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-
|
|
1
|
+
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-C4SuAZP4.js';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-9bC646Ax.js';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
|
|
4
|
-
export { ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './
|
|
4
|
+
export { Z as ZubariNFTProtocol, c as ZubariPayoutsProtocol, b as ZubariSubscriptionProtocol, a as ZubariTipsProtocol } from './PayoutsProtocol-BFrXok86.js';
|
|
5
|
+
export { A as Account, E as EarningsBreakdown, e as LazyMintVoucher, L as ListingParams, f as NFT, d as NFTMetadata, b as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, k as Subscription, j as SubscriptionPlan, m as SwapParams, l as SwapQuote, g as TipData, h as TipResult, i as TipStats, c as TokenBalance, T as TxResult, o as ZubariError, n as ZubariErrorCode, Z as ZubariWalletConfig } from './index-D9vwxETQ.js';
|
|
5
6
|
export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.js';
|
|
6
|
-
export { A as Account, E as EarningsBreakdown, L as LazyMintVoucher, e as ListingParams, d as NFT, c as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, j as Subscription, i as SubscriptionPlan, l as SwapParams, k as SwapQuote, f as TipData, g as TipResult, h as TipStats, T as TokenBalance, b as TxResult, n as ZubariError, m as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DhluuR9H.js';
|
|
7
7
|
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
|
|
8
|
-
import '
|
|
9
|
-
import 'node_modules/viem/_types/utils/ccip';
|
|
8
|
+
import 'abitype';
|
|
10
9
|
import 'viem';
|
|
11
10
|
import 'ethers';
|
|
12
11
|
|
package/dist/index.js
CHANGED
|
@@ -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
|
|
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
|
|
11
|
-
var
|
|
10
|
+
var sha2_js = require('@noble/hashes/sha2.js');
|
|
11
|
+
var legacy_js = require('@noble/hashes/legacy.js');
|
|
12
12
|
var react = require('react');
|
|
13
13
|
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
@@ -145,16 +145,18 @@ var ZUBARI_CONTRACTS = {
|
|
|
145
145
|
// Ethereum Sepolia (11155111) - Deployed 2024-12-09
|
|
146
146
|
registry: "0xEdDf443D48832f23D4A0bED4C4c5eF200B38A7d3",
|
|
147
147
|
nft: "0xdc37e25650D685e4c38124aC314477Ea5f508a9e",
|
|
148
|
-
marketplace:
|
|
149
|
-
//
|
|
148
|
+
marketplace: "0x48D0F3b6552A8CcDA7528db5aE8be004fCC3D3D9",
|
|
149
|
+
// ZubariMarket deployed 2024-12-22
|
|
150
150
|
tips: "0xFDc353edC63Cd3D4bba35bB43861369516a9Dc85",
|
|
151
151
|
subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
|
|
152
152
|
payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
|
|
153
153
|
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
154
154
|
paymaster: ZERO_ADDRESS,
|
|
155
|
-
//
|
|
155
|
+
// Deploy with: npx hardhat run deploy/deploy.ts --network ethereum-sepolia
|
|
156
156
|
accountFactory: ZERO_ADDRESS,
|
|
157
157
|
// Not yet deployed
|
|
158
|
+
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
159
|
+
// USDC on Sepolia
|
|
158
160
|
usdt: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
|
|
159
161
|
// USDT on Sepolia
|
|
160
162
|
weth: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14"
|
|
@@ -170,6 +172,8 @@ var ZUBARI_CONTRACTS = {
|
|
|
170
172
|
entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
171
173
|
paymaster: ZERO_ADDRESS,
|
|
172
174
|
accountFactory: ZERO_ADDRESS,
|
|
175
|
+
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
176
|
+
// USDC on Ethereum
|
|
173
177
|
usdt: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
174
178
|
// USDT on Ethereum
|
|
175
179
|
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
@@ -891,7 +895,7 @@ function deriveBitcoinAddress(seed, network = "testnet") {
|
|
|
891
895
|
if (!child.publicKey) {
|
|
892
896
|
throw new Error("Failed to derive public key");
|
|
893
897
|
}
|
|
894
|
-
const pubKeyHash =
|
|
898
|
+
const pubKeyHash = legacy_js.ripemd160(sha2_js.sha256(child.publicKey));
|
|
895
899
|
const witnessVersion = 0;
|
|
896
900
|
const words = base.bech32.toWords(pubKeyHash);
|
|
897
901
|
words.unshift(witnessVersion);
|
|
@@ -932,7 +936,7 @@ async function deriveTonAddress(seed) {
|
|
|
932
936
|
const publicKey = keypair.publicKey;
|
|
933
937
|
const workchain = 0;
|
|
934
938
|
const flags = 17;
|
|
935
|
-
const hash =
|
|
939
|
+
const hash = sha2_js.sha256(publicKey);
|
|
936
940
|
const addressData = new Uint8Array(34);
|
|
937
941
|
addressData[0] = flags;
|
|
938
942
|
addressData[1] = workchain;
|
|
@@ -969,7 +973,7 @@ function deriveTronAddress(seed) {
|
|
|
969
973
|
for (let i = 0; i < 20; i++) {
|
|
970
974
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
971
975
|
}
|
|
972
|
-
const tronBase58check = base.base58check(
|
|
976
|
+
const tronBase58check = base.base58check(sha2_js.sha256);
|
|
973
977
|
return tronBase58check.encode(addressBytes);
|
|
974
978
|
} catch (error) {
|
|
975
979
|
console.error("TRON address derivation failed:", error);
|
|
@@ -984,7 +988,7 @@ function deriveSparkAddress(seed, network = "testnet") {
|
|
|
984
988
|
if (!child.publicKey) {
|
|
985
989
|
throw new Error("Failed to derive public key");
|
|
986
990
|
}
|
|
987
|
-
const pubKeyHash =
|
|
991
|
+
const pubKeyHash = legacy_js.ripemd160(sha2_js.sha256(child.publicKey));
|
|
988
992
|
const witnessVersion = 0;
|
|
989
993
|
const words = base.bech32.toWords(pubKeyHash);
|
|
990
994
|
words.unshift(witnessVersion);
|
|
@@ -1042,10 +1046,10 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
1042
1046
|
return addresses;
|
|
1043
1047
|
}
|
|
1044
1048
|
function isValidSeed(seed) {
|
|
1045
|
-
return bip39.validateMnemonic(seed,
|
|
1049
|
+
return bip39.validateMnemonic(seed, english_js.wordlist);
|
|
1046
1050
|
}
|
|
1047
1051
|
function generateSeedPhrase() {
|
|
1048
|
-
return bip39.generateMnemonic(
|
|
1052
|
+
return bip39.generateMnemonic(english_js.wordlist);
|
|
1049
1053
|
}
|
|
1050
1054
|
|
|
1051
1055
|
// src/services/ZubariWdkService.ts
|
|
@@ -1216,13 +1220,21 @@ var ZubariWdkService = class {
|
|
|
1216
1220
|
try {
|
|
1217
1221
|
const response = await this.apiClient.deriveAllAddresses(seed, this.config.network);
|
|
1218
1222
|
if (response.success && response.addresses) {
|
|
1223
|
+
const extractAddress = (value) => {
|
|
1224
|
+
if (!value) return null;
|
|
1225
|
+
if (typeof value === "string") return value;
|
|
1226
|
+
if (typeof value === "object" && value !== null && "address" in value) {
|
|
1227
|
+
return value.address;
|
|
1228
|
+
}
|
|
1229
|
+
return null;
|
|
1230
|
+
};
|
|
1219
1231
|
return {
|
|
1220
|
-
ethereum: response.addresses.ethereum
|
|
1221
|
-
bitcoin: response.addresses.bitcoin
|
|
1222
|
-
ton: response.addresses.ton
|
|
1223
|
-
tron: response.addresses.tron
|
|
1224
|
-
solana: response.addresses.solana
|
|
1225
|
-
spark: response.addresses.spark
|
|
1232
|
+
ethereum: extractAddress(response.addresses.ethereum),
|
|
1233
|
+
bitcoin: extractAddress(response.addresses.bitcoin),
|
|
1234
|
+
ton: extractAddress(response.addresses.ton),
|
|
1235
|
+
tron: extractAddress(response.addresses.tron),
|
|
1236
|
+
solana: extractAddress(response.addresses.solana),
|
|
1237
|
+
spark: extractAddress(response.addresses.spark)
|
|
1226
1238
|
};
|
|
1227
1239
|
}
|
|
1228
1240
|
} catch (error) {
|
|
@@ -1811,33 +1823,6 @@ var WalletManager = class _WalletManager {
|
|
|
1811
1823
|
console.warn("Failed to save addresses to storage:", error);
|
|
1812
1824
|
}
|
|
1813
1825
|
}
|
|
1814
|
-
/**
|
|
1815
|
-
* Normalize an address value - extract string from object format if needed
|
|
1816
|
-
* Handles both string addresses and object format {chain, address, path}
|
|
1817
|
-
*/
|
|
1818
|
-
normalizeAddress(value) {
|
|
1819
|
-
if (typeof value === "string") {
|
|
1820
|
-
return value;
|
|
1821
|
-
}
|
|
1822
|
-
if (value && typeof value === "object" && "address" in value) {
|
|
1823
|
-
const addr = value.address;
|
|
1824
|
-
return typeof addr === "string" ? addr : null;
|
|
1825
|
-
}
|
|
1826
|
-
return null;
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
* Normalize all addresses in an object - extract strings from object format
|
|
1830
|
-
*/
|
|
1831
|
-
normalizeAddresses(addresses) {
|
|
1832
|
-
const normalized = {};
|
|
1833
|
-
for (const [chain, value] of Object.entries(addresses)) {
|
|
1834
|
-
const addr = this.normalizeAddress(value);
|
|
1835
|
-
if (addr) {
|
|
1836
|
-
normalized[chain] = addr;
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
return normalized;
|
|
1840
|
-
}
|
|
1841
1826
|
/**
|
|
1842
1827
|
* Load derived addresses from storage
|
|
1843
1828
|
*/
|
|
@@ -1845,11 +1830,8 @@ var WalletManager = class _WalletManager {
|
|
|
1845
1830
|
try {
|
|
1846
1831
|
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1847
1832
|
if (stored) {
|
|
1848
|
-
const
|
|
1849
|
-
console.log("
|
|
1850
|
-
const addresses = this.normalizeAddresses(rawAddresses);
|
|
1851
|
-
console.log("[WalletManager] Normalized addresses:", addresses);
|
|
1852
|
-
await this.saveAddressesToStorage(addresses);
|
|
1833
|
+
const addresses = JSON.parse(stored);
|
|
1834
|
+
console.log("Loaded derived addresses from storage:", Object.keys(addresses));
|
|
1853
1835
|
return addresses;
|
|
1854
1836
|
}
|
|
1855
1837
|
} catch (error) {
|
|
@@ -1887,15 +1869,8 @@ var WalletManager = class _WalletManager {
|
|
|
1887
1869
|
* Returns cached address or null - use deriveAllAddressesAsync to derive addresses
|
|
1888
1870
|
*/
|
|
1889
1871
|
getAddressForChain(chain) {
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
console.log(`[WalletManager] getAddressForChain(${chain}) cached value:`, cachedValue, "type:", typeof cachedValue);
|
|
1893
|
-
const addr = this.normalizeAddress(cachedValue);
|
|
1894
|
-
console.log(`[WalletManager] getAddressForChain(${chain}) normalized:`, addr);
|
|
1895
|
-
if (addr) {
|
|
1896
|
-
this.derivedAddresses[chain] = addr;
|
|
1897
|
-
return addr;
|
|
1898
|
-
}
|
|
1872
|
+
if (this.derivedAddresses[chain]) {
|
|
1873
|
+
return this.derivedAddresses[chain];
|
|
1899
1874
|
}
|
|
1900
1875
|
if (chain === "ethereum" && this.currentSeed) {
|
|
1901
1876
|
this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
|
|
@@ -1907,7 +1882,7 @@ var WalletManager = class _WalletManager {
|
|
|
1907
1882
|
* Get all derived addresses
|
|
1908
1883
|
*/
|
|
1909
1884
|
getAllAddresses() {
|
|
1910
|
-
return this.
|
|
1885
|
+
return { ...this.derivedAddresses };
|
|
1911
1886
|
}
|
|
1912
1887
|
/**
|
|
1913
1888
|
* Set the selected chain
|
|
@@ -1949,7 +1924,6 @@ var WalletManager = class _WalletManager {
|
|
|
1949
1924
|
let balance = "0";
|
|
1950
1925
|
if (chain === "ethereum") {
|
|
1951
1926
|
const viemChain = this.config.network === "mainnet" ? chains.mainnet : chains.sepolia;
|
|
1952
|
-
console.log(`[WalletManager] Fetching ${chain} balance for ${address} using RPC: ${this.config.rpcUrl}`);
|
|
1953
1927
|
const client = viem.createPublicClient({
|
|
1954
1928
|
chain: viemChain,
|
|
1955
1929
|
transport: viem.http(this.config.rpcUrl, {
|
|
@@ -1964,9 +1938,8 @@ var WalletManager = class _WalletManager {
|
|
|
1964
1938
|
address
|
|
1965
1939
|
});
|
|
1966
1940
|
balance = viem.formatEther(rawBalance);
|
|
1967
|
-
console.log(`[WalletManager] ${chain} balance fetched: ${balance} (raw: ${rawBalance})`);
|
|
1968
1941
|
} catch (error) {
|
|
1969
|
-
console.
|
|
1942
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
1970
1943
|
}
|
|
1971
1944
|
} else if (chain === "bitcoin") {
|
|
1972
1945
|
const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
|