@trustware/sdk-staging 1.1.12-staging.6 → 1.1.12-staging.7

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.
@@ -12265,7 +12265,7 @@ var init_constants = __esm({
12265
12265
  "src/constants.ts"() {
12266
12266
  "use strict";
12267
12267
  SDK_NAME = "@trustware/sdk";
12268
- SDK_VERSION = "1.1.12-staging.6";
12268
+ SDK_VERSION = "1.1.12-staging.7";
12269
12269
  API_ROOT = "https://bv-staging-api.trustware.io";
12270
12270
  API_PREFIX = "/api";
12271
12271
  }
@@ -12241,7 +12241,7 @@ var init_constants = __esm({
12241
12241
  "src/constants.ts"() {
12242
12242
  "use strict";
12243
12243
  SDK_NAME = "@trustware/sdk";
12244
- SDK_VERSION = "1.1.12-staging.6";
12244
+ SDK_VERSION = "1.1.12-staging.7";
12245
12245
  API_ROOT = "https://bv-staging-api.trustware.io";
12246
12246
  API_PREFIX = "/api";
12247
12247
  }
package/dist/wallet.cjs CHANGED
@@ -39,9 +39,58 @@ var init_bridges = __esm({
39
39
  }
40
40
  });
41
41
 
42
+ // src/wallets/chainParams.ts
43
+ function chainParamsFor(chainId) {
44
+ return registered.get(chainId) ?? BUILTIN_CHAIN_PARAMS[chainId];
45
+ }
46
+ var BUILTIN_CHAIN_PARAMS, registered;
47
+ var init_chainParams = __esm({
48
+ "src/wallets/chainParams.ts"() {
49
+ "use strict";
50
+ BUILTIN_CHAIN_PARAMS = {
51
+ 1: {
52
+ chainIdHex: "0x1",
53
+ chainName: "Ethereum",
54
+ rpcUrls: ["https://eth.llamarpc.com"],
55
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
56
+ blockExplorerUrls: ["https://etherscan.io"]
57
+ },
58
+ 137: {
59
+ chainIdHex: "0x89",
60
+ chainName: "Polygon",
61
+ rpcUrls: ["https://polygon-rpc.com"],
62
+ nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
63
+ blockExplorerUrls: ["https://polygonscan.com"]
64
+ },
65
+ 8453: {
66
+ chainIdHex: "0x2105",
67
+ chainName: "Base",
68
+ rpcUrls: ["https://mainnet.base.org"],
69
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
70
+ blockExplorerUrls: ["https://basescan.org"]
71
+ },
72
+ 42161: {
73
+ chainIdHex: "0xa4b1",
74
+ chainName: "Arbitrum One",
75
+ rpcUrls: ["https://arb1.arbitrum.io/rpc"],
76
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
77
+ blockExplorerUrls: ["https://arbiscan.io"]
78
+ },
79
+ 43114: {
80
+ chainIdHex: "0xa86a",
81
+ chainName: "Avalanche C-Chain",
82
+ rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
83
+ nativeCurrency: { name: "Avalanche", symbol: "AVAX", decimals: 18 },
84
+ blockExplorerUrls: ["https://snowtrace.io"]
85
+ }
86
+ };
87
+ registered = /* @__PURE__ */ new Map();
88
+ }
89
+ });
90
+
42
91
  // src/wallets/eipWallets.ts
43
92
  async function addThenSwitch(eth, chainId) {
44
- const p = CHAIN_PARAMS[chainId];
93
+ const p = chainParamsFor(chainId);
45
94
  if (!p) throw new Error(`Unknown chain ${chainId} (no params to add)`);
46
95
  await eth.request({ method: "wallet_addEthereumChain", params: [p] });
47
96
  await eth.request({
@@ -69,7 +118,7 @@ function useEIP1193(eth) {
69
118
  async switchChain(chainId) {
70
119
  if (switching) return;
71
120
  switching = true;
72
- const hex = CHAIN_PARAMS[chainId]?.chainIdHex ?? `0x${chainId.toString(16)}`;
121
+ const hex = chainParamsFor(chainId)?.chainIdHex ?? `0x${chainId.toString(16)}`;
73
122
  try {
74
123
  await eth.request({
75
124
  method: "wallet_switchEthereumChain",
@@ -78,7 +127,6 @@ function useEIP1193(eth) {
78
127
  } catch (e2) {
79
128
  if (e2?.code === 4902) {
80
129
  await addThenSwitch(eth, chainId);
81
- } else if (e2?.code === 4001) {
82
130
  } else {
83
131
  throw e2;
84
132
  }
@@ -120,15 +168,13 @@ function useWagmi(client) {
120
168
  const eth = globalThis.ethereum;
121
169
  if (!eth?.request) throw new Error("switchChain not available");
122
170
  try {
123
- const hex = CHAIN_PARAMS[target]?.chainIdHex ?? `0x${target.toString(16)}`;
171
+ const hex = chainParamsFor(target)?.chainIdHex ?? `0x${target.toString(16)}`;
124
172
  await eth.request({
125
173
  method: "wallet_switchEthereumChain",
126
174
  params: [{ chainId: hex }]
127
175
  });
128
176
  } catch (e2) {
129
177
  if (e2?.code === 4902) await addThenSwitch(eth, target);
130
- else if (e2?.code === 4001)
131
- ;
132
178
  else throw e2;
133
179
  }
134
180
  } finally {
@@ -214,47 +260,10 @@ async function autoDetectWallet(timeoutMs = 400) {
214
260
  const best = rank(Array.from(dedup.values()))[0];
215
261
  return { kind: "eip1193", wallet: useEIP1193(best.provider) };
216
262
  }
217
- var CHAIN_PARAMS;
218
263
  var init_eipWallets = __esm({
219
264
  "src/wallets/eipWallets.ts"() {
220
265
  "use strict";
221
- CHAIN_PARAMS = {
222
- 1: {
223
- chainIdHex: "0x1",
224
- chainName: "Ethereum",
225
- rpcUrls: ["https://eth.llamarpc.com"],
226
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
227
- blockExplorerUrls: ["https://etherscan.io"]
228
- },
229
- 137: {
230
- chainIdHex: "0x89",
231
- chainName: "Polygon",
232
- rpcUrls: ["https://polygon-rpc.com"],
233
- nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
234
- blockExplorerUrls: ["https://polygonscan.com"]
235
- },
236
- 8453: {
237
- chainIdHex: "0x2105",
238
- chainName: "Base",
239
- rpcUrls: ["https://mainnet.base.org"],
240
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
241
- blockExplorerUrls: ["https://basescan.org"]
242
- },
243
- 42161: {
244
- chainIdHex: "0xa4b1",
245
- chainName: "Arbitrum One",
246
- rpcUrls: ["https://arb1.arbitrum.io/rpc"],
247
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
248
- blockExplorerUrls: ["https://arbiscan.io"]
249
- },
250
- 43114: {
251
- chainIdHex: "0xa86a",
252
- chainName: "Avalanche C-Chain",
253
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
254
- nativeCurrency: { name: "Avalanche", symbol: "AVAX", decimals: 18 },
255
- blockExplorerUrls: ["https://snowtrace.io"]
256
- }
257
- };
266
+ init_chainParams();
258
267
  }
259
268
  });
260
269
 
@@ -264,7 +273,7 @@ var init_constants = __esm({
264
273
  "src/constants.ts"() {
265
274
  "use strict";
266
275
  SDK_NAME = "@trustware/sdk";
267
- SDK_VERSION = "1.1.12-staging.6";
276
+ SDK_VERSION = "1.1.12-staging.7";
268
277
  API_ROOT = "https://bv-staging-api.trustware.io";
269
278
  API_PREFIX = "/api";
270
279
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";