@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.
package/dist/wallet.mjs CHANGED
@@ -13,9 +13,58 @@ var init_bridges = __esm({
13
13
  }
14
14
  });
15
15
 
16
+ // src/wallets/chainParams.ts
17
+ function chainParamsFor(chainId) {
18
+ return registered.get(chainId) ?? BUILTIN_CHAIN_PARAMS[chainId];
19
+ }
20
+ var BUILTIN_CHAIN_PARAMS, registered;
21
+ var init_chainParams = __esm({
22
+ "src/wallets/chainParams.ts"() {
23
+ "use strict";
24
+ BUILTIN_CHAIN_PARAMS = {
25
+ 1: {
26
+ chainIdHex: "0x1",
27
+ chainName: "Ethereum",
28
+ rpcUrls: ["https://eth.llamarpc.com"],
29
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
30
+ blockExplorerUrls: ["https://etherscan.io"]
31
+ },
32
+ 137: {
33
+ chainIdHex: "0x89",
34
+ chainName: "Polygon",
35
+ rpcUrls: ["https://polygon-rpc.com"],
36
+ nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
37
+ blockExplorerUrls: ["https://polygonscan.com"]
38
+ },
39
+ 8453: {
40
+ chainIdHex: "0x2105",
41
+ chainName: "Base",
42
+ rpcUrls: ["https://mainnet.base.org"],
43
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
44
+ blockExplorerUrls: ["https://basescan.org"]
45
+ },
46
+ 42161: {
47
+ chainIdHex: "0xa4b1",
48
+ chainName: "Arbitrum One",
49
+ rpcUrls: ["https://arb1.arbitrum.io/rpc"],
50
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
51
+ blockExplorerUrls: ["https://arbiscan.io"]
52
+ },
53
+ 43114: {
54
+ chainIdHex: "0xa86a",
55
+ chainName: "Avalanche C-Chain",
56
+ rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
57
+ nativeCurrency: { name: "Avalanche", symbol: "AVAX", decimals: 18 },
58
+ blockExplorerUrls: ["https://snowtrace.io"]
59
+ }
60
+ };
61
+ registered = /* @__PURE__ */ new Map();
62
+ }
63
+ });
64
+
16
65
  // src/wallets/eipWallets.ts
17
66
  async function addThenSwitch(eth, chainId) {
18
- const p = CHAIN_PARAMS[chainId];
67
+ const p = chainParamsFor(chainId);
19
68
  if (!p) throw new Error(`Unknown chain ${chainId} (no params to add)`);
20
69
  await eth.request({ method: "wallet_addEthereumChain", params: [p] });
21
70
  await eth.request({
@@ -43,7 +92,7 @@ function useEIP1193(eth) {
43
92
  async switchChain(chainId) {
44
93
  if (switching) return;
45
94
  switching = true;
46
- const hex = CHAIN_PARAMS[chainId]?.chainIdHex ?? `0x${chainId.toString(16)}`;
95
+ const hex = chainParamsFor(chainId)?.chainIdHex ?? `0x${chainId.toString(16)}`;
47
96
  try {
48
97
  await eth.request({
49
98
  method: "wallet_switchEthereumChain",
@@ -52,7 +101,6 @@ function useEIP1193(eth) {
52
101
  } catch (e2) {
53
102
  if (e2?.code === 4902) {
54
103
  await addThenSwitch(eth, chainId);
55
- } else if (e2?.code === 4001) {
56
104
  } else {
57
105
  throw e2;
58
106
  }
@@ -94,15 +142,13 @@ function useWagmi(client) {
94
142
  const eth = globalThis.ethereum;
95
143
  if (!eth?.request) throw new Error("switchChain not available");
96
144
  try {
97
- const hex = CHAIN_PARAMS[target]?.chainIdHex ?? `0x${target.toString(16)}`;
145
+ const hex = chainParamsFor(target)?.chainIdHex ?? `0x${target.toString(16)}`;
98
146
  await eth.request({
99
147
  method: "wallet_switchEthereumChain",
100
148
  params: [{ chainId: hex }]
101
149
  });
102
150
  } catch (e2) {
103
151
  if (e2?.code === 4902) await addThenSwitch(eth, target);
104
- else if (e2?.code === 4001)
105
- ;
106
152
  else throw e2;
107
153
  }
108
154
  } finally {
@@ -188,47 +234,10 @@ async function autoDetectWallet(timeoutMs = 400) {
188
234
  const best = rank(Array.from(dedup.values()))[0];
189
235
  return { kind: "eip1193", wallet: useEIP1193(best.provider) };
190
236
  }
191
- var CHAIN_PARAMS;
192
237
  var init_eipWallets = __esm({
193
238
  "src/wallets/eipWallets.ts"() {
194
239
  "use strict";
195
- CHAIN_PARAMS = {
196
- 1: {
197
- chainIdHex: "0x1",
198
- chainName: "Ethereum",
199
- rpcUrls: ["https://eth.llamarpc.com"],
200
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
201
- blockExplorerUrls: ["https://etherscan.io"]
202
- },
203
- 137: {
204
- chainIdHex: "0x89",
205
- chainName: "Polygon",
206
- rpcUrls: ["https://polygon-rpc.com"],
207
- nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
208
- blockExplorerUrls: ["https://polygonscan.com"]
209
- },
210
- 8453: {
211
- chainIdHex: "0x2105",
212
- chainName: "Base",
213
- rpcUrls: ["https://mainnet.base.org"],
214
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
215
- blockExplorerUrls: ["https://basescan.org"]
216
- },
217
- 42161: {
218
- chainIdHex: "0xa4b1",
219
- chainName: "Arbitrum One",
220
- rpcUrls: ["https://arb1.arbitrum.io/rpc"],
221
- nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
222
- blockExplorerUrls: ["https://arbiscan.io"]
223
- },
224
- 43114: {
225
- chainIdHex: "0xa86a",
226
- chainName: "Avalanche C-Chain",
227
- rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
228
- nativeCurrency: { name: "Avalanche", symbol: "AVAX", decimals: 18 },
229
- blockExplorerUrls: ["https://snowtrace.io"]
230
- }
231
- };
240
+ init_chainParams();
232
241
  }
233
242
  });
234
243
 
@@ -238,7 +247,7 @@ var init_constants = __esm({
238
247
  "src/constants.ts"() {
239
248
  "use strict";
240
249
  SDK_NAME = "@trustware/sdk";
241
- SDK_VERSION = "1.1.12-staging.6";
250
+ SDK_VERSION = "1.1.12-staging.7";
242
251
  API_ROOT = "https://bv-staging-api.trustware.io";
243
252
  API_PREFIX = "/api";
244
253
  WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";