@zubari/sdk 0.4.2 → 0.4.4
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/{index-QLZi5YRN.d.mts → contracts-BahTuxZj.d.mts} +151 -83
- package/dist/{index-BnlkQ9B6.d.ts → contracts-D7rVmNJy.d.ts} +151 -83
- package/dist/index.d.mts +62 -2
- package/dist/index.d.ts +62 -2
- package/dist/index.js +182 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -17
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.js +9 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +9 -1
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.js +9 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +9 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +1 -1
- package/dist/wallet/index.d.ts +1 -1
- package/dist/wallet/index.js +11 -2
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +11 -2
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,9 +131,9 @@ var DERIVATION_PATHS = {
|
|
|
131
131
|
solana: "m/44'/501'/0'/0",
|
|
132
132
|
spark: "m/44'/998'/0'/0"
|
|
133
133
|
};
|
|
134
|
-
function getNetworkConfig(network,
|
|
134
|
+
function getNetworkConfig(network, isTestnet2 = false) {
|
|
135
135
|
const mainnetConfig = NETWORKS[network];
|
|
136
|
-
if (!
|
|
136
|
+
if (!isTestnet2) return mainnetConfig;
|
|
137
137
|
const testnetOverrides = TESTNET_NETWORKS[network];
|
|
138
138
|
if (!testnetOverrides) return mainnetConfig;
|
|
139
139
|
return {
|
|
@@ -142,6 +142,54 @@ function getNetworkConfig(network, isTestnet = false) {
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// src/config/env.ts
|
|
146
|
+
function getZubariNetwork() {
|
|
147
|
+
if (typeof process !== "undefined" && process.env) {
|
|
148
|
+
if (process.env.ZUBARI_NETWORK === "mainnet") {
|
|
149
|
+
return "mainnet";
|
|
150
|
+
}
|
|
151
|
+
if (process.env.NEXT_PUBLIC_ZUBARI_NETWORK === "mainnet") {
|
|
152
|
+
return "mainnet";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return "testnet";
|
|
156
|
+
}
|
|
157
|
+
function isMainnet() {
|
|
158
|
+
return getZubariNetwork() === "mainnet";
|
|
159
|
+
}
|
|
160
|
+
function isTestnet() {
|
|
161
|
+
return getZubariNetwork() === "testnet";
|
|
162
|
+
}
|
|
163
|
+
function getChainId() {
|
|
164
|
+
return isMainnet() ? 1 : 11155111;
|
|
165
|
+
}
|
|
166
|
+
function getNetworkName() {
|
|
167
|
+
return isMainnet() ? "Ethereum Mainnet" : "Ethereum Sepolia";
|
|
168
|
+
}
|
|
169
|
+
function getExplorerUrl() {
|
|
170
|
+
return isMainnet() ? "https://etherscan.io" : "https://sepolia.etherscan.io";
|
|
171
|
+
}
|
|
172
|
+
function getRpcUrl() {
|
|
173
|
+
return isMainnet() ? "https://ethereum-rpc.publicnode.com" : "https://ethereum-sepolia-rpc.publicnode.com";
|
|
174
|
+
}
|
|
175
|
+
function logNetworkStatus() {
|
|
176
|
+
const network = getZubariNetwork();
|
|
177
|
+
const chainId = getChainId();
|
|
178
|
+
if (network === "mainnet") {
|
|
179
|
+
console.warn(
|
|
180
|
+
"\x1B[33m%s\x1B[0m",
|
|
181
|
+
// Yellow color
|
|
182
|
+
`\u26A0\uFE0F ZUBARI SDK: Running on MAINNET (Chain ID: ${chainId}) - Real funds will be used!`
|
|
183
|
+
);
|
|
184
|
+
} else {
|
|
185
|
+
console.info(
|
|
186
|
+
"\x1B[36m%s\x1B[0m",
|
|
187
|
+
// Cyan color
|
|
188
|
+
`\u2139\uFE0F ZUBARI SDK: Running on TESTNET (Sepolia, Chain ID: ${chainId})`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
145
193
|
// src/config/contracts.ts
|
|
146
194
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
147
195
|
var ZUBARI_CONTRACTS = {
|
|
@@ -160,7 +208,8 @@ var ZUBARI_CONTRACTS = {
|
|
|
160
208
|
subscriptions: "0x8C05F8aD2F295fB7f3596043a7c37C98A5F7fAB8",
|
|
161
209
|
// ZubariSubscription - 10% fee
|
|
162
210
|
subscriptionsV2: ZERO_ADDRESS,
|
|
163
|
-
subscriptionsSimple:
|
|
211
|
+
subscriptionsSimple: "0x944f306e7d2e4f224dd660442EB65e4021b5eC24",
|
|
212
|
+
// Deployed 2025-01-26
|
|
164
213
|
creatorRegistry: ZERO_ADDRESS,
|
|
165
214
|
payouts: "0x804Fe503936E8b8d3D5Dbb62AF4fB6Fe7265Fb2c",
|
|
166
215
|
// ZubariPayouts
|
|
@@ -247,6 +296,97 @@ var CURRENCY_ADDRESSES = {
|
|
|
247
296
|
function getContractAddresses(network) {
|
|
248
297
|
return ZUBARI_CONTRACTS[network];
|
|
249
298
|
}
|
|
299
|
+
var MAINNET_FEE_WALLETS = {
|
|
300
|
+
// Ethereum (ETH, ERC-20 tokens like USDT)
|
|
301
|
+
ETH: {
|
|
302
|
+
address: "0x40Df60a57d02a7bB04B6624c65E2908Cc006badE",
|
|
303
|
+
name: "Zubari ETH Treasury",
|
|
304
|
+
network: "ethereum",
|
|
305
|
+
chainId: 1
|
|
306
|
+
},
|
|
307
|
+
// Bitcoin
|
|
308
|
+
BTC: {
|
|
309
|
+
address: "bc1qh20fx23wk34pcm3zp0v9wctwprtl02uvh6q9qj",
|
|
310
|
+
name: "Zubari BTC Treasury",
|
|
311
|
+
network: "bitcoin"
|
|
312
|
+
},
|
|
313
|
+
// Solana (SOL, SPL tokens)
|
|
314
|
+
SOLANA: {
|
|
315
|
+
address: "2hXGumVRpD5KgdqNZUuYJ2YoyLR6jc8mvWbubciWjPuZ",
|
|
316
|
+
name: "Zubari Solana Treasury",
|
|
317
|
+
network: "solana"
|
|
318
|
+
},
|
|
319
|
+
// TON (The Open Network)
|
|
320
|
+
TON: {
|
|
321
|
+
address: "UQB5hOrm9YGoKjrCVmvAUFgmApkvKWqVMROjieKs3z4kDz99",
|
|
322
|
+
name: "Zubari TON Treasury",
|
|
323
|
+
network: "ton"
|
|
324
|
+
},
|
|
325
|
+
// Tron (TRX, TRC-20 tokens like USDT)
|
|
326
|
+
TRON: {
|
|
327
|
+
address: "TVBPjQFNe8JgVctDKWMxJNgjbPZoP6uu5h",
|
|
328
|
+
name: "Zubari Tron Treasury",
|
|
329
|
+
network: "tron"
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
var TESTNET_FEE_WALLETS = {
|
|
333
|
+
// Ethereum Sepolia
|
|
334
|
+
ETH: {
|
|
335
|
+
address: "0xAC2e22B5a99F0123319644A9bF0DF4FD72c9b001",
|
|
336
|
+
// Zubari Treasury on Sepolia
|
|
337
|
+
name: "Zubari ETH Testnet Treasury",
|
|
338
|
+
network: "sepolia",
|
|
339
|
+
chainId: 11155111
|
|
340
|
+
},
|
|
341
|
+
// Bitcoin Testnet
|
|
342
|
+
BTC: {
|
|
343
|
+
address: "",
|
|
344
|
+
name: "Zubari BTC Testnet Treasury",
|
|
345
|
+
network: "bitcoin-testnet"
|
|
346
|
+
},
|
|
347
|
+
// Solana Devnet
|
|
348
|
+
SOLANA: {
|
|
349
|
+
address: "",
|
|
350
|
+
name: "Zubari Solana Devnet Treasury",
|
|
351
|
+
network: "solana-devnet"
|
|
352
|
+
},
|
|
353
|
+
// TON Testnet
|
|
354
|
+
TON: {
|
|
355
|
+
address: "",
|
|
356
|
+
name: "Zubari TON Testnet Treasury",
|
|
357
|
+
network: "ton-testnet"
|
|
358
|
+
},
|
|
359
|
+
// Tron Shasta Testnet
|
|
360
|
+
TRON: {
|
|
361
|
+
address: "",
|
|
362
|
+
name: "Zubari Tron Testnet Treasury",
|
|
363
|
+
network: "tron-shasta"
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
function getFeeWallet(chain, isMainnet2 = true) {
|
|
367
|
+
return isMainnet2 ? MAINNET_FEE_WALLETS[chain] : TESTNET_FEE_WALLETS[chain];
|
|
368
|
+
}
|
|
369
|
+
function getAllFeeWallets(useMainnet = false) {
|
|
370
|
+
return useMainnet ? MAINNET_FEE_WALLETS : TESTNET_FEE_WALLETS;
|
|
371
|
+
}
|
|
372
|
+
var DEFAULT_CONTRACTS = {
|
|
373
|
+
subscriptions: "subscriptionsSimple"
|
|
374
|
+
};
|
|
375
|
+
function getCurrentContractAddresses() {
|
|
376
|
+
return ZUBARI_CONTRACTS[getZubariNetwork()];
|
|
377
|
+
}
|
|
378
|
+
function getDefaultSubscriptionAddress() {
|
|
379
|
+
return ZUBARI_CONTRACTS[getZubariNetwork()].subscriptionsSimple;
|
|
380
|
+
}
|
|
381
|
+
function getCurrentFeeWallets() {
|
|
382
|
+
return isMainnet() ? MAINNET_FEE_WALLETS : TESTNET_FEE_WALLETS;
|
|
383
|
+
}
|
|
384
|
+
function getCurrentFeeWallet(chain) {
|
|
385
|
+
return getCurrentFeeWallets()[chain];
|
|
386
|
+
}
|
|
387
|
+
function getCurrentCurrencyAddresses() {
|
|
388
|
+
return CURRENCY_ADDRESSES[getZubariNetwork()];
|
|
389
|
+
}
|
|
250
390
|
|
|
251
391
|
// src/services/WdkApiClient.ts
|
|
252
392
|
var WdkApiClient = class {
|
|
@@ -778,7 +918,7 @@ var ZubariWdkService = class {
|
|
|
778
918
|
}
|
|
779
919
|
return null;
|
|
780
920
|
};
|
|
781
|
-
|
|
921
|
+
const addresses = {
|
|
782
922
|
ethereum: extractAddress(response.addresses.ethereum),
|
|
783
923
|
bitcoin: extractAddress(response.addresses.bitcoin),
|
|
784
924
|
ton: extractAddress(response.addresses.ton),
|
|
@@ -786,6 +926,14 @@ var ZubariWdkService = class {
|
|
|
786
926
|
solana: extractAddress(response.addresses.solana),
|
|
787
927
|
spark: extractAddress(response.addresses.spark)
|
|
788
928
|
};
|
|
929
|
+
if (!addresses.spark) {
|
|
930
|
+
try {
|
|
931
|
+
addresses.spark = deriveSparkAddress(seed, this.config.network);
|
|
932
|
+
} catch (e) {
|
|
933
|
+
console.warn("Browser Spark derivation fallback failed:", e);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return addresses;
|
|
789
937
|
}
|
|
790
938
|
} catch (error) {
|
|
791
939
|
console.warn("API address derivation failed:", error);
|
|
@@ -1915,8 +2063,8 @@ var WalletManager = class _WalletManager {
|
|
|
1915
2063
|
selectedChain = "ethereum";
|
|
1916
2064
|
wdkService;
|
|
1917
2065
|
constructor(config = {}) {
|
|
1918
|
-
const
|
|
1919
|
-
const ethereumConfig = getNetworkConfig("ethereum",
|
|
2066
|
+
const isTestnet2 = config.network !== "mainnet";
|
|
2067
|
+
const ethereumConfig = getNetworkConfig("ethereum", isTestnet2);
|
|
1920
2068
|
this.config = {
|
|
1921
2069
|
network: config.network || "mainnet",
|
|
1922
2070
|
rpcUrl: config.rpcUrl || ethereumConfig.rpcUrl,
|
|
@@ -2426,8 +2574,8 @@ var WalletManager = class _WalletManager {
|
|
|
2426
2574
|
console.error(`[WalletManager] Failed to fetch ${chain} balance from ${this.config.rpcUrl}:`, error);
|
|
2427
2575
|
}
|
|
2428
2576
|
} else if (chain === "bitcoin") {
|
|
2429
|
-
const
|
|
2430
|
-
const apisToTry =
|
|
2577
|
+
const isMainnet2 = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
|
|
2578
|
+
const apisToTry = isMainnet2 ? ["https://mempool.space/api"] : [
|
|
2431
2579
|
"https://mempool.space/testnet/api",
|
|
2432
2580
|
// testnet3 first (more common)
|
|
2433
2581
|
"https://mempool.space/testnet4/api"
|
|
@@ -2441,7 +2589,7 @@ var WalletManager = class _WalletManager {
|
|
|
2441
2589
|
if (response.ok) {
|
|
2442
2590
|
const data = await response.json();
|
|
2443
2591
|
const txCount = (data.chain_stats?.tx_count || 0) + (data.mempool_stats?.tx_count || 0);
|
|
2444
|
-
if (txCount > 0 ||
|
|
2592
|
+
if (txCount > 0 || isMainnet2) {
|
|
2445
2593
|
const chainFunded = data.chain_stats?.funded_txo_sum || 0;
|
|
2446
2594
|
const chainSpent = data.chain_stats?.spent_txo_sum || 0;
|
|
2447
2595
|
const mempoolFunded = data.mempool_stats?.funded_txo_sum || 0;
|
|
@@ -6959,11 +7107,11 @@ var SwapService = class {
|
|
|
6959
7107
|
isTestnet;
|
|
6960
7108
|
addresses;
|
|
6961
7109
|
tokens;
|
|
6962
|
-
constructor(chainId,
|
|
7110
|
+
constructor(chainId, isTestnet2 = false) {
|
|
6963
7111
|
this.chainId = chainId;
|
|
6964
|
-
this.isTestnet =
|
|
6965
|
-
this.addresses =
|
|
6966
|
-
this.tokens =
|
|
7112
|
+
this.isTestnet = isTestnet2;
|
|
7113
|
+
this.addresses = isTestnet2 ? UNISWAP_ADDRESSES.sepolia : UNISWAP_ADDRESSES.mainnet;
|
|
7114
|
+
this.tokens = isTestnet2 ? TOKENS.sepolia : TOKENS.mainnet;
|
|
6967
7115
|
}
|
|
6968
7116
|
/**
|
|
6969
7117
|
* Get a swap quote from Uniswap V3 Quoter
|
|
@@ -7296,7 +7444,7 @@ var TransactionService = class {
|
|
|
7296
7444
|
if (this.wallets[chain]) {
|
|
7297
7445
|
return this.wallets[chain];
|
|
7298
7446
|
}
|
|
7299
|
-
const
|
|
7447
|
+
const isTestnet2 = this.config.network === "testnet";
|
|
7300
7448
|
try {
|
|
7301
7449
|
switch (chain) {
|
|
7302
7450
|
case "ethereum": {
|
|
@@ -7307,7 +7455,7 @@ var TransactionService = class {
|
|
|
7307
7455
|
}
|
|
7308
7456
|
case "bitcoin": {
|
|
7309
7457
|
const wallet = new WalletManagerBtc(this.seed, {
|
|
7310
|
-
network:
|
|
7458
|
+
network: isTestnet2 ? "testnet" : "bitcoin"
|
|
7311
7459
|
});
|
|
7312
7460
|
this.wallets[chain] = wallet;
|
|
7313
7461
|
return wallet;
|
|
@@ -7338,7 +7486,7 @@ var TransactionService = class {
|
|
|
7338
7486
|
}
|
|
7339
7487
|
case "spark": {
|
|
7340
7488
|
const wallet = new WalletManagerSpark(this.seed, {
|
|
7341
|
-
network:
|
|
7489
|
+
network: isTestnet2 ? "TESTNET" : "MAINNET"
|
|
7342
7490
|
});
|
|
7343
7491
|
this.wallets[chain] = wallet;
|
|
7344
7492
|
return wallet;
|
|
@@ -7596,14 +7744,17 @@ function normalizeAddress(address) {
|
|
|
7596
7744
|
|
|
7597
7745
|
exports.BrowserAddressDerivation = BrowserAddressDerivation_exports;
|
|
7598
7746
|
exports.CURRENCY_ADDRESSES = CURRENCY_ADDRESSES;
|
|
7747
|
+
exports.DEFAULT_CONTRACTS = DEFAULT_CONTRACTS;
|
|
7599
7748
|
exports.DERIVATION_PATHS = DERIVATION_PATHS;
|
|
7600
7749
|
exports.KeyManager = KeyManager;
|
|
7750
|
+
exports.MAINNET_FEE_WALLETS = MAINNET_FEE_WALLETS;
|
|
7601
7751
|
exports.MemoryStorageAdapter = MemoryStorageAdapter;
|
|
7602
7752
|
exports.NETWORKS = NETWORKS;
|
|
7603
7753
|
exports.NFT_VOUCHER_DOMAIN = NFT_VOUCHER_DOMAIN;
|
|
7604
7754
|
exports.NFT_VOUCHER_TYPES = NFT_VOUCHER_TYPES;
|
|
7605
7755
|
exports.PLATFORM_CONFIG = PLATFORM_CONFIG;
|
|
7606
7756
|
exports.SwapService = SwapService;
|
|
7757
|
+
exports.TESTNET_FEE_WALLETS = TESTNET_FEE_WALLETS;
|
|
7607
7758
|
exports.TESTNET_NETWORKS = TESTNET_NETWORKS;
|
|
7608
7759
|
exports.TransactionService = TransactionService;
|
|
7609
7760
|
exports.WalletManager = WalletManager;
|
|
@@ -7624,13 +7775,28 @@ exports.createTransactionService = createTransactionService;
|
|
|
7624
7775
|
exports.createZubariWdkService = createZubariWdkService;
|
|
7625
7776
|
exports.formatAddress = formatAddress;
|
|
7626
7777
|
exports.formatBalance = formatBalance;
|
|
7778
|
+
exports.getAllFeeWallets = getAllFeeWallets;
|
|
7779
|
+
exports.getChainId = getChainId;
|
|
7627
7780
|
exports.getContractAddresses = getContractAddresses;
|
|
7781
|
+
exports.getCurrentContractAddresses = getCurrentContractAddresses;
|
|
7782
|
+
exports.getCurrentCurrencyAddresses = getCurrentCurrencyAddresses;
|
|
7783
|
+
exports.getCurrentFeeWallet = getCurrentFeeWallet;
|
|
7784
|
+
exports.getCurrentFeeWallets = getCurrentFeeWallets;
|
|
7785
|
+
exports.getDefaultSubscriptionAddress = getDefaultSubscriptionAddress;
|
|
7786
|
+
exports.getExplorerUrl = getExplorerUrl;
|
|
7787
|
+
exports.getFeeWallet = getFeeWallet;
|
|
7628
7788
|
exports.getNetworkConfig = getNetworkConfig;
|
|
7789
|
+
exports.getNetworkName = getNetworkName;
|
|
7790
|
+
exports.getRpcUrl = getRpcUrl;
|
|
7629
7791
|
exports.getTransactionService = getTransactionService;
|
|
7630
7792
|
exports.getWdkApiClient = getWdkApiClient;
|
|
7793
|
+
exports.getZubariNetwork = getZubariNetwork;
|
|
7631
7794
|
exports.getZubariWdkService = getZubariWdkService;
|
|
7632
7795
|
exports.isBrowser = isBrowser;
|
|
7796
|
+
exports.isMainnet = isMainnet;
|
|
7797
|
+
exports.isTestnet = isTestnet;
|
|
7633
7798
|
exports.isValidAddress = isValidAddress;
|
|
7799
|
+
exports.logNetworkStatus = logNetworkStatus;
|
|
7634
7800
|
exports.normalizeAddress = normalizeAddress;
|
|
7635
7801
|
//# sourceMappingURL=index.js.map
|
|
7636
7802
|
//# sourceMappingURL=index.js.map
|