@zubari/sdk 0.1.26 → 0.1.27
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/{WalletManager-D1ohlVea.d.ts → WalletManager-CR1B7vN_.d.ts} +140 -48
- package/dist/{WalletManager-CGIuecnp.d.mts → WalletManager-Cdk81G55.d.mts} +140 -48
- package/dist/{index-CR7fLCYO.d.ts → index-BztGRtFG.d.ts} +1 -1
- package/dist/{index-Dh2ukHnr.d.mts → index-OooXWNfP.d.mts} +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +59 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -9
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +59 -15
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +53 -9
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.js +9 -9
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +3 -3
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +4 -3
- package/dist/wallet/index.d.ts +4 -3
- package/dist/wallet/index.js +59 -15
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +53 -9
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +2 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import './WalletManager-CR1B7vN_.js';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import './WalletManager-Cdk81G55.mjs';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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-OooXWNfP.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-Cdk81G55.mjs';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
|
|
4
4
|
export { Z as ZubariNFTProtocol, c as ZubariPayoutsProtocol, b as ZubariSubscriptionProtocol, a as ZubariTipsProtocol } from './PayoutsProtocol-Q3wZHcaf.mjs';
|
|
5
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';
|
|
6
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';
|
|
7
7
|
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
|
|
8
|
-
import '
|
|
8
|
+
import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
9
|
+
import 'node_modules/viem/_types/utils/ccip';
|
|
9
10
|
import 'viem';
|
|
10
11
|
import 'ethers';
|
|
11
12
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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-BztGRtFG.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-CR1B7vN_.js';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
|
|
4
4
|
export { Z as ZubariNFTProtocol, c as ZubariPayoutsProtocol, b as ZubariSubscriptionProtocol, a as ZubariTipsProtocol } from './PayoutsProtocol-BFrXok86.js';
|
|
5
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';
|
|
6
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';
|
|
7
7
|
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
|
|
8
|
-
import '
|
|
8
|
+
import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
9
|
+
import 'node_modules/viem/_types/utils/ccip';
|
|
9
10
|
import 'viem';
|
|
10
11
|
import 'ethers';
|
|
11
12
|
|
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 = require('@scure/bip39/wordlists/english');
|
|
8
8
|
var bip32 = require('@scure/bip32');
|
|
9
9
|
var base = require('@scure/base');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var sha256 = require('@noble/hashes/sha256');
|
|
11
|
+
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
12
12
|
var react = require('react');
|
|
13
13
|
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
@@ -105,6 +105,11 @@ var NETWORKS = {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
var TESTNET_NETWORKS = {
|
|
108
|
+
bitcoin: {
|
|
109
|
+
name: "Bitcoin Testnet",
|
|
110
|
+
rpcUrl: "https://blockstream.info/testnet/api",
|
|
111
|
+
explorerUrl: "https://mempool.space/testnet"
|
|
112
|
+
},
|
|
108
113
|
ethereum: {
|
|
109
114
|
name: "Sepolia",
|
|
110
115
|
chainId: 11155111,
|
|
@@ -957,7 +962,7 @@ function deriveBitcoinAddress(seed, network = "testnet") {
|
|
|
957
962
|
if (!child.publicKey) {
|
|
958
963
|
throw new Error("Failed to derive public key");
|
|
959
964
|
}
|
|
960
|
-
const pubKeyHash =
|
|
965
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
961
966
|
const witnessVersion = 0;
|
|
962
967
|
const words = base.bech32.toWords(pubKeyHash);
|
|
963
968
|
words.unshift(witnessVersion);
|
|
@@ -998,7 +1003,7 @@ async function deriveTonAddress(seed) {
|
|
|
998
1003
|
const publicKey = keypair.publicKey;
|
|
999
1004
|
const workchain = 0;
|
|
1000
1005
|
const flags = 17;
|
|
1001
|
-
const hash =
|
|
1006
|
+
const hash = sha256.sha256(publicKey);
|
|
1002
1007
|
const addressData = new Uint8Array(34);
|
|
1003
1008
|
addressData[0] = flags;
|
|
1004
1009
|
addressData[1] = workchain;
|
|
@@ -1035,7 +1040,7 @@ function deriveTronAddress(seed) {
|
|
|
1035
1040
|
for (let i = 0; i < 20; i++) {
|
|
1036
1041
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
1037
1042
|
}
|
|
1038
|
-
const tronBase58check = base.base58check(
|
|
1043
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
1039
1044
|
return tronBase58check.encode(addressBytes);
|
|
1040
1045
|
} catch (error) {
|
|
1041
1046
|
console.error("TRON address derivation failed:", error);
|
|
@@ -1050,7 +1055,7 @@ function deriveSparkAddress(seed, network = "testnet") {
|
|
|
1050
1055
|
if (!child.publicKey) {
|
|
1051
1056
|
throw new Error("Failed to derive public key");
|
|
1052
1057
|
}
|
|
1053
|
-
const pubKeyHash =
|
|
1058
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
1054
1059
|
const witnessVersion = 0;
|
|
1055
1060
|
const words = base.bech32.toWords(pubKeyHash);
|
|
1056
1061
|
words.unshift(witnessVersion);
|
|
@@ -1108,10 +1113,10 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
1108
1113
|
return addresses;
|
|
1109
1114
|
}
|
|
1110
1115
|
function isValidSeed(seed) {
|
|
1111
|
-
return bip39.validateMnemonic(seed,
|
|
1116
|
+
return bip39.validateMnemonic(seed, english.wordlist);
|
|
1112
1117
|
}
|
|
1113
1118
|
function generateSeedPhrase() {
|
|
1114
|
-
return bip39.generateMnemonic(
|
|
1119
|
+
return bip39.generateMnemonic(english.wordlist);
|
|
1115
1120
|
}
|
|
1116
1121
|
|
|
1117
1122
|
// src/services/ZubariWdkService.ts
|
|
@@ -1892,6 +1897,33 @@ var WalletManager = class _WalletManager {
|
|
|
1892
1897
|
console.warn("Failed to save addresses to storage:", error);
|
|
1893
1898
|
}
|
|
1894
1899
|
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Normalize an address value - extract string from object format if needed
|
|
1902
|
+
* Handles both string addresses and object format {chain, address, path}
|
|
1903
|
+
*/
|
|
1904
|
+
normalizeAddress(value) {
|
|
1905
|
+
if (typeof value === "string") {
|
|
1906
|
+
return value;
|
|
1907
|
+
}
|
|
1908
|
+
if (value && typeof value === "object" && "address" in value) {
|
|
1909
|
+
const addr = value.address;
|
|
1910
|
+
return typeof addr === "string" ? addr : null;
|
|
1911
|
+
}
|
|
1912
|
+
return null;
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Normalize all addresses in an object - extract strings from object format
|
|
1916
|
+
*/
|
|
1917
|
+
normalizeAddresses(addresses) {
|
|
1918
|
+
const normalized = {};
|
|
1919
|
+
for (const [chain, value] of Object.entries(addresses)) {
|
|
1920
|
+
const addr = this.normalizeAddress(value);
|
|
1921
|
+
if (addr) {
|
|
1922
|
+
normalized[chain] = addr;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return normalized;
|
|
1926
|
+
}
|
|
1895
1927
|
/**
|
|
1896
1928
|
* Load derived addresses from storage
|
|
1897
1929
|
*/
|
|
@@ -1899,8 +1931,11 @@ var WalletManager = class _WalletManager {
|
|
|
1899
1931
|
try {
|
|
1900
1932
|
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1901
1933
|
if (stored) {
|
|
1902
|
-
const
|
|
1903
|
-
console.log("
|
|
1934
|
+
const rawAddresses = JSON.parse(stored);
|
|
1935
|
+
console.log("[WalletManager] Raw addresses from storage:", rawAddresses);
|
|
1936
|
+
const addresses = this.normalizeAddresses(rawAddresses);
|
|
1937
|
+
console.log("[WalletManager] Normalized addresses:", addresses);
|
|
1938
|
+
await this.saveAddressesToStorage(addresses);
|
|
1904
1939
|
return addresses;
|
|
1905
1940
|
}
|
|
1906
1941
|
} catch (error) {
|
|
@@ -1938,8 +1973,15 @@ var WalletManager = class _WalletManager {
|
|
|
1938
1973
|
* Returns cached address or null - use deriveAllAddressesAsync to derive addresses
|
|
1939
1974
|
*/
|
|
1940
1975
|
getAddressForChain(chain) {
|
|
1941
|
-
|
|
1942
|
-
|
|
1976
|
+
const cachedValue = this.derivedAddresses[chain];
|
|
1977
|
+
if (cachedValue) {
|
|
1978
|
+
console.log(`[WalletManager] getAddressForChain(${chain}) cached value:`, cachedValue, "type:", typeof cachedValue);
|
|
1979
|
+
const addr = this.normalizeAddress(cachedValue);
|
|
1980
|
+
console.log(`[WalletManager] getAddressForChain(${chain}) normalized:`, addr);
|
|
1981
|
+
if (addr) {
|
|
1982
|
+
this.derivedAddresses[chain] = addr;
|
|
1983
|
+
return addr;
|
|
1984
|
+
}
|
|
1943
1985
|
}
|
|
1944
1986
|
if (chain === "ethereum" && this.currentSeed) {
|
|
1945
1987
|
this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
|
|
@@ -1951,7 +1993,7 @@ var WalletManager = class _WalletManager {
|
|
|
1951
1993
|
* Get all derived addresses
|
|
1952
1994
|
*/
|
|
1953
1995
|
getAllAddresses() {
|
|
1954
|
-
return
|
|
1996
|
+
return this.normalizeAddresses(this.derivedAddresses);
|
|
1955
1997
|
}
|
|
1956
1998
|
/**
|
|
1957
1999
|
* Set the selected chain
|
|
@@ -1993,6 +2035,7 @@ var WalletManager = class _WalletManager {
|
|
|
1993
2035
|
let balance = "0";
|
|
1994
2036
|
if (chain === "ethereum") {
|
|
1995
2037
|
const viemChain = this.config.network === "mainnet" ? chains.mainnet : chains.sepolia;
|
|
2038
|
+
console.log(`[WalletManager] Fetching ${chain} balance for ${address} using RPC: ${this.config.rpcUrl}`);
|
|
1996
2039
|
const client = viem.createPublicClient({
|
|
1997
2040
|
chain: viemChain,
|
|
1998
2041
|
transport: viem.http(this.config.rpcUrl, {
|
|
@@ -2007,8 +2050,9 @@ var WalletManager = class _WalletManager {
|
|
|
2007
2050
|
address
|
|
2008
2051
|
});
|
|
2009
2052
|
balance = viem.formatEther(rawBalance);
|
|
2053
|
+
console.log(`[WalletManager] ${chain} balance fetched: ${balance} (raw: ${rawBalance})`);
|
|
2010
2054
|
} catch (error) {
|
|
2011
|
-
console.
|
|
2055
|
+
console.error(`[WalletManager] Failed to fetch ${chain} balance from ${this.config.rpcUrl}:`, error);
|
|
2012
2056
|
}
|
|
2013
2057
|
} else if (chain === "bitcoin") {
|
|
2014
2058
|
const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
|