@weblock-wallet/sdk 0.1.55 → 0.1.57

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.d.cts CHANGED
@@ -116,14 +116,13 @@ interface NetworkInfo {
116
116
  * 토큰 잔액 정보
117
117
  */
118
118
  interface TokenBalance {
119
- /** 원본 값 (Wei) */
120
119
  raw: string;
121
- /** 변환된 값 */
122
120
  formatted: string;
123
- /** 소수점 자리수 */
124
121
  decimals: number;
125
- /** 토큰 심볼 */
126
122
  symbol: string;
123
+ balanceWei?: string;
124
+ balance?: string;
125
+ result?: string;
127
126
  }
128
127
  /**
129
128
  * 토큰 정보
package/dist/index.d.ts CHANGED
@@ -116,14 +116,13 @@ interface NetworkInfo {
116
116
  * 토큰 잔액 정보
117
117
  */
118
118
  interface TokenBalance {
119
- /** 원본 값 (Wei) */
120
119
  raw: string;
121
- /** 변환된 값 */
122
120
  formatted: string;
123
- /** 소수점 자리수 */
124
121
  decimals: number;
125
- /** 토큰 심볼 */
126
122
  symbol: string;
123
+ balanceWei?: string;
124
+ balance?: string;
125
+ result?: string;
127
126
  }
128
127
  /**
129
128
  * 토큰 정보
package/dist/index.js CHANGED
@@ -104619,6 +104619,18 @@ var WalletService = class {
104619
104619
  if (!from) {
104620
104620
  throw new SDKError("Wallet not found", "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */);
104621
104621
  }
104622
+ const toHexQuantity = (v5) => {
104623
+ if (v5 === void 0 || v5 === null) return "0x0";
104624
+ const s5 = String(v5).trim();
104625
+ if (!s5) return "0x0";
104626
+ if (s5.startsWith("0x") || s5.startsWith("0X")) return s5;
104627
+ try {
104628
+ const bi = BigInt(s5);
104629
+ return "0x" + bi.toString(16);
104630
+ } catch {
104631
+ return s5;
104632
+ }
104633
+ };
104622
104634
  const [share1, share2] = await Promise.all([
104623
104635
  this.walletClient.getWallet().then((wallet2) => wallet2.share1),
104624
104636
  LocalForage.get(STORAGE_KEYS.share2(this.orgHost))
@@ -104633,6 +104645,20 @@ var WalletService = class {
104633
104645
  const wallet = new Wallet(privateKey);
104634
104646
  const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
104635
104647
  const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
104648
+ let gasLimit = params.gasLimit;
104649
+ if (!gasLimit) {
104650
+ const est = await this.estimateGas(
104651
+ {
104652
+ from,
104653
+ to: params.to,
104654
+ value: toHexQuantity(params.value),
104655
+ data: params.data || "0x"
104656
+ },
104657
+ params.chainId
104658
+ );
104659
+ const buffered = Math.max(21e3, Math.ceil(est * 1.2));
104660
+ gasLimit = "0x" + buffered.toString(16);
104661
+ }
104636
104662
  const signedTx = await wallet.signTransaction({
104637
104663
  to: params.to,
104638
104664
  value: params.value,
@@ -104640,7 +104666,7 @@ var WalletService = class {
104640
104666
  chainId: params.chainId,
104641
104667
  nonce,
104642
104668
  gasPrice,
104643
- gasLimit: params.gasLimit
104669
+ gasLimit
104644
104670
  });
104645
104671
  return this.sendRawTransaction(signedTx, params.chainId);
104646
104672
  } catch (error) {
@@ -104699,11 +104725,34 @@ var NetworkService = class {
104699
104725
  async switchNetwork(networkId) {
104700
104726
  try {
104701
104727
  const networks = await this.getRegisteredNetworks();
104702
- const network = networks.find((n5) => n5.id === networkId);
104728
+ const key = String(networkId || "").trim();
104729
+ let network = networks.find((n5) => n5.id === key);
104730
+ if (!network) {
104731
+ const lower = key.toLowerCase();
104732
+ network = networks.find((n5) => (n5.name || "").toLowerCase() === lower);
104733
+ }
104734
+ if (!network && /^\d+$/.test(key)) {
104735
+ const chainId = Number(key);
104736
+ network = networks.find((n5) => n5.chainId === chainId);
104737
+ }
104738
+ if (!network) {
104739
+ const alias = key.toLowerCase();
104740
+ const aliasChainId = {
104741
+ fuji: 43113,
104742
+ avalanchefuji: 43113,
104743
+ "avalanche-fuji": 43113,
104744
+ avaxfuji: 43113,
104745
+ "avax-fuji": 43113
104746
+ };
104747
+ const chainId = aliasChainId[alias];
104748
+ if (chainId) {
104749
+ network = networks.find((n5) => n5.chainId === chainId);
104750
+ }
104751
+ }
104703
104752
  if (!network) {
104704
104753
  throw new SDKError("Network not found", "INVALID_NETWORK" /* INVALID_NETWORK */);
104705
104754
  }
104706
- await LocalForage.save(`${this.orgHost}:currentNetwork`, networkId);
104755
+ await LocalForage.save(`${this.orgHost}:currentNetwork`, network.id);
104707
104756
  } catch (error) {
104708
104757
  if (error instanceof SDKError) throw error;
104709
104758
  throw new SDKError("Failed to switch network", "NETWORK_ERROR" /* NETWORK_ERROR */);
@@ -106800,6 +106849,22 @@ var KNOWN_NETWORKS = {
106800
106849
  currencyDecimals: 18,
106801
106850
  explorerUrl: "https://polygonscan.com",
106802
106851
  isTestnet: false
106852
+ },
106853
+ 43114: {
106854
+ chainId: 43114,
106855
+ currencySymbol: "AVAX",
106856
+ currencyName: "Avalanche",
106857
+ currencyDecimals: 18,
106858
+ explorerUrl: "https://snowtrace.io",
106859
+ isTestnet: false
106860
+ },
106861
+ 43113: {
106862
+ chainId: 43113,
106863
+ currencySymbol: "AVAX",
106864
+ currencyName: "Avalanche Fuji",
106865
+ currencyDecimals: 18,
106866
+ explorerUrl: "https://testnet.snowtrace.io",
106867
+ isTestnet: true
106803
106868
  }
106804
106869
  };
106805
106870
  var DEFAULT_NETWORK_PARAMS = {