@zubari/sdk 0.4.3 → 0.4.5

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.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, isTestnet = false) {
134
+ function getNetworkConfig(network, isTestnet2 = false) {
135
135
  const mainnetConfig = NETWORKS[network];
136
- if (!isTestnet) return mainnetConfig;
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: ZERO_ADDRESS,
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 {
@@ -1923,8 +2063,8 @@ var WalletManager = class _WalletManager {
1923
2063
  selectedChain = "ethereum";
1924
2064
  wdkService;
1925
2065
  constructor(config = {}) {
1926
- const isTestnet = config.network !== "mainnet";
1927
- const ethereumConfig = getNetworkConfig("ethereum", isTestnet);
2066
+ const isTestnet2 = config.network !== "mainnet";
2067
+ const ethereumConfig = getNetworkConfig("ethereum", isTestnet2);
1928
2068
  this.config = {
1929
2069
  network: config.network || "mainnet",
1930
2070
  rpcUrl: config.rpcUrl || ethereumConfig.rpcUrl,
@@ -2434,8 +2574,8 @@ var WalletManager = class _WalletManager {
2434
2574
  console.error(`[WalletManager] Failed to fetch ${chain} balance from ${this.config.rpcUrl}:`, error);
2435
2575
  }
2436
2576
  } else if (chain === "bitcoin") {
2437
- const isMainnet = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
2438
- const apisToTry = isMainnet ? ["https://mempool.space/api"] : [
2577
+ const isMainnet2 = this.config.network === "mainnet" || address.startsWith("bc1") || address.startsWith("1") || address.startsWith("3");
2578
+ const apisToTry = isMainnet2 ? ["https://mempool.space/api"] : [
2439
2579
  "https://mempool.space/testnet/api",
2440
2580
  // testnet3 first (more common)
2441
2581
  "https://mempool.space/testnet4/api"
@@ -2449,7 +2589,7 @@ var WalletManager = class _WalletManager {
2449
2589
  if (response.ok) {
2450
2590
  const data = await response.json();
2451
2591
  const txCount = (data.chain_stats?.tx_count || 0) + (data.mempool_stats?.tx_count || 0);
2452
- if (txCount > 0 || isMainnet) {
2592
+ if (txCount > 0 || isMainnet2) {
2453
2593
  const chainFunded = data.chain_stats?.funded_txo_sum || 0;
2454
2594
  const chainSpent = data.chain_stats?.spent_txo_sum || 0;
2455
2595
  const mempoolFunded = data.mempool_stats?.funded_txo_sum || 0;
@@ -6967,11 +7107,11 @@ var SwapService = class {
6967
7107
  isTestnet;
6968
7108
  addresses;
6969
7109
  tokens;
6970
- constructor(chainId, isTestnet = false) {
7110
+ constructor(chainId, isTestnet2 = false) {
6971
7111
  this.chainId = chainId;
6972
- this.isTestnet = isTestnet;
6973
- this.addresses = isTestnet ? UNISWAP_ADDRESSES.sepolia : UNISWAP_ADDRESSES.mainnet;
6974
- this.tokens = isTestnet ? TOKENS.sepolia : TOKENS.mainnet;
7112
+ this.isTestnet = isTestnet2;
7113
+ this.addresses = isTestnet2 ? UNISWAP_ADDRESSES.sepolia : UNISWAP_ADDRESSES.mainnet;
7114
+ this.tokens = isTestnet2 ? TOKENS.sepolia : TOKENS.mainnet;
6975
7115
  }
6976
7116
  /**
6977
7117
  * Get a swap quote from Uniswap V3 Quoter
@@ -7304,7 +7444,7 @@ var TransactionService = class {
7304
7444
  if (this.wallets[chain]) {
7305
7445
  return this.wallets[chain];
7306
7446
  }
7307
- const isTestnet = this.config.network === "testnet";
7447
+ const isTestnet2 = this.config.network === "testnet";
7308
7448
  try {
7309
7449
  switch (chain) {
7310
7450
  case "ethereum": {
@@ -7315,7 +7455,7 @@ var TransactionService = class {
7315
7455
  }
7316
7456
  case "bitcoin": {
7317
7457
  const wallet = new WalletManagerBtc(this.seed, {
7318
- network: isTestnet ? "testnet" : "bitcoin"
7458
+ network: isTestnet2 ? "testnet" : "bitcoin"
7319
7459
  });
7320
7460
  this.wallets[chain] = wallet;
7321
7461
  return wallet;
@@ -7346,7 +7486,7 @@ var TransactionService = class {
7346
7486
  }
7347
7487
  case "spark": {
7348
7488
  const wallet = new WalletManagerSpark(this.seed, {
7349
- network: isTestnet ? "TESTNET" : "MAINNET"
7489
+ network: isTestnet2 ? "TESTNET" : "MAINNET"
7350
7490
  });
7351
7491
  this.wallets[chain] = wallet;
7352
7492
  return wallet;
@@ -7604,14 +7744,17 @@ function normalizeAddress(address) {
7604
7744
 
7605
7745
  exports.BrowserAddressDerivation = BrowserAddressDerivation_exports;
7606
7746
  exports.CURRENCY_ADDRESSES = CURRENCY_ADDRESSES;
7747
+ exports.DEFAULT_CONTRACTS = DEFAULT_CONTRACTS;
7607
7748
  exports.DERIVATION_PATHS = DERIVATION_PATHS;
7608
7749
  exports.KeyManager = KeyManager;
7750
+ exports.MAINNET_FEE_WALLETS = MAINNET_FEE_WALLETS;
7609
7751
  exports.MemoryStorageAdapter = MemoryStorageAdapter;
7610
7752
  exports.NETWORKS = NETWORKS;
7611
7753
  exports.NFT_VOUCHER_DOMAIN = NFT_VOUCHER_DOMAIN;
7612
7754
  exports.NFT_VOUCHER_TYPES = NFT_VOUCHER_TYPES;
7613
7755
  exports.PLATFORM_CONFIG = PLATFORM_CONFIG;
7614
7756
  exports.SwapService = SwapService;
7757
+ exports.TESTNET_FEE_WALLETS = TESTNET_FEE_WALLETS;
7615
7758
  exports.TESTNET_NETWORKS = TESTNET_NETWORKS;
7616
7759
  exports.TransactionService = TransactionService;
7617
7760
  exports.WalletManager = WalletManager;
@@ -7632,13 +7775,28 @@ exports.createTransactionService = createTransactionService;
7632
7775
  exports.createZubariWdkService = createZubariWdkService;
7633
7776
  exports.formatAddress = formatAddress;
7634
7777
  exports.formatBalance = formatBalance;
7778
+ exports.getAllFeeWallets = getAllFeeWallets;
7779
+ exports.getChainId = getChainId;
7635
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;
7636
7788
  exports.getNetworkConfig = getNetworkConfig;
7789
+ exports.getNetworkName = getNetworkName;
7790
+ exports.getRpcUrl = getRpcUrl;
7637
7791
  exports.getTransactionService = getTransactionService;
7638
7792
  exports.getWdkApiClient = getWdkApiClient;
7793
+ exports.getZubariNetwork = getZubariNetwork;
7639
7794
  exports.getZubariWdkService = getZubariWdkService;
7640
7795
  exports.isBrowser = isBrowser;
7796
+ exports.isMainnet = isMainnet;
7797
+ exports.isTestnet = isTestnet;
7641
7798
  exports.isValidAddress = isValidAddress;
7799
+ exports.logNetworkStatus = logNetworkStatus;
7642
7800
  exports.normalizeAddress = normalizeAddress;
7643
7801
  //# sourceMappingURL=index.js.map
7644
7802
  //# sourceMappingURL=index.js.map