@trustware/sdk-staging 1.0.16-staging.13 → 1.0.17-staging.14

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.cjs CHANGED
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
9
  var __esm = (fn, res) => function __init() {
9
10
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
11
  };
@@ -29,6 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
30
  mod
30
31
  ));
31
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
34
 
33
35
  // src/config/defaults.ts
34
36
  var DEFAULT_SLIPPAGE, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_THEME, DEFAULT_MESSAGES;
@@ -74,7 +76,7 @@ var init_constants = __esm({
74
76
  "src/constants.ts"() {
75
77
  "use strict";
76
78
  SDK_NAME = "@trustware/sdk";
77
- SDK_VERSION = "1.0.16-staging.13";
79
+ SDK_VERSION = "1.0.17-staging.14";
78
80
  API_ROOT = "https://bv-staging-api.trustware.io";
79
81
  API_PREFIX = "/api";
80
82
  ASSETS_BASE_URL = "https://app.trustware.io";
@@ -269,6 +271,75 @@ var init_store = __esm({
269
271
  }
270
272
  });
271
273
 
274
+ // src/utils/chains.ts
275
+ function inferChainTypeFromValue(normalized) {
276
+ if (!normalized) return void 0;
277
+ const aliased = CHAIN_TYPE_ALIASES[normalized];
278
+ if (aliased) return aliased;
279
+ if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
280
+ return normalized;
281
+ }
282
+ if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
283
+ return "evm";
284
+ }
285
+ if (normalized.startsWith("solana:") || normalized.includes("solana")) {
286
+ return "solana";
287
+ }
288
+ if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
289
+ return "cosmos";
290
+ }
291
+ return void 0;
292
+ }
293
+ function normalizeChainKey(value) {
294
+ if (value === void 0 || value === null) return "";
295
+ return String(value).trim().toLowerCase();
296
+ }
297
+ function normalizeChainType(chain) {
298
+ if (!chain) return void 0;
299
+ const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
300
+ if (!raw) return void 0;
301
+ const normalized = String(raw).trim().toLowerCase();
302
+ return inferChainTypeFromValue(normalized) ?? normalized;
303
+ }
304
+ function getNativeTokenAddress(chainType) {
305
+ return normalizeChainType(chainType) === "solana" ? NATIVE_SOLANA : NATIVE_EVM;
306
+ }
307
+ function isSolanaNativeTokenAlias(address) {
308
+ if (!address) return false;
309
+ const trimmed = address.trim();
310
+ if (!trimmed) return false;
311
+ return trimmed === NATIVE_SOLANA || trimmed.toLowerCase() === NATIVE_EVM;
312
+ }
313
+ function normalizeAddress(address, chainType) {
314
+ const trimmed = address.trim();
315
+ if (normalizeChainType(chainType) === "solana") {
316
+ if (isSolanaNativeTokenAlias(trimmed)) {
317
+ return NATIVE_SOLANA;
318
+ }
319
+ return trimmed;
320
+ }
321
+ return trimmed.toLowerCase();
322
+ }
323
+ function isZeroAddressLike(address, chainType) {
324
+ if (!address) return true;
325
+ const normalized = normalizeAddress(address, chainType);
326
+ return normalized === normalizeAddress(getNativeTokenAddress(chainType), chainType) || normalized === "0x0000000000000000000000000000000000000000";
327
+ }
328
+ var NATIVE_EVM, NATIVE_SOLANA, CHAIN_TYPE_ALIASES;
329
+ var init_chains = __esm({
330
+ "src/utils/chains.ts"() {
331
+ "use strict";
332
+ NATIVE_EVM = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
333
+ NATIVE_SOLANA = "So11111111111111111111111111111111111111111";
334
+ CHAIN_TYPE_ALIASES = {
335
+ btc: "bitcoin",
336
+ bitcoin: "bitcoin",
337
+ sei: "cosmos",
338
+ "pacific-1": "cosmos"
339
+ };
340
+ }
341
+ });
342
+
272
343
  // src/config/index.ts
273
344
  var init_config2 = __esm({
274
345
  "src/config/index.ts"() {
@@ -423,16 +494,28 @@ __export(registry_exports, {
423
494
  NATIVE: () => NATIVE,
424
495
  Registry: () => Registry
425
496
  });
497
+ function getChainAliases(chain) {
498
+ const values = [
499
+ chain.chainId,
500
+ chain.id,
501
+ chain.networkIdentifier,
502
+ chain.axelarChainName,
503
+ chain.networkName
504
+ ];
505
+ return values.map((value) => normalizeChainKey(value)).filter(Boolean);
506
+ }
426
507
  var NATIVE, Registry;
427
508
  var init_registry = __esm({
428
509
  "src/registry.ts"() {
429
510
  "use strict";
430
511
  init_store();
512
+ init_chains();
431
513
  NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
432
514
  Registry = class {
433
515
  constructor(baseURL) {
434
516
  this.baseURL = baseURL;
435
517
  this._chainsById = /* @__PURE__ */ new Map();
518
+ this._chainAliases = /* @__PURE__ */ new Map();
436
519
  this._tokensByChain = /* @__PURE__ */ new Map();
437
520
  this._loaded = false;
438
521
  this._loadingPromise = null;
@@ -450,13 +533,18 @@ var init_registry = __esm({
450
533
  this._loadingPromise = null;
451
534
  }
452
535
  }
536
+ storeToken(chainKey, token) {
537
+ const list = this._tokensByChain.get(chainKey) ?? [];
538
+ list.push(token);
539
+ this._tokensByChain.set(chainKey, list);
540
+ }
453
541
  async load() {
454
542
  const cfg = TrustwareConfigStore.get();
455
543
  const [chainsRes, tokensRes] = await Promise.all([
456
- fetch(`${this.baseURL}/squid/chains`, {
544
+ fetch(`${this.baseURL}/v1/routes/chains`, {
457
545
  headers: { Accept: "application/json", "X-API-Key": cfg.apiKey }
458
546
  }),
459
- fetch(`${this.baseURL}/squid/tokens`, {
547
+ fetch(`${this.baseURL}/v1/routes/tokens`, {
460
548
  headers: { Accept: "application/json", "X-API-Key": cfg.apiKey }
461
549
  })
462
550
  ]);
@@ -465,58 +553,80 @@ var init_registry = __esm({
465
553
  const chains = await chainsRes.json();
466
554
  const tokens = await tokensRes.json();
467
555
  const chainsArr = Array.isArray(chains) ? chains : chains.data ?? [];
468
- for (const c of chainsArr) {
469
- const canonical = c?.chainId ?? c?.id;
556
+ for (const chain of chainsArr) {
557
+ const canonical = chain?.chainId ?? chain?.id;
470
558
  if (canonical == null) continue;
471
- const chainId = c.chainId ?? canonical;
472
559
  const normalized = {
473
- ...c,
474
- id: c.id ?? canonical,
475
- chainId
560
+ ...chain,
561
+ id: chain.id ?? canonical,
562
+ chainId: chain.chainId ?? canonical
476
563
  };
477
- this._chainsById.set(String(canonical), normalized);
564
+ const canonicalKey = normalizeChainKey(canonical);
565
+ this._chainsById.set(canonicalKey, normalized);
566
+ for (const alias of getChainAliases(normalized)) {
567
+ this._chainAliases.set(alias, canonicalKey);
568
+ }
478
569
  }
479
570
  const tokensArr = Array.isArray(tokens) ? tokens : tokens.data ?? [];
480
- for (const t of tokensArr) {
481
- const canonical = t?.chainId;
482
- if (canonical == null) continue;
483
- const id = String(canonical);
571
+ for (const token of tokensArr) {
572
+ const chainRef = token?.chainId;
573
+ if (chainRef == null) continue;
484
574
  const normalized = {
485
- ...t,
486
- chainId: t.chainId ?? canonical
575
+ ...token,
576
+ chainId: token.chainId ?? chainRef
487
577
  };
488
- if (!this._tokensByChain.has(id)) this._tokensByChain.set(id, []);
489
- this._tokensByChain.get(id).push(normalized);
578
+ const resolvedChain = this.chain(chainRef);
579
+ const aliases = resolvedChain ? getChainAliases(resolvedChain) : [normalizeChainKey(chainRef)];
580
+ for (const alias of aliases) {
581
+ this.storeToken(alias, normalized);
582
+ }
490
583
  }
491
584
  this._loaded = true;
492
585
  }
493
586
  chains() {
494
587
  return Array.from(this._chainsById.values());
495
588
  }
496
- chain(chainId) {
497
- return this._chainsById.get(String(chainId));
589
+ chain(chainRef) {
590
+ const normalized = normalizeChainKey(chainRef);
591
+ const canonicalKey = this._chainAliases.get(normalized) ?? normalized;
592
+ return this._chainsById.get(canonicalKey);
498
593
  }
499
594
  allTokens() {
500
- const all = [];
595
+ const unique = /* @__PURE__ */ new Map();
501
596
  for (const list of this._tokensByChain.values()) {
502
- all.push(...list);
597
+ for (const token of list) {
598
+ unique.set(`${token.chainId}:${token.address}`, token);
599
+ }
503
600
  }
504
- return all;
601
+ return Array.from(unique.values());
505
602
  }
506
- tokens(chainId) {
507
- return this._tokensByChain.get(String(chainId)) ?? [];
603
+ tokens(chainRef) {
604
+ return this._tokensByChain.get(normalizeChainKey(chainRef)) ?? [];
508
605
  }
509
- resolveToken(chainId, input) {
606
+ findToken(chainRef, address) {
607
+ const chain = this.chain(chainRef);
608
+ const chainType = normalizeChainType(chain);
609
+ const normalizedAddress = normalizeAddress(address, chainType);
610
+ return this.tokens(chainRef).find((token) => {
611
+ return normalizeAddress(token.address, chainType) === normalizedAddress;
612
+ });
613
+ }
614
+ resolveToken(chainRef, input) {
510
615
  if (!input) return void 0;
511
616
  const s = String(input).trim();
617
+ const chain = this.chain(chainRef);
618
+ const chainType = normalizeChainType(chain);
512
619
  if (/^0x[0-9a-fA-F]{40}$/.test(s)) return s;
513
- const chain = this.chain(chainId);
514
- const nativeSym = chain?.nativeCurrency?.symbol?.toUpperCase?.();
515
- if (nativeSym && s.toUpperCase() === nativeSym) return NATIVE;
516
- if (["ETH", "MATIC", "AVAX", "BNB", "NATIVE"].includes(s.toUpperCase()))
517
- return NATIVE;
518
- const list = this.tokens(chainId);
519
- const hit = list.find((t) => t.symbol?.toUpperCase?.() === s.toUpperCase());
620
+ if (chainType === "solana" && s.length > 20) return s;
621
+ const nativeAddress = getNativeTokenAddress(chainType);
622
+ const nativeSymbol = chain?.nativeCurrency?.symbol?.toUpperCase?.();
623
+ if (nativeSymbol && s.toUpperCase() === nativeSymbol || ["ETH", "MATIC", "AVAX", "BNB", "SOL", "NATIVE"].includes(s.toUpperCase())) {
624
+ return chainType === "solana" ? nativeAddress : NATIVE;
625
+ }
626
+ const hit = this.tokens(chainRef).find((token) => {
627
+ if (!token.symbol) return false;
628
+ return token.symbol.toUpperCase() === s.toUpperCase();
629
+ });
520
630
  if (hit) return hit.address;
521
631
  return s;
522
632
  }
@@ -633,6 +743,7 @@ __export(index_exports, {
633
743
  DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
634
744
  DEFAULT_SLIPPAGE: () => DEFAULT_SLIPPAGE2,
635
745
  DEFAULT_THEME: () => DEFAULT_THEME2,
746
+ IdentityStore: () => IdentityStore,
636
747
  RateLimitError: () => RateLimitError,
637
748
  SDK_NAME: () => SDK_NAME,
638
749
  SDK_VERSION: () => SDK_VERSION,
@@ -641,13 +752,23 @@ __export(index_exports, {
641
752
  TrustwareProvider: () => TrustwareProvider,
642
753
  TrustwareWidget: () => TrustwareWidgetV2,
643
754
  WALLETCONNECT_PROJECT_ID: () => WALLETCONNECT_PROJECT_ID,
755
+ buildWalletIdentityAddress: () => buildWalletIdentityAddress,
644
756
  connectDetectedWallet: () => connectDetectedWallet,
757
+ createWalletIdentity: () => createWalletIdentity,
758
+ resolveWalletAddressForChain: () => resolveWalletAddressForChain,
645
759
  toWalletInterfaceFromDetected: () => toWalletInterfaceFromDetected,
760
+ upsertWalletIdentityAddress: () => upsertWalletIdentityAddress,
646
761
  useEIP1193: () => useEIP1193,
647
762
  useTrustware: () => useTrustware,
648
763
  useWagmi: () => useWagmi,
649
764
  useWalletDetection: () => useWalletDetection,
650
- useWireDetectionIntoManager: () => useWireDetectionIntoManager
765
+ useWireDetectionIntoManager: () => useWireDetectionIntoManager,
766
+ validateAddressForChain: () => validateAddressForChain,
767
+ validateBtcAddress: () => validateBtcAddress,
768
+ validateEvmAddress: () => validateEvmAddress,
769
+ validateRouteAddresses: () => validateRouteAddresses,
770
+ validateSeiAddress: () => validateSeiAddress,
771
+ validateSolanaAddress: () => validateSolanaAddress
651
772
  });
652
773
  module.exports = __toCommonJS(index_exports);
653
774
 
@@ -691,6 +812,7 @@ function useEIP1193(eth) {
691
812
  if (!eth?.request) throw new Error("useEIP1193: invalid provider");
692
813
  let switching = false;
693
814
  return {
815
+ ecosystem: "evm",
694
816
  type: "eip1193",
695
817
  async getAddress() {
696
818
  const [a] = await eth.request({
@@ -712,12 +834,12 @@ function useEIP1193(eth) {
712
834
  method: "wallet_switchEthereumChain",
713
835
  params: [{ chainId: hex }]
714
836
  });
715
- } catch (e) {
716
- if (e?.code === 4902) {
837
+ } catch (e2) {
838
+ if (e2?.code === 4902) {
717
839
  await addThenSwitch(eth, chainId);
718
- } else if (e?.code === 4001) {
840
+ } else if (e2?.code === 4001) {
719
841
  } else {
720
- throw e;
842
+ throw e2;
721
843
  }
722
844
  } finally {
723
845
  switching = false;
@@ -762,11 +884,11 @@ function useWagmi(client) {
762
884
  method: "wallet_switchEthereumChain",
763
885
  params: [{ chainId: hex }]
764
886
  });
765
- } catch (e) {
766
- if (e?.code === 4902) await addThenSwitch(eth, target);
767
- else if (e?.code === 4001)
887
+ } catch (e2) {
888
+ if (e2?.code === 4902) await addThenSwitch(eth, target);
889
+ else if (e2?.code === 4001)
768
890
  ;
769
- else throw e;
891
+ else throw e2;
770
892
  }
771
893
  } finally {
772
894
  switching = false;
@@ -798,6 +920,7 @@ function useWagmi(client) {
798
920
  }
799
921
  }
800
922
  return {
923
+ ecosystem: "evm",
801
924
  type: "wagmi",
802
925
  getAddress,
803
926
  getChainId,
@@ -806,9 +929,123 @@ function useWagmi(client) {
806
929
  };
807
930
  }
808
931
 
932
+ // src/wallets/solana.ts
933
+ var import_web3 = require("@solana/web3.js");
934
+ var SOLANA_WALLET_IDS = [
935
+ "phantom-solana",
936
+ "solflare",
937
+ "backpack"
938
+ ];
939
+ function getPublicKeyString(provider) {
940
+ const publicKey = provider?.publicKey;
941
+ if (!publicKey) return null;
942
+ const text = publicKey.toString().trim();
943
+ return text || null;
944
+ }
945
+ function decodeBase64(serializedTransaction) {
946
+ const trimmed = serializedTransaction.trim();
947
+ if (typeof Buffer !== "undefined") {
948
+ return Uint8Array.from(Buffer.from(trimmed, "base64"));
949
+ }
950
+ const binary = globalThis.atob(trimmed);
951
+ return Uint8Array.from(binary, (char) => char.charCodeAt(0));
952
+ }
953
+ function decodeBase64Transaction(serializedTransaction) {
954
+ const bytes = decodeBase64(serializedTransaction);
955
+ try {
956
+ return import_web3.VersionedTransaction.deserialize(bytes);
957
+ } catch {
958
+ return import_web3.Transaction.from(bytes);
959
+ }
960
+ }
961
+ function getSolanaProviders() {
962
+ if (typeof window === "undefined") return {};
963
+ const win = window;
964
+ const providers = {};
965
+ const phantom = win.phantom?.solana ?? (win.solana?.isPhantom ? win.solana : void 0);
966
+ const solflare = win.solflare ?? (win.solana?.isSolflare ? win.solana : void 0);
967
+ const backpack = win.backpack?.solana ?? (win.solana?.isBackpack ? win.solana : void 0);
968
+ if (phantom) providers["phantom-solana"] = phantom;
969
+ if (solflare) providers.solflare = solflare;
970
+ if (backpack) providers.backpack = backpack;
971
+ return providers;
972
+ }
973
+ function detectSolanaWallets(wallets) {
974
+ const providers = getSolanaProviders();
975
+ return SOLANA_WALLET_IDS.flatMap((walletId) => {
976
+ const provider = providers[walletId];
977
+ const meta = wallets.find((item) => item.id === walletId);
978
+ if (!provider || !meta) return [];
979
+ return [{ meta, provider, via: "solana-window" }];
980
+ });
981
+ }
982
+ function bindSolanaProviderEvents(provider, handlers) {
983
+ const onConnect = () => handlers.onConnect?.();
984
+ const onAccountChanged = () => handlers.onAccountChanged?.();
985
+ const onDisconnect = () => handlers.onDisconnect?.();
986
+ provider.on?.("connect", onConnect);
987
+ provider.on?.("accountChanged", onAccountChanged);
988
+ provider.on?.("disconnect", onDisconnect);
989
+ return () => {
990
+ provider.off?.("connect", onConnect);
991
+ provider.off?.("accountChanged", onAccountChanged);
992
+ provider.off?.("disconnect", onDisconnect);
993
+ provider.removeListener?.("connect", onConnect);
994
+ provider.removeListener?.("accountChanged", onAccountChanged);
995
+ provider.removeListener?.("disconnect", onDisconnect);
996
+ };
997
+ }
998
+ function toSolanaWalletInterface(provider) {
999
+ return {
1000
+ ecosystem: "solana",
1001
+ type: "solana",
1002
+ async getAddress() {
1003
+ const current = getPublicKeyString(provider);
1004
+ if (current) return current;
1005
+ if (!provider.connect) {
1006
+ throw new Error("Selected Solana wallet cannot connect");
1007
+ }
1008
+ await provider.connect();
1009
+ const next = getPublicKeyString(provider);
1010
+ if (!next) throw new Error("No connected Solana address");
1011
+ return next;
1012
+ },
1013
+ async disconnect() {
1014
+ await provider.disconnect?.();
1015
+ },
1016
+ async getChainKey() {
1017
+ return "solana-mainnet-beta";
1018
+ },
1019
+ async sendSerializedTransaction(serializedTransactionBase64, rpcUrl) {
1020
+ const transaction = decodeBase64Transaction(serializedTransactionBase64);
1021
+ if (provider.signAndSendTransaction) {
1022
+ const result = await provider.signAndSendTransaction(transaction, {
1023
+ preflightCommitment: "confirmed"
1024
+ });
1025
+ if (typeof result === "string") return result;
1026
+ if (result?.signature) return result.signature;
1027
+ }
1028
+ if (!provider.signTransaction) {
1029
+ throw new Error("Connected Solana wallet cannot sign transactions");
1030
+ }
1031
+ const signed = await provider.signTransaction(transaction);
1032
+ const connection = new import_web3.Connection(
1033
+ rpcUrl?.trim() || "https://api.mainnet-beta.solana.com",
1034
+ "confirmed"
1035
+ );
1036
+ const signature = await connection.sendRawTransaction(signed.serialize());
1037
+ await connection.confirmTransaction(signature, "confirmed");
1038
+ return signature;
1039
+ }
1040
+ };
1041
+ }
1042
+
809
1043
  // src/wallets/adapters.ts
810
1044
  function toWalletInterfaceFromDetected(dw) {
811
1045
  if (!dw?.provider) throw new Error("No provider on detected wallet");
1046
+ if (dw.via === "solana-window" || dw.meta.ecosystem === "solana") {
1047
+ return toSolanaWalletInterface(dw.provider);
1048
+ }
812
1049
  const eth = dw.provider;
813
1050
  return useEIP1193(eth);
814
1051
  }
@@ -836,6 +1073,11 @@ async function connectDetectedWallet(dw, opts) {
836
1073
  }
837
1074
  throw new Error("WalletConnect connection failed. Please try again.");
838
1075
  }
1076
+ if (dw.via === "solana-window" || dw.meta.ecosystem === "solana") {
1077
+ const api2 = toWalletInterfaceFromDetected(dw);
1078
+ if (touchAddress) await api2.getAddress();
1079
+ return { via: "eip1193", api: api2 };
1080
+ }
839
1081
  if (wagmi) {
840
1082
  const conn = pickWagmiConnector(
841
1083
  wagmi,
@@ -878,6 +1120,7 @@ var WALLETS = [
878
1120
  id: "metamask",
879
1121
  name: "MetaMask",
880
1122
  category: "injected",
1123
+ ecosystem: "evm",
881
1124
  logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
882
1125
  emoji: "\u{1F98A}",
883
1126
  homepage: "https://metamask.io/",
@@ -885,20 +1128,11 @@ var WALLETS = [
885
1128
  detectFlags: ["isMetaMask"],
886
1129
  deepLink: (url) => formatDeepLink("metamask", url) ?? ""
887
1130
  },
888
- {
889
- id: "rabby",
890
- name: "Rabby",
891
- category: "injected",
892
- logo: `${ASSETS_BASE_URL}/assets/wallets/rabby.svg`,
893
- emoji: "\u{1F430}",
894
- homepage: "https://rabby.io/",
895
- chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
896
- detectFlags: ["isRabby"]
897
- },
898
1131
  {
899
1132
  id: "coinbase",
900
1133
  name: "Coinbase Wallet",
901
1134
  category: "app",
1135
+ ecosystem: "evm",
902
1136
  logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
903
1137
  emoji: "\u{1F7E6}",
904
1138
  homepage: "https://www.coinbase.com/wallet",
@@ -909,6 +1143,7 @@ var WALLETS = [
909
1143
  id: "walletconnect",
910
1144
  name: "WalletConnect",
911
1145
  category: "walletconnect",
1146
+ ecosystem: "multi",
912
1147
  logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
913
1148
  emoji: "\u{1FA9D}",
914
1149
  homepage: "https://walletconnect.com/"
@@ -917,6 +1152,7 @@ var WALLETS = [
917
1152
  id: "rainbow",
918
1153
  name: "Rainbow",
919
1154
  category: "app",
1155
+ ecosystem: "evm",
920
1156
  logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
921
1157
  emoji: "\u{1F308}",
922
1158
  homepage: "https://rainbow.me/",
@@ -924,27 +1160,82 @@ var WALLETS = [
924
1160
  detectFlags: ["isRainbow"]
925
1161
  },
926
1162
  {
927
- id: "okx",
928
- name: "OKX",
1163
+ id: "phantom-evm",
1164
+ name: "Phantom (EVM)",
929
1165
  category: "injected",
930
- logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
931
- emoji: "\u2B1B",
932
- homepage: "https://www.okx.com/web3",
933
- detectFlags: ["isOkxWallet"]
1166
+ ecosystem: "evm",
1167
+ logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
1168
+ emoji: "\u{1F47B}",
1169
+ homepage: "https://phantom.app/",
1170
+ detectFlags: ["isPhantom"]
1171
+ },
1172
+ {
1173
+ id: "phantom-solana",
1174
+ name: "Phantom (Solana)",
1175
+ category: "injected",
1176
+ ecosystem: "solana",
1177
+ logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
1178
+ emoji: "\u{1F47B}",
1179
+ homepage: "https://phantom.app/",
1180
+ android: "https://play.google.com/store/apps/details?id=app.phantom",
1181
+ ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
1182
+ deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
1183
+ },
1184
+ {
1185
+ id: "solflare",
1186
+ name: "Solflare",
1187
+ category: "injected",
1188
+ ecosystem: "solana",
1189
+ logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
1190
+ emoji: "\u2600\uFE0F",
1191
+ homepage: "https://solflare.com/",
1192
+ deepLink: (url) => `solflare://ul/v1/browse/${encodeURIComponent(url)}`
1193
+ },
1194
+ {
1195
+ id: "backpack",
1196
+ name: "Backpack",
1197
+ category: "injected",
1198
+ ecosystem: "solana",
1199
+ logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
1200
+ emoji: "\u{1F392}",
1201
+ homepage: "https://backpack.app/"
1202
+ },
1203
+ {
1204
+ id: "rabby",
1205
+ name: "Rabby",
1206
+ category: "injected",
1207
+ ecosystem: "evm",
1208
+ logo: `${ASSETS_BASE_URL}/assets/wallets/rabby.svg`,
1209
+ emoji: "\u{1F430}",
1210
+ homepage: "https://rabby.io/",
1211
+ chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
1212
+ detectFlags: ["isRabby"]
934
1213
  },
935
1214
  {
936
1215
  id: "brave",
937
1216
  name: "Brave Wallet",
938
1217
  category: "injected",
1218
+ ecosystem: "evm",
939
1219
  logo: `${ASSETS_BASE_URL}/assets/wallets/brave.svg`,
940
1220
  emoji: "\u{1F981}",
941
1221
  homepage: "https://brave.com/wallet/",
942
1222
  detectFlags: ["isBraveWallet"]
943
1223
  },
1224
+ {
1225
+ id: "okx",
1226
+ name: "OKX",
1227
+ category: "injected",
1228
+ ecosystem: "evm",
1229
+ logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
1230
+ emoji: "\u2B1B",
1231
+ homepage: "https://www.okx.com/web3",
1232
+ detectFlags: ["isOkxWallet"]
1233
+ },
944
1234
  {
945
1235
  id: "zerion",
946
1236
  name: "Zerion",
947
1237
  category: "app",
1238
+ ecosystem: "evm",
948
1239
  logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
949
1240
  emoji: "\u{1F9FF}",
950
1241
  homepage: "https://zerion.io/wallet/"
@@ -953,6 +1244,7 @@ var WALLETS = [
953
1244
  id: "taho",
954
1245
  name: "Taho",
955
1246
  category: "injected",
1247
+ ecosystem: "evm",
956
1248
  logo: `${ASSETS_BASE_URL}/assets/wallets/taho.png`,
957
1249
  emoji: "\u{1F7EA}",
958
1250
  homepage: "https://taho.xyz/",
@@ -962,6 +1254,7 @@ var WALLETS = [
962
1254
  id: "trust",
963
1255
  name: "Trust Wallet",
964
1256
  category: "app",
1257
+ ecosystem: "multi",
965
1258
  logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
966
1259
  emoji: "\u{1F6E1}\uFE0F",
967
1260
  homepage: "https://trustwallet.com/",
@@ -971,24 +1264,17 @@ var WALLETS = [
971
1264
  id: "bitget",
972
1265
  name: "Bitget Wallet",
973
1266
  category: "injected",
1267
+ ecosystem: "evm",
974
1268
  logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
975
1269
  emoji: "\u{1F7E9}",
976
1270
  homepage: "https://web3.bitget.com/",
977
1271
  detectFlags: ["isBitGetWallet"]
978
1272
  },
979
- {
980
- id: "phantom-evm",
981
- name: "Phantom (EVM)",
982
- category: "injected",
983
- logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
984
- emoji: "\u{1F47B}",
985
- homepage: "https://phantom.app/",
986
- detectFlags: ["isPhantom"]
987
- },
988
1273
  {
989
1274
  id: "safe",
990
1275
  name: "Safe",
991
1276
  category: "app",
1277
+ ecosystem: "evm",
992
1278
  logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
993
1279
  emoji: "\u{1F7E9}",
994
1280
  homepage: "https://safe.global/"
@@ -997,6 +1283,7 @@ var WALLETS = [
997
1283
  id: "kucoin",
998
1284
  name: "KuCoin Wallet",
999
1285
  category: "app",
1286
+ ecosystem: "evm",
1000
1287
  logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
1001
1288
  emoji: "\u{1F7E6}",
1002
1289
  homepage: "https://www.kucoin.com/"
@@ -1077,6 +1364,7 @@ function createGenericWalletMeta(name) {
1077
1364
  id: rawId,
1078
1365
  name,
1079
1366
  category: "injected",
1367
+ ecosystem: "evm",
1080
1368
  logo: "",
1081
1369
  emoji: "\u{1F45B}"
1082
1370
  };
@@ -1147,8 +1435,8 @@ function useWalletDetection(timeoutMs = 400) {
1147
1435
  const w = window;
1148
1436
  const announced = [];
1149
1437
  const providerDetailMap = /* @__PURE__ */ new Map();
1150
- const onAnnounce = (e) => {
1151
- const ce = e;
1438
+ const onAnnounce = (e2) => {
1439
+ const ce = e2;
1152
1440
  if (ce?.detail?.provider?.request) {
1153
1441
  const detail = {
1154
1442
  info: ce.detail.info,
@@ -1190,6 +1478,11 @@ function useWalletDetection(timeoutMs = 400) {
1190
1478
  out.push(wallet);
1191
1479
  }
1192
1480
  }
1481
+ for (const wallet of detectSolanaWallets(WALLETS)) {
1482
+ if (seenIds.has(wallet.meta.id)) continue;
1483
+ seenIds.add(wallet.meta.id);
1484
+ out.push(wallet);
1485
+ }
1193
1486
  setDetected(rankDetected(out));
1194
1487
  w.removeEventListener?.("eip6963:announceProvider", onAnnounce);
1195
1488
  done = true;
@@ -1206,6 +1499,1114 @@ function useWalletDetection(timeoutMs = 400) {
1206
1499
  return { detected, detectedIds };
1207
1500
  }
1208
1501
 
1502
+ // src/validation/address.ts
1503
+ var import_viem = require("viem");
1504
+
1505
+ // node_modules/@solana/errors/dist/index.node.mjs
1506
+ var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
1507
+ var SOLANA_ERROR__INVALID_NONCE = 2;
1508
+ var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 3;
1509
+ var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 4;
1510
+ var SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = 5;
1511
+ var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 6;
1512
+ var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 7;
1513
+ var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 8;
1514
+ var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 9;
1515
+ var SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR = 10;
1516
+ var SOLANA_ERROR__JSON_RPC__PARSE_ERROR = -32700;
1517
+ var SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = -32603;
1518
+ var SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = -32602;
1519
+ var SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND = -32601;
1520
+ var SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = -32600;
1521
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE = -32019;
1522
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_NOT_EPOCH_BOUNDARY = -32018;
1523
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_EPOCH_REWARDS_PERIOD_ACTIVE = -32017;
1524
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
1525
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION = -32015;
1526
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET = -32014;
1527
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH = -32013;
1528
+ var SOLANA_ERROR__JSON_RPC__SCAN_ERROR = -32012;
1529
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE = -32011;
1530
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX = -32010;
1531
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED = -32009;
1532
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT = -32008;
1533
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED = -32007;
1534
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE = -32006;
1535
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY = -32005;
1536
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE = -32004;
1537
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE = -32003;
1538
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE = -32002;
1539
+ var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP = -32001;
1540
+ var SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH = 28e5;
1541
+ var SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE = 2800001;
1542
+ var SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS = 2800002;
1543
+ var SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY = 2800003;
1544
+ var SOLANA_ERROR__ADDRESSES__MALFORMED_PDA = 2800004;
1545
+ var SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE = 2800005;
1546
+ var SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED = 2800006;
1547
+ var SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED = 2800007;
1548
+ var SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE = 2800008;
1549
+ var SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED = 2800009;
1550
+ var SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER = 2800010;
1551
+ var SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS = 2800011;
1552
+ var SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = 323e4;
1553
+ var SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND = 32300001;
1554
+ var SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT = 3230002;
1555
+ var SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = 3230003;
1556
+ var SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = 3230004;
1557
+ var SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = 361e4;
1558
+ var SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = 3610001;
1559
+ var SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = 3610002;
1560
+ var SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED = 3610003;
1561
+ var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
1562
+ var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
1563
+ var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
1564
+ var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
1565
+ var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
1566
+ var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
1567
+ var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
1568
+ var SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH = 3704002;
1569
+ var SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704003;
1570
+ var SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY = 3704004;
1571
+ var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
1572
+ var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA = 4128001;
1573
+ var SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH = 4128002;
1574
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN = 4615e3;
1575
+ var SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR = 4615001;
1576
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT = 4615002;
1577
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA = 4615003;
1578
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA = 4615004;
1579
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL = 4615005;
1580
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS = 4615006;
1581
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID = 4615007;
1582
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE = 4615008;
1583
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED = 4615009;
1584
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT = 4615010;
1585
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION = 4615011;
1586
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID = 4615012;
1587
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
1588
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
1589
+ var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE = 4615015;
1590
+ var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED = 4615016;
1591
+ var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX = 4615017;
1592
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED = 4615018;
1593
+ var SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED = 4615019;
1594
+ var SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
1595
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED = 4615021;
1596
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE = 4615022;
1597
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED = 4615023;
1598
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 4615024;
1599
+ var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
1600
+ var SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM = 4615026;
1601
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR = 4615027;
1602
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED = 4615028;
1603
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE = 4615029;
1604
+ var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
1605
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID = 4615031;
1606
+ var SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH = 4615032;
1607
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT = 4615033;
1608
+ var SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED = 4615034;
1609
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4615035;
1610
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS = 4615036;
1611
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC = 4615037;
1612
+ var SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
1613
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION = 4615039;
1614
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
1615
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE = 4615041;
1616
+ var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE = 4615042;
1617
+ var SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE = 4615043;
1618
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY = 4615044;
1619
+ var SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR = 4615045;
1620
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT = 4615046;
1621
+ var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER = 4615047;
1622
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW = 4615048;
1623
+ var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR = 4615049;
1624
+ var SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER = 4615050;
1625
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
1626
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED = 4615052;
1627
+ var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
1628
+ var SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
1629
+ var SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
1630
+ var SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER = 5508001;
1631
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER = 5508002;
1632
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
1633
+ var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
1634
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER = 5508005;
1635
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
1636
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
1637
+ var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
1638
+ var SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
1639
+ var SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
1640
+ var SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = 5508011;
1641
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED = 5607e3;
1642
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE = 5607001;
1643
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__APPLICATION_DOMAIN_STRING_LENGTH_OUT_OF_RANGE = 5607002;
1644
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__INVALID_APPLICATION_DOMAIN_BYTE_LENGTH = 5607003;
1645
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH = 5607004;
1646
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO = 5607005;
1647
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED = 5607006;
1648
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH = 5607007;
1649
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_LENGTH_MISMATCH = 5607008;
1650
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY = 5607009;
1651
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO = 5607010;
1652
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING = 5607011;
1653
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__ENVELOPE_SIGNERS_MISMATCH = 5607012;
1654
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__ADDRESSES_CANNOT_SIGN_OFFCHAIN_MESSAGE = 5607013;
1655
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION = 5607014;
1656
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED = 5607015;
1657
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE = 5607016;
1658
+ var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE = 5607017;
1659
+ var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
1660
+ var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
1661
+ var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
1662
+ var SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = 5663003;
1663
+ var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = 5663004;
1664
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663005;
1665
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663006;
1666
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663007;
1667
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663008;
1668
+ var SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = 5663009;
1669
+ var SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = 5663010;
1670
+ var SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = 5663011;
1671
+ var SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = 5663012;
1672
+ var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = 5663013;
1673
+ var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = 5663014;
1674
+ var SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = 5663015;
1675
+ var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
1676
+ var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
1677
+ var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
1678
+ var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
1679
+ var SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = 5663020;
1680
+ var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED = 5663021;
1681
+ var SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE = 5663022;
1682
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
1683
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
1684
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
1685
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND = 7050003;
1686
+ var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
1687
+ var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
1688
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE = 7050006;
1689
+ var SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED = 7050007;
1690
+ var SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND = 7050008;
1691
+ var SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP = 7050009;
1692
+ var SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE = 7050010;
1693
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX = 7050011;
1694
+ var SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE = 7050012;
1695
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION = 7050013;
1696
+ var SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE = 7050014;
1697
+ var SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE = 7050015;
1698
+ var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 7050016;
1699
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
1700
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION = 7050018;
1701
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT = 7050019;
1702
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
1703
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
1704
+ var SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS = 7050022;
1705
+ var SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
1706
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
1707
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
1708
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
1709
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT = 7050027;
1710
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
1711
+ var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
1712
+ var SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION = 7050030;
1713
+ var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
1714
+ var SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
1715
+ var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
1716
+ var SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED = 7050034;
1717
+ var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
1718
+ var SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION = 7050036;
1719
+ var SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN = 7618e3;
1720
+ var SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE = 7618001;
1721
+ var SOLANA_ERROR__INSTRUCTION_PLANS__EMPTY_INSTRUCTION_PLAN = 7618002;
1722
+ var SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN = 7618003;
1723
+ var SOLANA_ERROR__INSTRUCTION_PLANS__NON_DIVISIBLE_TRANSACTION_PLANS_NOT_SUPPORTED = 7618004;
1724
+ var SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_SINGLE_TRANSACTION_PLAN_RESULT_NOT_FOUND = 7618005;
1725
+ var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_INSTRUCTION_PLAN = 7618006;
1726
+ var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN = 7618007;
1727
+ var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN_RESULT = 7618008;
1728
+ var SOLANA_ERROR__INSTRUCTION_PLANS__EXPECTED_SUCCESSFUL_TRANSACTION_PLAN_RESULT = 7618009;
1729
+ var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
1730
+ var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
1731
+ var SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH = 8078002;
1732
+ var SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH = 8078003;
1733
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
1734
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
1735
+ var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
1736
+ var SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = 8078007;
1737
+ var SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
1738
+ var SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT = 8078009;
1739
+ var SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT = 8078010;
1740
+ var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
1741
+ var SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = 8078012;
1742
+ var SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH = 8078013;
1743
+ var SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE = 8078014;
1744
+ var SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT = 8078015;
1745
+ var SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = 8078016;
1746
+ var SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE = 8078017;
1747
+ var SOLANA_ERROR__CODECS__INVALID_CONSTANT = 8078018;
1748
+ var SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE = 8078019;
1749
+ var SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL = 8078020;
1750
+ var SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = 8078021;
1751
+ var SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS = 8078022;
1752
+ var SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY = 8078023;
1753
+ var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
1754
+ var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
1755
+ var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
1756
+ var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
1757
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
1758
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
1759
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
1760
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
1761
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
1762
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
1763
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
1764
+ var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
1765
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
1766
+ var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
1767
+ var SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_INSTRUCTION_PLAN_KIND = 9900005;
1768
+ var SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_TRANSACTION_PLAN_KIND = 9900006;
1769
+ function encodeValue(value) {
1770
+ if (Array.isArray(value)) {
1771
+ const commaSeparatedValues = value.map(encodeValue).join(
1772
+ "%2C%20"
1773
+ /* ", " */
1774
+ );
1775
+ return "%5B" + commaSeparatedValues + /* "]" */
1776
+ "%5D";
1777
+ } else if (typeof value === "bigint") {
1778
+ return `${value}n`;
1779
+ } else {
1780
+ return encodeURIComponent(
1781
+ String(
1782
+ value != null && Object.getPrototypeOf(value) === null ? (
1783
+ // Plain objects with no prototype don't have a `toString` method.
1784
+ // Convert them before stringifying them.
1785
+ { ...value }
1786
+ ) : value
1787
+ )
1788
+ );
1789
+ }
1790
+ }
1791
+ function encodeObjectContextEntry([key, value]) {
1792
+ return `${key}=${encodeValue(value)}`;
1793
+ }
1794
+ function encodeContextObject(context) {
1795
+ const searchParamsString = Object.entries(context).map(encodeObjectContextEntry).join("&");
1796
+ return Buffer.from(searchParamsString, "utf8").toString("base64");
1797
+ }
1798
+ var SolanaErrorMessages = {
1799
+ [SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
1800
+ [SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
1801
+ [SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT]: "Expected decoded account at address: $address",
1802
+ [SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT]: "Failed to decode account data at address: $address",
1803
+ [SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND]: "Accounts not found at addresses: $addresses",
1804
+ [SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED]: "Unable to find a viable program address bump seed.",
1805
+ [SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS]: "$putativeAddress is not a base58-encoded address.",
1806
+ [SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
1807
+ [SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY]: "The `CryptoKey` must be an `Ed25519` public key.",
1808
+ [SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS]: "$putativeOffCurveAddress is not a base58-encoded off-curve address.",
1809
+ [SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE]: "Invalid seeds; point must fall off the Ed25519 curve.",
1810
+ [SOLANA_ERROR__ADDRESSES__MALFORMED_PDA]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
1811
+ [SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED]: "A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",
1812
+ [SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
1813
+ [SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
1814
+ [SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER]: "Program address cannot end with PDA marker.",
1815
+ [SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
1816
+ [SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
1817
+ [SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
1818
+ [SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY]: "Codec [$codecDescription] cannot decode empty byte arrays.",
1819
+ [SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS]: "Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",
1820
+ [SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL]: "Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",
1821
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
1822
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
1823
+ [SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH]: "Encoder and decoder must either both be fixed-size or variable-size.",
1824
+ [SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE]: "Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",
1825
+ [SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH]: "Expected a fixed-size codec, got a variable-size one.",
1826
+ [SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH]: "Codec [$codecDescription] expected a positive byte length, got $bytesLength.",
1827
+ [SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH]: "Expected a variable-size codec, got a fixed-size one.",
1828
+ [SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE]: "Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",
1829
+ [SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
1830
+ [SOLANA_ERROR__CODECS__INVALID_CONSTANT]: "Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",
1831
+ [SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT]: "Invalid discriminated union variant. Expected one of [$variants], got $value.",
1832
+ [SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT]: "Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",
1833
+ [SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT]: "Invalid literal union variant. Expected one of [$variants], got $value.",
1834
+ [SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS]: "Expected [$codecDescription] to have $expected items, got $actual.",
1835
+ [SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE]: "Invalid value $value for base $base with alphabet $alphabet.",
1836
+ [SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE]: "Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
1837
+ [SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
1838
+ [SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE]: "Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",
1839
+ [SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
1840
+ [SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
1841
+ [SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY]: "This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",
1842
+ [SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED]: "No random values implementation could be found.",
1843
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
1844
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
1845
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
1846
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED]: "program other than the account's owner changed the size of the account data",
1847
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL]: "account data too small for instruction",
1848
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE]: "instruction expected an executable account",
1849
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT]: "An account does not have enough lamports to be rent-exempt",
1850
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW]: "Program arithmetic overflowed",
1851
+ [SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR]: "Failed to serialize or deserialize account data: $encodedData",
1852
+ [SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS]: "Builtin programs must consume compute units",
1853
+ [SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH]: "Cross-program invocation call depth too deep",
1854
+ [SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED]: "Computational budget exceeded",
1855
+ [SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM]: "custom program error: #$code",
1856
+ [SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX]: "instruction contains duplicate accounts",
1857
+ [SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC]: "instruction modifications of multiply-passed account differ",
1858
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT]: "executable accounts must be rent exempt",
1859
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED]: "instruction changed executable accounts data",
1860
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE]: "instruction changed the balance of an executable account",
1861
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED]: "instruction changed executable bit of an account",
1862
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED]: "instruction modified data of an account it does not own",
1863
+ [SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND]: "instruction spent from the balance of an account it does not own",
1864
+ [SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR]: "generic instruction error",
1865
+ [SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER]: "Provided owner is not allowed",
1866
+ [SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE]: "Account is immutable",
1867
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY]: "Incorrect authority provided",
1868
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID]: "incorrect program id for instruction",
1869
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS]: "insufficient funds for instruction",
1870
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA]: "invalid account data for instruction",
1871
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER]: "Invalid account owner",
1872
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT]: "invalid program argument",
1873
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR]: "program returned invalid error code",
1874
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA]: "invalid instruction data",
1875
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC]: "Failed to reallocate account data",
1876
+ [SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS]: "Provided seeds do not result in a valid address",
1877
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED]: "Accounts data allocations exceeded the maximum allowed per transaction",
1878
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED]: "Max accounts exceeded",
1879
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED]: "Max instruction trace length exceeded",
1880
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED]: "Length of the seed is too long for address generation",
1881
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT]: "An account required by the instruction is missing",
1882
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE]: "missing required signature for instruction",
1883
+ [SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID]: "instruction illegally modified the program id of an account",
1884
+ [SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: "insufficient account keys for instruction",
1885
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION]: "Cross-program invocation with unauthorized signer or writable account",
1886
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE]: "Failed to create program execution environment",
1887
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE]: "Program failed to compile",
1888
+ [SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE]: "Program failed to complete",
1889
+ [SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED]: "instruction modified data of a read-only account",
1890
+ [SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE]: "instruction changed the balance of a read-only account",
1891
+ [SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED]: "Cross-program invocation reentrancy not allowed for this instruction",
1892
+ [SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED]: "instruction modified rent epoch of an account",
1893
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION]: "sum of account balances before and after instruction do not match",
1894
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT]: "instruction requires an initialized account",
1895
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN]: "",
1896
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
1897
+ [SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
1898
+ [SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_INSTRUCTION_PLAN_KIND]: "Invalid instruction plan kind: $kind.",
1899
+ [SOLANA_ERROR__INSTRUCTION_PLANS__EMPTY_INSTRUCTION_PLAN]: "The provided instruction plan is empty.",
1900
+ [SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_SINGLE_TRANSACTION_PLAN_RESULT_NOT_FOUND]: "No failed transaction plan result was found in the provided transaction plan result.",
1901
+ [SOLANA_ERROR__INSTRUCTION_PLANS__NON_DIVISIBLE_TRANSACTION_PLANS_NOT_SUPPORTED]: "This transaction plan executor does not support non-divisible sequential plans. To support them, you may create your own executor such that multi-transaction atomicity is preserved \u2014 e.g. by targetting RPCs that support transaction bundles.",
1902
+ [SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN]: "The provided transaction plan failed to execute. See the `transactionPlanResult` attribute for more details. Note that the `cause` property is deprecated, and a future version will not set it.",
1903
+ [SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN]: "The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",
1904
+ [SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_TRANSACTION_PLAN_KIND]: "Invalid transaction plan kind: $kind.",
1905
+ [SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE]: "No more instructions to pack; the message packer has completed the instruction plan.",
1906
+ [SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_INSTRUCTION_PLAN]: "Unexpected instruction plan. Expected $expectedKind plan, got $actualKind plan.",
1907
+ [SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN]: "Unexpected transaction plan. Expected $expectedKind plan, got $actualKind plan.",
1908
+ [SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN_RESULT]: "Unexpected transaction plan result. Expected $expectedKind plan, got $actualKind plan.",
1909
+ [SOLANA_ERROR__INSTRUCTION_PLANS__EXPECTED_SUCCESSFUL_TRANSACTION_PLAN_RESULT]: "Expected a successful transaction plan result. I.e. there is at least one failed or cancelled transaction in the plan.",
1910
+ [SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS]: "The instruction does not have any accounts.",
1911
+ [SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA]: "The instruction does not have any data.",
1912
+ [SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
1913
+ [SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
1914
+ [SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
1915
+ [SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING]: "Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
1916
+ [SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED]: "Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",
1917
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
1918
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
1919
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE]: "Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
1920
+ [SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
1921
+ [SOLANA_ERROR__JSON_RPC__INVALID_PARAMS]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
1922
+ [SOLANA_ERROR__JSON_RPC__INVALID_REQUEST]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
1923
+ [SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND]: "JSON-RPC error: The method does not exist / is not available ($__serverMessage)",
1924
+ [SOLANA_ERROR__JSON_RPC__PARSE_ERROR]: "JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",
1925
+ [SOLANA_ERROR__JSON_RPC__SCAN_ERROR]: "$__serverMessage",
1926
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP]: "$__serverMessage",
1927
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE]: "$__serverMessage",
1928
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET]: "$__serverMessage",
1929
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_EPOCH_REWARDS_PERIOD_ACTIVE]: "Epoch rewards period still active at slot $slot",
1930
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX]: "$__serverMessage",
1931
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED]: "$__serverMessage",
1932
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE]: "Failed to query long-term storage; please try again",
1933
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED]: "Minimum context slot has not been reached",
1934
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY]: "Node is unhealthy; behind by $numSlotsBehind slots",
1935
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT]: "No snapshot",
1936
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE]: "Transaction simulation failed",
1937
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_NOT_EPOCH_BOUNDARY]: "Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",
1938
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED]: "$__serverMessage",
1939
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE]: "Transaction history is not available from this node",
1940
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE]: "$__serverMessage",
1941
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH]: "Transaction signature length mismatch",
1942
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE]: "Transaction signature verification failure",
1943
+ [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION]: "$__serverMessage",
1944
+ [SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH]: "Key pair bytes must be of length 64, got $byteLength.",
1945
+ [SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH]: "Expected private key bytes with length 32. Actual length: $actualLength.",
1946
+ [SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
1947
+ [SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY]: "The provided private key does not match the provided public key.",
1948
+ [SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
1949
+ [SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE]: "Lamports value must be in the range [0, 2e64-1]",
1950
+ [SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
1951
+ [SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR]: "$message",
1952
+ [SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
1953
+ [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
1954
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__INVALID_APPLICATION_DOMAIN_BYTE_LENGTH]: "Expected base58 encoded application domain to decode to a byte array of length 32. Actual length: $actualLength.",
1955
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__ADDRESSES_CANNOT_SIGN_OFFCHAIN_MESSAGE]: "Attempted to sign an offchain message with an address that is not a signer for it",
1956
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__APPLICATION_DOMAIN_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded application domain string of length in the range [32, 44]. Actual length: $actualLength.",
1957
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__ENVELOPE_SIGNERS_MISMATCH]: "The signer addresses in this offchain message envelope do not match the list of required signers in the message preamble. These unexpected signers were present in the envelope: `[$unexpectedSigners]`. These required signers were missing from the envelope `[$missingSigners]`.",
1958
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED]: "The message body provided has a byte-length of $actualBytes. The maximum allowable byte-length is $maxBytes",
1959
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH]: "Expected message format $expectedMessageFormat, got $actualMessageFormat",
1960
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_LENGTH_MISMATCH]: "The message length specified in the message preamble is $specifiedLength bytes. The actual length of the message is $actualLength bytes.",
1961
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY]: "Offchain message content must be non-empty",
1962
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO]: "Offchain message must specify the address of at least one required signer",
1963
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO]: "Offchain message envelope must reserve space for at least one signature",
1964
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH]: "The offchain message preamble specifies $numRequiredSignatures required signature(s), got $signaturesLength.",
1965
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED]: "The signatories of this offchain message must be listed in lexicographical order",
1966
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE]: "An address must be listed no more than once among the signatories of an offchain message",
1967
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING]: "Offchain message is missing signatures for addresses: $addresses.",
1968
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE]: "Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",
1969
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE]: "The message body provided contains characters whose codes fall outside the allowed range. In order to ensure clear-signing compatiblity with hardware wallets, the message may only contain line feeds and characters in the range [\\x20-\\x7e].",
1970
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION]: "Expected offchain message version $expectedVersion. Got $actualVersion.",
1971
+ [SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED]: "This version of Kit does not support decoding offchain messages with version $unsupportedVersion. The current max supported version is 0.",
1972
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN]: "The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",
1973
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
1974
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED]: "WebSocket connection closed",
1975
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT]: "WebSocket failed to connect",
1976
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
1977
+ [SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD]: "Could not find an API plan for RPC method: `$method`",
1978
+ [SOLANA_ERROR__RPC__INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
1979
+ [SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
1980
+ [SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
1981
+ [SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS]: "Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",
1982
+ [SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER]: "The provided value does not implement the `KeyPairSigner` interface",
1983
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER]: "The provided value does not implement the `MessageModifyingSigner` interface",
1984
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER]: "The provided value does not implement the `MessagePartialSigner` interface",
1985
+ [SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER]: "The provided value does not implement any of the `MessageSigner` interfaces",
1986
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER]: "The provided value does not implement the `TransactionModifyingSigner` interface",
1987
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER]: "The provided value does not implement the `TransactionPartialSigner` interface",
1988
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER]: "The provided value does not implement the `TransactionSendingSigner` interface",
1989
+ [SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER]: "The provided value does not implement any of the `TransactionSigner` interfaces",
1990
+ [SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
1991
+ [SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",
1992
+ [SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
1993
+ [SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
1994
+ [SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
1995
+ [SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
1996
+ [SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",
1997
+ [SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED]: "No signature verification implementation could be found.",
1998
+ [SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
1999
+ [SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
2000
+ [SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
2001
+ [SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
2002
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
2003
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
2004
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
2005
+ [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
2006
+ [SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
2007
+ [SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED]: "This transaction has already been processed",
2008
+ [SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND]: "Blockhash not found",
2009
+ [SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
2010
+ [SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
2011
+ [SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
2012
+ [SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
2013
+ [SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
2014
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
2015
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
2016
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
2017
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
2018
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
2019
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
2020
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
2021
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
2022
+ [SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
2023
+ [SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
2024
+ [SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
2025
+ [SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
2026
+ [SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
2027
+ [SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED]: "ResanitizationNeeded",
2028
+ [SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
2029
+ [SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
2030
+ [SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
2031
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
2032
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN]: "The transaction failed with the error `$errorName`",
2033
+ [SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION]: "Transaction version is unsupported",
2034
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
2035
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
2036
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
2037
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
2038
+ [SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
2039
+ [SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION]: "Attempted to sign a transaction with an address that is not a signer for it",
2040
+ [SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING]: "Transaction is missing an address at index: $index.",
2041
+ [SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES]: "Transaction has no expected signers therefore it cannot be encoded",
2042
+ [SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT]: "Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",
2043
+ [SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
2044
+ [SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
2045
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
2046
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE]: "Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",
2047
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
2048
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
2049
+ [SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT]: "Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",
2050
+ [SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT]: "Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",
2051
+ [SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
2052
+ [SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
2053
+ [SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
2054
+ [SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING]: "Transaction with no instructions cannot be durable nonce transaction.",
2055
+ [SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES]: "This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",
2056
+ [SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE]: "This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",
2057
+ [SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH]: "The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",
2058
+ [SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING]: "Transaction is missing signatures for addresses: $addresses.",
2059
+ [SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given",
2060
+ [SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED]: "This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",
2061
+ [SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE]: "The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."
2062
+ };
2063
+ var START_INDEX = "i";
2064
+ var TYPE = "t";
2065
+ function getHumanReadableErrorMessage(code, context = {}) {
2066
+ const messageFormatString = SolanaErrorMessages[code];
2067
+ if (messageFormatString.length === 0) {
2068
+ return "";
2069
+ }
2070
+ let state;
2071
+ function commitStateUpTo(endIndex) {
2072
+ if (state[TYPE] === 2) {
2073
+ const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex);
2074
+ fragments.push(
2075
+ variableName in context ? (
2076
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
2077
+ `${context[variableName]}`
2078
+ ) : `$${variableName}`
2079
+ );
2080
+ } else if (state[TYPE] === 1) {
2081
+ fragments.push(messageFormatString.slice(state[START_INDEX], endIndex));
2082
+ }
2083
+ }
2084
+ const fragments = [];
2085
+ messageFormatString.split("").forEach((char, ii) => {
2086
+ if (ii === 0) {
2087
+ state = {
2088
+ [START_INDEX]: 0,
2089
+ [TYPE]: messageFormatString[0] === "\\" ? 0 : messageFormatString[0] === "$" ? 2 : 1
2090
+ /* Text */
2091
+ };
2092
+ return;
2093
+ }
2094
+ let nextState;
2095
+ switch (state[TYPE]) {
2096
+ case 0:
2097
+ nextState = {
2098
+ [START_INDEX]: ii,
2099
+ [TYPE]: 1
2100
+ /* Text */
2101
+ };
2102
+ break;
2103
+ case 1:
2104
+ if (char === "\\") {
2105
+ nextState = {
2106
+ [START_INDEX]: ii,
2107
+ [TYPE]: 0
2108
+ /* EscapeSequence */
2109
+ };
2110
+ } else if (char === "$") {
2111
+ nextState = {
2112
+ [START_INDEX]: ii,
2113
+ [TYPE]: 2
2114
+ /* Variable */
2115
+ };
2116
+ }
2117
+ break;
2118
+ case 2:
2119
+ if (char === "\\") {
2120
+ nextState = {
2121
+ [START_INDEX]: ii,
2122
+ [TYPE]: 0
2123
+ /* EscapeSequence */
2124
+ };
2125
+ } else if (char === "$") {
2126
+ nextState = {
2127
+ [START_INDEX]: ii,
2128
+ [TYPE]: 2
2129
+ /* Variable */
2130
+ };
2131
+ } else if (!char.match(/\w/)) {
2132
+ nextState = {
2133
+ [START_INDEX]: ii,
2134
+ [TYPE]: 1
2135
+ /* Text */
2136
+ };
2137
+ }
2138
+ break;
2139
+ }
2140
+ if (nextState) {
2141
+ if (state !== nextState) {
2142
+ commitStateUpTo(ii);
2143
+ }
2144
+ state = nextState;
2145
+ }
2146
+ });
2147
+ commitStateUpTo();
2148
+ return fragments.join("");
2149
+ }
2150
+ function getErrorMessage(code, context = {}) {
2151
+ if (process.env.NODE_ENV !== "production") {
2152
+ return getHumanReadableErrorMessage(code, context);
2153
+ } else {
2154
+ let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \`npx @solana/errors decode -- ${code}`;
2155
+ if (Object.keys(context).length) {
2156
+ decodingAdviceMessage += ` '${encodeContextObject(context)}'`;
2157
+ }
2158
+ return `${decodingAdviceMessage}\``;
2159
+ }
2160
+ }
2161
+ var SolanaError = class extends Error {
2162
+ constructor(...[code, contextAndErrorOptions]) {
2163
+ let context;
2164
+ let errorOptions;
2165
+ if (contextAndErrorOptions) {
2166
+ Object.entries(Object.getOwnPropertyDescriptors(contextAndErrorOptions)).forEach(([name, descriptor]) => {
2167
+ if (name === "cause") {
2168
+ errorOptions = { cause: descriptor.value };
2169
+ } else {
2170
+ if (context === void 0) {
2171
+ context = {
2172
+ __code: code
2173
+ };
2174
+ }
2175
+ Object.defineProperty(context, name, descriptor);
2176
+ }
2177
+ });
2178
+ }
2179
+ const message = getErrorMessage(code, context);
2180
+ super(message, errorOptions);
2181
+ /**
2182
+ * Indicates the root cause of this {@link SolanaError}, if any.
2183
+ *
2184
+ * For example, a transaction error might have an instruction error as its root cause. In this
2185
+ * case, you will be able to access the instruction error on the transaction error as `cause`.
2186
+ */
2187
+ __publicField(this, "cause", this.cause);
2188
+ /**
2189
+ * Contains context that can assist in understanding or recovering from a {@link SolanaError}.
2190
+ */
2191
+ __publicField(this, "context");
2192
+ this.context = Object.freeze(
2193
+ context === void 0 ? {
2194
+ __code: code
2195
+ } : context
2196
+ );
2197
+ this.name = "SolanaError";
2198
+ }
2199
+ };
2200
+
2201
+ // node_modules/@solana/codecs-core/dist/index.node.mjs
2202
+ function getEncodedSize(value, encoder) {
2203
+ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
2204
+ }
2205
+ function createEncoder(encoder) {
2206
+ return Object.freeze({
2207
+ ...encoder,
2208
+ encode: (value) => {
2209
+ const bytes = new Uint8Array(getEncodedSize(value, encoder));
2210
+ encoder.write(value, bytes, 0);
2211
+ return bytes;
2212
+ }
2213
+ });
2214
+ }
2215
+
2216
+ // node_modules/@solana/codecs-strings/dist/index.node.mjs
2217
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
2218
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
2219
+ throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
2220
+ alphabet: alphabet4,
2221
+ base: alphabet4.length,
2222
+ value: givenValue
2223
+ });
2224
+ }
2225
+ }
2226
+ var getBaseXEncoder = (alphabet4) => {
2227
+ return createEncoder({
2228
+ getSizeFromValue: (value) => {
2229
+ const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
2230
+ if (!tailChars) return value.length;
2231
+ const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
2232
+ return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
2233
+ },
2234
+ write(value, bytes, offset) {
2235
+ assertValidBaseString(alphabet4, value);
2236
+ if (value === "") return offset;
2237
+ const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
2238
+ if (!tailChars) {
2239
+ bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
2240
+ return offset + leadingZeroes.length;
2241
+ }
2242
+ let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
2243
+ const tailBytes = [];
2244
+ while (base10Number > 0n) {
2245
+ tailBytes.unshift(Number(base10Number % 256n));
2246
+ base10Number /= 256n;
2247
+ }
2248
+ const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
2249
+ bytes.set(bytesToAdd, offset);
2250
+ return offset + bytesToAdd.length;
2251
+ }
2252
+ });
2253
+ };
2254
+ function partitionLeadingZeroes(value, zeroCharacter) {
2255
+ const [leadingZeros, tailChars] = value.split(new RegExp(`((?!${zeroCharacter}).*)`));
2256
+ return [leadingZeros, tailChars];
2257
+ }
2258
+ function getBigIntFromBaseX(value, alphabet4) {
2259
+ const base = BigInt(alphabet4.length);
2260
+ let sum = 0n;
2261
+ for (const char of value) {
2262
+ sum *= base;
2263
+ sum += BigInt(alphabet4.indexOf(char));
2264
+ }
2265
+ return sum;
2266
+ }
2267
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2268
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
2269
+ var e = globalThis.TextDecoder;
2270
+ var o = globalThis.TextEncoder;
2271
+
2272
+ // node_modules/@solana/addresses/dist/index.node.mjs
2273
+ var memoizedBase58Encoder;
2274
+ function getMemoizedBase58Encoder() {
2275
+ if (!memoizedBase58Encoder) memoizedBase58Encoder = getBase58Encoder();
2276
+ return memoizedBase58Encoder;
2277
+ }
2278
+ function isAddress(putativeAddress) {
2279
+ if (
2280
+ // Lowest address (32 bytes of zeroes)
2281
+ putativeAddress.length < 32 || // Highest address (32 bytes of 255)
2282
+ putativeAddress.length > 44
2283
+ ) {
2284
+ return false;
2285
+ }
2286
+ const base58Encoder = getMemoizedBase58Encoder();
2287
+ try {
2288
+ return base58Encoder.encode(putativeAddress).byteLength === 32;
2289
+ } catch {
2290
+ return false;
2291
+ }
2292
+ }
2293
+
2294
+ // src/validation/address.ts
2295
+ init_chains();
2296
+ var BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
2297
+ function hasMixedCase(value) {
2298
+ return value !== value.toLowerCase() && value !== value.toUpperCase();
2299
+ }
2300
+ function validateBech32LikeAddress(address, prefix) {
2301
+ const trimmed = address.trim();
2302
+ if (!trimmed) {
2303
+ return { isValid: false, error: "Address is required." };
2304
+ }
2305
+ if (hasMixedCase(trimmed)) {
2306
+ return { isValid: false, error: "Bech32 addresses cannot mix case." };
2307
+ }
2308
+ const lower = trimmed.toLowerCase();
2309
+ const expectedPrefix = `${prefix.toLowerCase()}1`;
2310
+ if (!lower.startsWith(expectedPrefix)) {
2311
+ return {
2312
+ isValid: false,
2313
+ error: `Address must start with ${expectedPrefix}.`
2314
+ };
2315
+ }
2316
+ const dataPart = lower.slice(expectedPrefix.length);
2317
+ if (dataPart.length < 6 || !BECH32_CHARSET.test(dataPart)) {
2318
+ return {
2319
+ isValid: false,
2320
+ error: "Bech32 address format is invalid."
2321
+ };
2322
+ }
2323
+ return { isValid: true };
2324
+ }
2325
+ function validateEvmAddress(address) {
2326
+ if (!(0, import_viem.isAddress)(address.trim())) {
2327
+ return {
2328
+ isValid: false,
2329
+ error: "EVM addresses must be 0x-prefixed 20-byte hex strings."
2330
+ };
2331
+ }
2332
+ return { isValid: true };
2333
+ }
2334
+ function validateSeiAddress(address) {
2335
+ const trimmed = address.trim();
2336
+ if ((0, import_viem.isAddress)(trimmed)) {
2337
+ return { isValid: true };
2338
+ }
2339
+ const result = validateBech32LikeAddress(trimmed, "sei");
2340
+ if (result.isValid) return result;
2341
+ return {
2342
+ isValid: false,
2343
+ error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
2344
+ };
2345
+ }
2346
+ function validateSolanaAddress(address) {
2347
+ const trimmed = address.trim();
2348
+ if (trimmed.startsWith("0x") || (0, import_viem.isAddress)(trimmed)) {
2349
+ return {
2350
+ isValid: false,
2351
+ error: "Solana addresses must be base58-encoded strings."
2352
+ };
2353
+ }
2354
+ if (trimmed.toLowerCase().startsWith("bc1") || trimmed.toLowerCase().startsWith("sei1")) {
2355
+ return {
2356
+ isValid: false,
2357
+ error: "Solana addresses cannot be bech32 strings."
2358
+ };
2359
+ }
2360
+ if (!isAddress(trimmed)) {
2361
+ return {
2362
+ isValid: false,
2363
+ error: "Solana addresses must be base58-encoded strings."
2364
+ };
2365
+ }
2366
+ return { isValid: true };
2367
+ }
2368
+ function validateBtcAddress(address) {
2369
+ const trimmed = address.trim();
2370
+ if (hasMixedCase(trimmed)) {
2371
+ return { isValid: false, error: "Bitcoin addresses cannot mix case." };
2372
+ }
2373
+ const result = validateBech32LikeAddress(trimmed, "bc");
2374
+ if (result.isValid) return result;
2375
+ return {
2376
+ isValid: false,
2377
+ error: "Bitcoin addresses must use native SegWit (bc1...) format."
2378
+ };
2379
+ }
2380
+ function validateAddressForChain(address, chain) {
2381
+ const trimmed = address.trim();
2382
+ if (!trimmed) return { isValid: true };
2383
+ const chainType = normalizeChainType(chain);
2384
+ const chainDef = typeof chain === "object" && chain ? chain : void 0;
2385
+ switch (chainType) {
2386
+ case "evm":
2387
+ return validateEvmAddress(trimmed);
2388
+ case "solana":
2389
+ return validateSolanaAddress(trimmed);
2390
+ case "bitcoin":
2391
+ return validateBtcAddress(trimmed);
2392
+ case "cosmos":
2393
+ if (chainDef?.networkIdentifier?.toLowerCase() === "sei") {
2394
+ return validateSeiAddress(trimmed);
2395
+ }
2396
+ return validateBech32LikeAddress(trimmed, "sei");
2397
+ default:
2398
+ return { isValid: false, error: "Unsupported or unknown chain type." };
2399
+ }
2400
+ }
2401
+ function validateAddressForRouteChain(address, chainType) {
2402
+ switch (normalizeChainType(chainType)) {
2403
+ case "evm":
2404
+ return validateEvmAddress(address);
2405
+ case "solana":
2406
+ return validateSolanaAddress(address);
2407
+ case "bitcoin":
2408
+ return validateBtcAddress(address);
2409
+ case "cosmos":
2410
+ return validateSeiAddress(address);
2411
+ default:
2412
+ return { isValid: false, error: "Unsupported chain type." };
2413
+ }
2414
+ }
2415
+ function validateRouteAddresses(params) {
2416
+ const fromType = normalizeChainType(params.fromChain);
2417
+ const toType = normalizeChainType(params.toChain);
2418
+ if (!fromType || !toType) {
2419
+ return {
2420
+ isValid: false,
2421
+ error: "Missing chain types for route validation."
2422
+ };
2423
+ }
2424
+ const fromAddress = params.fromAddress.trim();
2425
+ const toAddress = params.toAddress.trim();
2426
+ if (!fromAddress || !toAddress) {
2427
+ return { isValid: false, error: "Route addresses are required." };
2428
+ }
2429
+ const normalizedDirection = params.direction?.trim().toLowerCase();
2430
+ const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
2431
+ if (isDepositFlow) {
2432
+ const fromResult2 = validateAddressForRouteChain(fromAddress, fromType);
2433
+ if (!fromResult2.isValid) {
2434
+ return {
2435
+ isValid: false,
2436
+ error: `From address: ${fromResult2.error ?? "Invalid address."}`
2437
+ };
2438
+ }
2439
+ const toResult2 = toType === "cosmos" ? validateSeiAddress(toAddress) : validateEvmAddress(toAddress);
2440
+ if (!toResult2.isValid) {
2441
+ return {
2442
+ isValid: false,
2443
+ error: `To address: ${toResult2.error ?? "Invalid address."}`
2444
+ };
2445
+ }
2446
+ if (fromType === "bitcoin") {
2447
+ const refundAddress = params.refundAddress?.trim();
2448
+ if (!refundAddress) {
2449
+ return {
2450
+ isValid: false,
2451
+ error: "Refund address is required for BTC deposit routes."
2452
+ };
2453
+ }
2454
+ const refundResult = validateBtcAddress(refundAddress);
2455
+ if (!refundResult.isValid) {
2456
+ return {
2457
+ isValid: false,
2458
+ error: `Refund address: ${refundResult.error ?? "Invalid address."}`
2459
+ };
2460
+ }
2461
+ }
2462
+ return { isValid: true };
2463
+ }
2464
+ const fromResult = validateAddressForRouteChain(fromAddress, fromType);
2465
+ if (!fromResult.isValid) {
2466
+ return {
2467
+ isValid: false,
2468
+ error: `From address: ${fromResult.error ?? "Invalid address."}`
2469
+ };
2470
+ }
2471
+ const toResult = validateAddressForRouteChain(toAddress, toType);
2472
+ if (!toResult.isValid) {
2473
+ return {
2474
+ isValid: false,
2475
+ error: `To address: ${toResult.error ?? "Invalid address."}`
2476
+ };
2477
+ }
2478
+ return { isValid: true };
2479
+ }
2480
+
2481
+ // src/identity/index.ts
2482
+ init_chains();
2483
+ function normalizeIdentityChainId(chain) {
2484
+ if (!chain || typeof chain === "string") return void 0;
2485
+ const raw = chain.chainId ?? chain.id;
2486
+ if (raw === void 0 || raw === null) return void 0;
2487
+ const normalized = String(raw).trim();
2488
+ return normalized || void 0;
2489
+ }
2490
+ function identityEntryMatchesChain(entry, chainType, chainKey, chainId) {
2491
+ if (chainKey && entry.chainKey && entry.chainKey === chainKey) return true;
2492
+ if (chainId && entry.chainId && entry.chainId === chainId) return true;
2493
+ if (chainType && entry.chainType === chainType) return true;
2494
+ return false;
2495
+ }
2496
+ function createWalletIdentity(addresses = []) {
2497
+ return { addresses };
2498
+ }
2499
+ function upsertWalletIdentityAddress(identity, next) {
2500
+ const normalizedAddress = next.address.trim();
2501
+ const normalizedChainKey = next.chainKey ? normalizeChainKey(next.chainKey) : void 0;
2502
+ const normalizedChainId = next.chainId?.trim() || void 0;
2503
+ const addresses = identity.addresses.filter((entry) => {
2504
+ if (entry.chainType !== next.chainType) return true;
2505
+ if (normalizedChainKey && entry.chainKey === normalizedChainKey)
2506
+ return false;
2507
+ if (normalizedChainId && entry.chainId === normalizedChainId) return false;
2508
+ if (!normalizedChainKey && !normalizedChainId) return false;
2509
+ return true;
2510
+ });
2511
+ if (!normalizedAddress) return createWalletIdentity(addresses);
2512
+ return createWalletIdentity([
2513
+ ...addresses,
2514
+ {
2515
+ ...next,
2516
+ address: normalizedAddress,
2517
+ chainKey: normalizedChainKey,
2518
+ chainId: normalizedChainId
2519
+ }
2520
+ ]);
2521
+ }
2522
+ function resolveWalletAddressForChain(identity, chain) {
2523
+ const chainType = normalizeChainType(chain);
2524
+ const chainDef = typeof chain === "object" && chain ? chain : void 0;
2525
+ const chainKey = chainDef ? normalizeChainKey(
2526
+ chainDef.networkIdentifier ?? chainDef.chainId ?? chainDef.id
2527
+ ) : typeof chain === "string" ? normalizeChainKey(chain) : void 0;
2528
+ const chainId = normalizeIdentityChainId(chain);
2529
+ if (!chainType) {
2530
+ return {
2531
+ status: "missing",
2532
+ reason: "unknown_chain_type",
2533
+ chainKey,
2534
+ chainId
2535
+ };
2536
+ }
2537
+ const match = identity.addresses.find(
2538
+ (entry) => identityEntryMatchesChain(entry, chainType, chainKey, chainId)
2539
+ );
2540
+ if (!match) {
2541
+ return {
2542
+ status: "missing",
2543
+ reason: "missing_chain_address",
2544
+ chainType,
2545
+ chainKey,
2546
+ chainId
2547
+ };
2548
+ }
2549
+ const validation = validateAddressForChain(
2550
+ match.address,
2551
+ chainDef ?? chainType
2552
+ );
2553
+ if (!validation.isValid) {
2554
+ return {
2555
+ status: "invalid",
2556
+ reason: validation.error ?? "invalid_chain_address",
2557
+ address: match.address,
2558
+ source: match.source,
2559
+ chainType,
2560
+ chainKey,
2561
+ chainId
2562
+ };
2563
+ }
2564
+ return {
2565
+ status: "resolved",
2566
+ address: match.address.trim(),
2567
+ source: match.source,
2568
+ chainType,
2569
+ chainKey,
2570
+ chainId
2571
+ };
2572
+ }
2573
+ function buildWalletIdentityAddress(params) {
2574
+ const chainType = normalizeChainType(params.chain);
2575
+ if (!chainType) return null;
2576
+ const address = params.address.trim();
2577
+ const chainId = normalizeIdentityChainId(params.chain);
2578
+ const chainDef = typeof params.chain === "object" && params.chain ? params.chain : void 0;
2579
+ const chainKey = chainDef ? normalizeChainKey(
2580
+ chainDef.networkIdentifier ?? chainDef.chainId ?? chainDef.id
2581
+ ) : void 0;
2582
+ return {
2583
+ address,
2584
+ chainType,
2585
+ chainId,
2586
+ chainKey,
2587
+ providerId: params.providerId,
2588
+ source: params.source
2589
+ };
2590
+ }
2591
+ var IdentityStore = class {
2592
+ constructor() {
2593
+ this._identity = createWalletIdentity();
2594
+ }
2595
+ get snapshot() {
2596
+ return this._identity;
2597
+ }
2598
+ reset() {
2599
+ this._identity = createWalletIdentity();
2600
+ }
2601
+ upsert(next) {
2602
+ this._identity = upsertWalletIdentityAddress(this._identity, next);
2603
+ return this._identity;
2604
+ }
2605
+ resolve(chain) {
2606
+ return resolveWalletAddressForChain(this._identity, chain);
2607
+ }
2608
+ };
2609
+
1209
2610
  // src/wallets/manager.ts
1210
2611
  var import_react2 = require("react");
1211
2612
  var WalletManager = class {
@@ -1214,6 +2615,9 @@ var WalletManager = class {
1214
2615
  this._wallet = null;
1215
2616
  this._detected = [];
1216
2617
  this._listeners = /* @__PURE__ */ new Set();
2618
+ this._identity = new IdentityStore();
2619
+ this._providerCleanup = null;
2620
+ this._connectedWalletId = null;
1217
2621
  }
1218
2622
  get status() {
1219
2623
  return this._status;
@@ -1229,8 +2633,14 @@ var WalletManager = class {
1229
2633
  }
1230
2634
  get simple() {
1231
2635
  if (!this._wallet) return null;
1232
- const { getAddress, getChainId, switchChain } = this._wallet;
1233
- return { getAddress, getChainId, switchChain };
2636
+ const { getAddress, disconnect } = this._wallet;
2637
+ return { getAddress, disconnect };
2638
+ }
2639
+ get identity() {
2640
+ return this._identity.snapshot;
2641
+ }
2642
+ get connectedWalletId() {
2643
+ return this._connectedWalletId;
1234
2644
  }
1235
2645
  onChange(fn) {
1236
2646
  this._listeners.add(fn);
@@ -1251,17 +2661,28 @@ var WalletManager = class {
1251
2661
  await this.connectDetected(target, opts);
1252
2662
  }
1253
2663
  async connectDetected(target, opts) {
2664
+ if (this._status === "connected" && this._connectedWalletId === target.meta.id && this._wallet) {
2665
+ this.emit();
2666
+ return;
2667
+ }
1254
2668
  this._status = "connecting";
2669
+ this.clearConnectedWalletState();
1255
2670
  this.emit();
1256
2671
  try {
1257
2672
  const { api } = await connectDetectedWallet(target, {
1258
2673
  wagmi: opts?.wagmi
1259
2674
  });
1260
- if (api) this._wallet = api;
2675
+ if (api) {
2676
+ this._wallet = api;
2677
+ this._connectedWalletId = target.meta.id;
2678
+ this.bindProviderEvents(target);
2679
+ await this.syncIdentityFromWallet(target.meta.id);
2680
+ }
1261
2681
  this._status = "connected";
1262
- } catch (e) {
1263
- this._error = e;
2682
+ } catch (e2) {
2683
+ this._error = e2;
1264
2684
  this._status = "error";
2685
+ this.clearConnectedWalletState();
1265
2686
  } finally {
1266
2687
  this.emit();
1267
2688
  }
@@ -1269,14 +2690,21 @@ var WalletManager = class {
1269
2690
  async disconnect(wagmi) {
1270
2691
  if (wagmi) await wagmi.disconnect().catch(() => {
1271
2692
  });
1272
- this._wallet = null;
2693
+ if (this._wallet?.disconnect) {
2694
+ await this._wallet.disconnect().catch(() => {
2695
+ });
2696
+ }
2697
+ this.clearConnectedWalletState();
1273
2698
  this._status = "idle";
1274
2699
  this.emit();
1275
2700
  }
1276
2701
  /** Directly attach a pre-provided wallet interface (from old provider prop). */
1277
2702
  attachWallet(api) {
2703
+ this.clearConnectedWalletState();
1278
2704
  this._wallet = api;
2705
+ this._connectedWalletId = null;
1279
2706
  this._status = "connected";
2707
+ void this.syncIdentityFromWallet();
1280
2708
  this.emit();
1281
2709
  }
1282
2710
  /** Optional helper to set explicit status (e.g., "initializing" UX). */
@@ -1284,6 +2712,90 @@ var WalletManager = class {
1284
2712
  this._status = s;
1285
2713
  this.emit();
1286
2714
  }
2715
+ addIdentityAddress(address) {
2716
+ this._identity.upsert(address);
2717
+ }
2718
+ resolveAddressForChain(chain) {
2719
+ return this._identity.resolve(chain);
2720
+ }
2721
+ clearProviderCleanup() {
2722
+ this._providerCleanup?.();
2723
+ this._providerCleanup = null;
2724
+ }
2725
+ clearConnectedWalletState() {
2726
+ this.clearProviderCleanup();
2727
+ this._wallet = null;
2728
+ this._connectedWalletId = null;
2729
+ }
2730
+ bindProviderEvents(target) {
2731
+ if (!target.provider) return;
2732
+ if (target.via === "solana-window") {
2733
+ this._providerCleanup = bindSolanaProviderEvents(target.provider, {
2734
+ onConnect: () => {
2735
+ this._status = "connected";
2736
+ void this.syncIdentityFromWallet(target.meta.id);
2737
+ this.emit();
2738
+ },
2739
+ onAccountChanged: () => {
2740
+ void this.syncIdentityFromWallet(target.meta.id);
2741
+ this.emit();
2742
+ },
2743
+ onDisconnect: () => {
2744
+ this.clearConnectedWalletState();
2745
+ this._status = "idle";
2746
+ this.emit();
2747
+ }
2748
+ });
2749
+ return;
2750
+ }
2751
+ const provider = target.provider;
2752
+ const onAccountsChanged = (accounts) => {
2753
+ const nextAccounts = Array.isArray(accounts) ? accounts : [];
2754
+ if (nextAccounts.length === 0) {
2755
+ this.clearConnectedWalletState();
2756
+ this._status = "idle";
2757
+ this.emit();
2758
+ return;
2759
+ }
2760
+ this._status = "connected";
2761
+ void this.syncIdentityFromWallet(target.meta.id);
2762
+ this.emit();
2763
+ };
2764
+ const onDisconnect = () => {
2765
+ this.clearConnectedWalletState();
2766
+ this._status = "idle";
2767
+ this.emit();
2768
+ };
2769
+ provider.on?.("accountsChanged", onAccountsChanged);
2770
+ provider.on?.("disconnect", onDisconnect);
2771
+ this._providerCleanup = () => {
2772
+ provider.off?.("accountsChanged", onAccountsChanged);
2773
+ provider.off?.("disconnect", onDisconnect);
2774
+ provider.removeListener?.("accountsChanged", onAccountsChanged);
2775
+ provider.removeListener?.("disconnect", onDisconnect);
2776
+ };
2777
+ }
2778
+ async syncIdentityFromWallet(providerId) {
2779
+ if (!this._wallet) return;
2780
+ try {
2781
+ const address = await this._wallet.getAddress();
2782
+ const chain = this._wallet.ecosystem === "evm" ? { chainId: String(await this._wallet.getChainId()), type: "evm" } : {
2783
+ chainId: "solana-mainnet-beta",
2784
+ networkIdentifier: "solana-mainnet-beta",
2785
+ type: "solana"
2786
+ };
2787
+ const identityAddress = buildWalletIdentityAddress({
2788
+ address,
2789
+ chain,
2790
+ source: "provider",
2791
+ providerId
2792
+ });
2793
+ if (identityAddress) {
2794
+ this._identity.upsert(identityAddress);
2795
+ }
2796
+ } catch {
2797
+ }
2798
+ }
1287
2799
  };
1288
2800
  var walletManager = new WalletManager();
1289
2801
  function useWireDetectionIntoManager() {
@@ -1296,13 +2808,30 @@ function useWireDetectionIntoManager() {
1296
2808
  // src/core/routes.ts
1297
2809
  init_http();
1298
2810
  init_store();
2811
+ function isEvmTxRequest(txReq) {
2812
+ return Boolean(txReq?.data && (txReq.to || txReq.target));
2813
+ }
2814
+ function isSerializedSolanaTxRequest(txReq) {
2815
+ return Boolean(txReq?.data && !txReq?.to && !txReq?.target);
2816
+ }
1299
2817
  async function buildRoute(body, signal) {
2818
+ const addressValidation = validateRouteAddresses({
2819
+ fromChain: body.fromChain,
2820
+ toChain: body.toChain,
2821
+ fromAddress: body.fromAddress,
2822
+ toAddress: body.toAddress,
2823
+ refundAddress: body.refundAddress,
2824
+ direction: body.direction
2825
+ });
2826
+ if (!addressValidation.isValid) {
2827
+ throw new Error(addressValidation.error || "Invalid route addresses.");
2828
+ }
1300
2829
  const cfg = TrustwareConfigStore.get();
1301
- const url = `${apiBase()}/routes/route`;
2830
+ const url = `${apiBase()}/v1/routes/route`;
1302
2831
  const payload = {
1303
2832
  ...body,
1304
- slippageBps: body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100),
1305
- fromAmountUSD: body.fromAmountUsd
2833
+ slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
2834
+ fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
1306
2835
  };
1307
2836
  const r = await rateLimitedFetch(url, {
1308
2837
  method: "POST",
@@ -1326,16 +2855,58 @@ async function buildRoute(body, signal) {
1326
2855
  const estimate = route?.estimate ?? {};
1327
2856
  const finalExchangeRate = {
1328
2857
  fromAmountUSD: estimate.fromAmountUsd,
1329
- toAmountMinUSD: estimate?.toAmountUsd
2858
+ toAmountMinUSD: estimate?.toAmountMinUsd ?? estimate?.toAmountUsd
1330
2859
  };
1331
- if (!txReq?.data || !(txReq?.to || txReq?.target)) {
1332
- throw new Error("Invalid route: missing transactionRequest target/data");
2860
+ if (!txReq?.data) {
2861
+ throw new Error("Invalid route: missing transaction data");
1333
2862
  }
1334
2863
  return { intentId, txReq, actions, finalExchangeRate, route };
1335
2864
  }
2865
+ async function buildDepositAddress(body, signal) {
2866
+ const cfg = TrustwareConfigStore.get();
2867
+ const url = `${apiBase()}/v1/routes/deposit-address`;
2868
+ const payload = {
2869
+ ...body,
2870
+ slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
2871
+ fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
2872
+ };
2873
+ const r = await rateLimitedFetch(url, {
2874
+ method: "POST",
2875
+ headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
2876
+ body: JSON.stringify(payload),
2877
+ signal
2878
+ });
2879
+ let json = {};
2880
+ try {
2881
+ json = await r.json();
2882
+ } catch {
2883
+ }
2884
+ if (!r.ok) {
2885
+ const msg = json?.error || json?.message || "Failed to build deposit address";
2886
+ throw new Error(msg);
2887
+ }
2888
+ const intentId = json?.data?.intentId ?? json?.intentId ?? "";
2889
+ const route = json?.data?.route ?? json?.route;
2890
+ const depositAddress = json?.data?.depositAddress?.address ?? json?.depositAddress?.address ?? "";
2891
+ const actions = Array.isArray(route?.steps) ? route.steps : [];
2892
+ const estimate = route?.estimate ?? {};
2893
+ if (!depositAddress) {
2894
+ throw new Error("Invalid route: missing deposit address");
2895
+ }
2896
+ return {
2897
+ intentId,
2898
+ depositAddress,
2899
+ actions,
2900
+ finalExchangeRate: {
2901
+ fromAmountUSD: estimate.fromAmountUsd,
2902
+ toAmountMinUSD: estimate?.toAmountMinUsd ?? estimate?.toAmountUsd
2903
+ },
2904
+ route
2905
+ };
2906
+ }
1336
2907
  async function submitReceipt(intentId, txHash) {
1337
2908
  const r = await rateLimitedFetch(
1338
- `${apiBase()}/route-intent/${intentId}/receipt`,
2909
+ `${apiBase()}/v1/route-intent/${intentId}/receipt`,
1339
2910
  {
1340
2911
  method: "POST",
1341
2912
  headers: jsonHeaders({ "Idempotency-Key": txHash }),
@@ -1348,7 +2919,7 @@ async function submitReceipt(intentId, txHash) {
1348
2919
  }
1349
2920
  async function getStatus(intentId) {
1350
2921
  const r = await rateLimitedFetch(
1351
- `${apiBase()}/route-intent/${intentId}/status`,
2922
+ `${apiBase()}/v1/route-intent/${intentId}/status`,
1352
2923
  {
1353
2924
  headers: jsonHeaders()
1354
2925
  }
@@ -1370,20 +2941,125 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
1370
2941
  // src/core/balances.ts
1371
2942
  init_http();
1372
2943
  init_registry();
1373
- async function getBalances(chainId, address) {
2944
+ init_chains();
2945
+ var balanceCache = /* @__PURE__ */ new Map();
2946
+ function toStringOrUndefined(value) {
2947
+ if (typeof value !== "string") return void 0;
2948
+ const trimmed = value.trim();
2949
+ return trimmed || void 0;
2950
+ }
2951
+ function toNumberOrUndefined(value) {
2952
+ if (typeof value === "number") {
2953
+ return Number.isFinite(value) ? value : void 0;
2954
+ }
2955
+ if (typeof value === "string") {
2956
+ const parsed = Number(value.trim());
2957
+ return Number.isFinite(parsed) ? parsed : void 0;
2958
+ }
2959
+ return void 0;
2960
+ }
2961
+ function fallbackTokenSymbol(address, chainType) {
2962
+ if (chainType?.toLowerCase() === "solana") {
2963
+ return "SPL";
2964
+ }
2965
+ return `TOKEN-${address.slice(0, 6)}`;
2966
+ }
2967
+ function normalizeRows(rows, chain, address, registry) {
2968
+ const chainKey = chain.networkIdentifier ?? String(chain.chainId ?? chain.id);
2969
+ const chainType = normalizeChainType(chain);
2970
+ const nativeAddress = getNativeTokenAddress(chainType);
2971
+ const map = /* @__PURE__ */ new Map();
2972
+ for (const item of rows) {
2973
+ const category = toStringOrUndefined(item.category)?.toLowerCase();
2974
+ const addressRaw = item.contract ?? item.token_address ?? item.address ?? item.addr;
2975
+ const tokenAddress = typeof addressRaw === "string" ? addressRaw.trim() : void 0;
2976
+ const symbol = toStringOrUndefined(item.symbol ?? item.sym);
2977
+ const name = toStringOrUndefined(item.name ?? item.token_name ?? item.token) ?? symbol;
2978
+ const decimals = toNumberOrUndefined(item.decimals ?? item.dec);
2979
+ const balance = String(item.balance ?? item.bal ?? "0");
2980
+ const explicitNative = Boolean(item.native ?? item.is_native);
2981
+ const nativeFlag = explicitNative || category === "native" || isZeroAddressLike(tokenAddress, chainType);
2982
+ if (nativeFlag) {
2983
+ const nativeRow = {
2984
+ chain_key: chainKey,
2985
+ category: "native",
2986
+ contract: nativeAddress,
2987
+ address: nativeAddress,
2988
+ symbol: symbol ?? chain.nativeCurrency?.symbol ?? "NATIVE",
2989
+ name: name ?? chain.nativeCurrency?.name ?? symbol,
2990
+ decimals: decimals ?? chain.nativeCurrency?.decimals ?? 18,
2991
+ balance
2992
+ };
2993
+ map.set(`${chainKey}:${nativeAddress}`, nativeRow);
2994
+ continue;
2995
+ }
2996
+ if (!tokenAddress || decimals === void 0) continue;
2997
+ const metadata = registry.findToken(chain.chainId, tokenAddress);
2998
+ const displaySymbol = symbol ?? metadata?.symbol ?? fallbackTokenSymbol(tokenAddress, chainType);
2999
+ const displayName = name ?? metadata?.name ?? displaySymbol;
3000
+ const normalizedAddress = metadata?.address ?? tokenAddress;
3001
+ map.set(`${chainKey}:${normalizedAddress}`, {
3002
+ chain_key: chainKey,
3003
+ category: category ?? (chainType === "solana" ? "spl" : "erc20"),
3004
+ contract: normalizedAddress,
3005
+ address: normalizedAddress,
3006
+ symbol: displaySymbol,
3007
+ name: displayName,
3008
+ decimals: metadata?.decimals ?? decimals,
3009
+ balance,
3010
+ logoURI: metadata?.logoURI,
3011
+ usdPrice: metadata?.usdPrice
3012
+ });
3013
+ }
3014
+ if (!Array.from(map.values()).some((row) => row.category === "native")) {
3015
+ map.set(`${chainKey}:${nativeAddress}`, {
3016
+ chain_key: chainKey,
3017
+ category: "native",
3018
+ contract: nativeAddress,
3019
+ address: nativeAddress,
3020
+ symbol: chain.nativeCurrency?.symbol ?? "NATIVE",
3021
+ name: chain.nativeCurrency?.name ?? chain.nativeCurrency?.symbol,
3022
+ decimals: chain.nativeCurrency?.decimals ?? 18,
3023
+ balance: "0"
3024
+ });
3025
+ }
3026
+ return Array.from(map.values()).sort((a, b) => {
3027
+ try {
3028
+ return Number(BigInt(b.balance) - BigInt(a.balance));
3029
+ } catch {
3030
+ return 0;
3031
+ }
3032
+ });
3033
+ }
3034
+ async function getBalances(chainRef, address) {
1374
3035
  const reg = await ensureRegistry();
1375
- const meta = reg.chain(chainId);
1376
- const chainKey = meta?.networkIdentifier || String(chainId);
1377
- const url = `${apiBase()}/data/wallets/${encodeURIComponent(chainKey)}/${address}/balances`;
1378
- const r = await fetch(url, {
3036
+ const chain = reg.chain(chainRef);
3037
+ if (!chain) return [];
3038
+ const trimmedAddress = address.trim();
3039
+ const validation = validateAddressForChain(trimmedAddress, chain);
3040
+ if (!validation.isValid) return [];
3041
+ const chainKey = chain.networkIdentifier ?? String(chain.chainId ?? chain.id);
3042
+ const cacheKey = [
3043
+ chainKey,
3044
+ trimmedAddress,
3045
+ chain.nativeCurrency?.symbol ?? "",
3046
+ chain.nativeCurrency?.decimals ?? "",
3047
+ normalizeChainType(chain) ?? ""
3048
+ ].join(":");
3049
+ const cached = balanceCache.get(cacheKey);
3050
+ if (cached) return cached;
3051
+ const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
3052
+ const response = await fetch(url, {
1379
3053
  method: "GET",
1380
3054
  credentials: "omit",
1381
3055
  headers: jsonHeaders()
1382
3056
  });
1383
- if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
1384
- const j = await r.json();
1385
- const rows = Array.isArray(j) ? j : j.data ?? [];
1386
- return rows;
3057
+ if (!response.ok) throw new Error(`balances: HTTP ${response.status}`);
3058
+ const json = await response.json();
3059
+ const rows = Array.isArray(json) ? json : json.data ?? [];
3060
+ const normalized = normalizeRows(rows, chain, trimmedAddress, reg);
3061
+ balanceCache.set(cacheKey, normalized);
3062
+ return normalized;
1387
3063
  }
1388
3064
  async function getBalancesByAddress(address) {
1389
3065
  const url = `${apiBase()}/data/balances/${address}`;
@@ -1394,8 +3070,7 @@ async function getBalancesByAddress(address) {
1394
3070
  });
1395
3071
  if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
1396
3072
  const j = await r.json();
1397
- const rows = Array.isArray(j) ? j : j.results ?? [];
1398
- return rows;
3073
+ return Array.isArray(j) ? j : j.results ?? [];
1399
3074
  }
1400
3075
  var _registry;
1401
3076
  async function ensureRegistry() {
@@ -1407,71 +3082,100 @@ async function ensureRegistry() {
1407
3082
  }
1408
3083
 
1409
3084
  // src/core/tx.ts
1410
- function isUserRejected(e) {
1411
- const code = e?.code ?? e?.data?.code;
3085
+ function isUserRejected(e2) {
3086
+ const code = e2?.code ?? e2?.data?.code;
1412
3087
  if (code === 4001) return true;
1413
- const msg = String(e?.message || e)?.toLowerCase?.() || "";
3088
+ const msg = String(e2?.message || e2)?.toLowerCase?.() || "";
1414
3089
  return msg.includes("user rejected") || msg.includes("user denied");
1415
3090
  }
1416
3091
  async function sendRouteTransaction(b, fallbackChainId) {
1417
3092
  const w = walletManager.wallet;
1418
3093
  if (!w) throw new Error("Trustware.wallet not configured");
1419
- const tr = b?.txReq;
1420
- const to = tr.to;
1421
- const data = tr.data;
1422
- const value = tr.value ? BigInt(tr.value) : 0n;
1423
- const target = Number(tr.chainId ?? fallbackChainId);
1424
- if (Number.isFinite(target)) {
1425
- const current = await w.getChainId();
1426
- if (current !== target) {
1427
- try {
1428
- await w.switchChain(target);
1429
- } catch {
3094
+ const txReq = b.txReq;
3095
+ if (isEvmTxRequest(txReq)) {
3096
+ if (w.ecosystem !== "evm") {
3097
+ throw new Error("An EVM wallet is required for this route");
3098
+ }
3099
+ const to = txReq.to ?? txReq.target;
3100
+ const data = txReq.data;
3101
+ const value = txReq.value ? BigInt(txReq.value) : 0n;
3102
+ const target = Number(txReq.chainId ?? fallbackChainId);
3103
+ if (Number.isFinite(target)) {
3104
+ const current = await w.getChainId();
3105
+ if (current !== target) {
3106
+ try {
3107
+ await w.switchChain(target);
3108
+ } catch {
3109
+ }
1430
3110
  }
1431
3111
  }
1432
- }
1433
- if (w.type === "eip1193") {
1434
- const from = await w.getAddress();
1435
- const hexValue = value ? `0x${value.toString(16)}` : "0x0";
1436
- const params = { from, to, data, value: hexValue };
1437
- if (Number.isFinite(target)) params.chainId = `0x${target.toString(16)}`;
1438
- const hash = await w.request({
1439
- method: "eth_sendTransaction",
1440
- params: [params]
1441
- });
1442
- return hash;
1443
- } else {
1444
- const resp = await w.sendTransaction({
3112
+ if (w.type === "eip1193") {
3113
+ const from = await w.getAddress();
3114
+ const hexValue = value ? `0x${value.toString(16)}` : "0x0";
3115
+ const params = {
3116
+ from,
3117
+ to,
3118
+ data,
3119
+ value: hexValue
3120
+ };
3121
+ if (Number.isFinite(target)) {
3122
+ params.chainId = `0x${target.toString(16)}`;
3123
+ }
3124
+ const hash = await w.request({
3125
+ method: "eth_sendTransaction",
3126
+ params: [params]
3127
+ });
3128
+ return hash;
3129
+ }
3130
+ const response = await w.sendTransaction({
1445
3131
  to,
1446
3132
  data,
1447
3133
  value,
1448
3134
  chainId: Number.isFinite(target) ? target : void 0
1449
3135
  });
1450
- return resp.hash;
3136
+ return response.hash;
3137
+ }
3138
+ if (isSerializedSolanaTxRequest(txReq)) {
3139
+ if (w.ecosystem !== "solana") {
3140
+ throw new Error("A Solana wallet is required for this route");
3141
+ }
3142
+ const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
3143
+ const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
3144
+ const registry = new Registry2(apiBase2());
3145
+ await registry.ensureLoaded();
3146
+ const chain = registry.chain(
3147
+ String(fallbackChainId ?? txReq.chainId ?? "")
3148
+ );
3149
+ const rpcUrl = chain?.rpc ?? chain?.rpcList?.[0];
3150
+ return w.sendSerializedTransaction(txReq.data, rpcUrl);
1451
3151
  }
3152
+ throw new Error("Invalid route transaction payload");
1452
3153
  }
1453
3154
  async function runTopUp(params) {
1454
3155
  const w = walletManager.wallet;
1455
3156
  if (!w) throw new Error("Trustware.wallet not configured");
1456
- const { Registry: Registry2, NATIVE: NATIVE2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
3157
+ const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
1457
3158
  const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
1458
3159
  const reg = new Registry2(apiBase2());
1459
3160
  await reg.ensureLoaded();
1460
3161
  const fromAddress = await w.getAddress();
1461
- const currentChainId = await w.getChainId();
1462
- const originalChain = currentChainId;
1463
- const fromChain = params.fromChain ?? String(currentChainId);
3162
+ const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
3163
+ const originalChain = w.ecosystem === "evm" ? await w.getChainId() : void 0;
3164
+ const fromChain = params.fromChain ?? currentChainRef;
1464
3165
  const { TrustwareConfigStore: TrustwareConfigStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
1465
3166
  const cfg = TrustwareConfigStore2.get();
1466
3167
  const toChain = params.toChain ?? String(cfg.routes.toChain);
1467
3168
  const fromToken = reg.resolveToken(
1468
3169
  fromChain,
1469
3170
  params.fromToken ?? cfg.routes.fromToken ?? void 0
1470
- ) ?? NATIVE2;
3171
+ ) ?? params.fromToken;
1471
3172
  const toToken = reg.resolveToken(
1472
3173
  toChain,
1473
3174
  params.toToken ?? cfg.routes.toToken ?? void 0
1474
- ) ?? NATIVE2;
3175
+ ) ?? params.toToken;
3176
+ if (!fromToken || !toToken) {
3177
+ throw new Error("Unable to resolve route tokens");
3178
+ }
1475
3179
  try {
1476
3180
  const build = await buildRoute({
1477
3181
  fromChain,
@@ -1483,16 +3187,15 @@ async function runTopUp(params) {
1483
3187
  toAddress: params.toAddress ?? cfg.routes.toAddress ?? cfg.routes.fromAddress ?? fromAddress,
1484
3188
  slippage: cfg.routes.defaultSlippage
1485
3189
  });
1486
- const hash = await sendRouteTransaction(build, Number(fromChain));
3190
+ const hash = await sendRouteTransaction(build, fromChain);
1487
3191
  await submitReceipt(build.intentId, hash);
1488
- const tx = await pollStatus(build.intentId);
1489
- return tx;
1490
- } catch (e) {
1491
- if (isUserRejected(e)) throw new Error("Transaction cancelled by user");
1492
- throw e;
3192
+ return await pollStatus(build.intentId);
3193
+ } catch (e2) {
3194
+ if (isUserRejected(e2)) throw new Error("Transaction cancelled by user");
3195
+ throw e2;
1493
3196
  } finally {
1494
3197
  try {
1495
- if (originalChain && originalChain !== Number(fromChain)) {
3198
+ if (w.ecosystem === "evm" && originalChain && originalChain !== Number(fromChain)) {
1496
3199
  await w.switchChain(originalChain);
1497
3200
  }
1498
3201
  } catch {
@@ -1528,40 +3231,64 @@ function getSharedRegistry() {
1528
3231
  }
1529
3232
 
1530
3233
  // src/widget/helpers/chainHelpers.ts
1531
- function normalizeChainKey(id) {
3234
+ function normalizeChainKey2(id) {
1532
3235
  if (id === void 0 || id === null) return "";
1533
3236
  return String(id).trim().toLowerCase();
1534
3237
  }
1535
- var NATIVE_EVM = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
1536
- var NATIVE_SOLANA = "So11111111111111111111111111111111111111111";
1537
- function getNativeTokenAddress(chainType) {
3238
+ var NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
3239
+ var NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
3240
+ function getNativeTokenAddress2(chainType) {
1538
3241
  const normalized = chainType?.toLowerCase?.();
1539
- return normalized === "solana" ? NATIVE_SOLANA : NATIVE_EVM;
3242
+ return normalized === "solana" ? NATIVE_SOLANA2 : NATIVE_EVM2;
1540
3243
  }
1541
- var CHAIN_TYPE_ALIASES = {
3244
+ function isSolanaNativeTokenAlias2(address) {
3245
+ if (!address) return false;
3246
+ const trimmed = address.trim();
3247
+ if (!trimmed) return false;
3248
+ return trimmed === NATIVE_SOLANA2 || trimmed.toLowerCase() === NATIVE_EVM2;
3249
+ }
3250
+ var CHAIN_TYPE_ALIASES2 = {
1542
3251
  btc: "bitcoin",
1543
3252
  bitcoin: "bitcoin",
1544
3253
  sei: "cosmos",
1545
3254
  "pacific-1": "cosmos"
1546
3255
  };
1547
- function normalizeChainType(chain) {
3256
+ function inferChainTypeFromValue2(normalized) {
3257
+ if (!normalized) return void 0;
3258
+ const aliased = CHAIN_TYPE_ALIASES2[normalized];
3259
+ if (aliased) return aliased;
3260
+ if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
3261
+ return normalized;
3262
+ }
3263
+ if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
3264
+ return "evm";
3265
+ }
3266
+ if (normalized.startsWith("solana:") || normalized.includes("solana")) {
3267
+ return "solana";
3268
+ }
3269
+ if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
3270
+ return "cosmos";
3271
+ }
3272
+ return void 0;
3273
+ }
3274
+ function normalizeChainType2(chain) {
1548
3275
  if (!chain) return void 0;
1549
3276
  const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
1550
3277
  if (!raw) return void 0;
1551
3278
  const normalized = String(raw).trim().toLowerCase();
1552
- return CHAIN_TYPE_ALIASES[normalized] ?? normalized;
3279
+ return inferChainTypeFromValue2(normalized) ?? normalized;
1553
3280
  }
1554
3281
  function canonicalChainKeyForLink(chain) {
1555
3282
  const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
1556
3283
  if (seiKey) return seiKey;
1557
- return normalizeChainKey(
3284
+ return normalizeChainKey2(
1558
3285
  chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
1559
3286
  );
1560
3287
  }
1561
3288
  var SEI_EVM_CHAIN_ID = "1329";
1562
3289
  var SEI_COSMOS_CHAIN_ID = "pacific-1";
1563
3290
  function canonicalSeiChainKey(chainId) {
1564
- const normalized = normalizeChainKey(chainId);
3291
+ const normalized = normalizeChainKey2(chainId);
1565
3292
  if (!normalized) return null;
1566
3293
  if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
1567
3294
  if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
@@ -1570,40 +3297,43 @@ function canonicalSeiChainKey(chainId) {
1570
3297
  function isZeroAddrLike(a, chainType) {
1571
3298
  if (!a) return true;
1572
3299
  if (!chainType) return false;
1573
- const s = normalizeAddress(a, chainType);
1574
- return s === normalizeAddress(getNativeTokenAddress(chainType), chainType) || s === "0x0000000000000000000000000000000000000000";
3300
+ const s = normalizeAddress2(a, chainType);
3301
+ return s === normalizeAddress2(getNativeTokenAddress2(chainType), chainType) || s === "0x0000000000000000000000000000000000000000";
1575
3302
  }
1576
- function normalizeAddress(address, chainType) {
3303
+ function normalizeAddress2(address, chainType) {
1577
3304
  if (chainType?.toLowerCase?.() === "solana") {
1578
3305
  const trimmed = address.trim();
1579
- return trimmed.startsWith("0x") ? trimmed.toLowerCase() : trimmed;
3306
+ if (isSolanaNativeTokenAlias2(trimmed)) {
3307
+ return NATIVE_SOLANA2;
3308
+ }
3309
+ return trimmed;
1580
3310
  }
1581
3311
  return address.toLowerCase();
1582
3312
  }
1583
3313
  function isNativeTokenAddress(address, chainType) {
1584
3314
  if (!address) return false;
1585
3315
  if (!chainType) return false;
1586
- return normalizeAddress(address, chainType) === normalizeAddress(getNativeTokenAddress(chainType), chainType);
3316
+ return normalizeAddress2(address, chainType) === normalizeAddress2(getNativeTokenAddress2(chainType), chainType);
1587
3317
  }
1588
3318
  function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
1589
- const chainType = normalizeChainType(chain);
3319
+ const chainType = normalizeChainType2(chain);
1590
3320
  const rawAddress = (address ?? "").trim();
1591
- if (chainType === "solana") return rawAddress;
3321
+ if (chainType === "solana") return normalizeAddress2(rawAddress, "solana");
1592
3322
  if (chainType === "cosmos") {
1593
- const chainIdKey = normalizeChainKey(chain.chainId ?? chain.id ?? "");
3323
+ const chainIdKey = normalizeChainKey2(chain.chainId ?? chain.id ?? "");
1594
3324
  const nativeSymbol = chain.nativeCurrency?.symbol?.toUpperCase?.();
1595
3325
  const nativeFromRegistry = chainTokens.find(
1596
- (token) => normalizeChainKey(token.chainId) === chainIdKey && token.symbol?.toUpperCase?.() === nativeSymbol
3326
+ (token) => normalizeChainKey2(token.chainId) === chainIdKey && token.symbol?.toUpperCase?.() === nativeSymbol
1597
3327
  );
1598
3328
  const nativeDenom = (nativeFromRegistry?.address ?? "usei").toLowerCase();
1599
- if (rawAddress.toLowerCase() === NATIVE_EVM) {
3329
+ if (rawAddress.toLowerCase() === NATIVE_EVM2) {
1600
3330
  return nativeDenom;
1601
3331
  }
1602
3332
  return rawAddress.toLowerCase();
1603
3333
  }
1604
3334
  const lowerAddress = rawAddress.toLowerCase();
1605
3335
  if (lowerAddress === "0x0000000000000000000000000000000000000000") {
1606
- return NATIVE_EVM;
3336
+ return NATIVE_EVM2;
1607
3337
  }
1608
3338
  return lowerAddress;
1609
3339
  }
@@ -1620,7 +3350,7 @@ var POPULAR_CHAIN_IDS = /* @__PURE__ */ new Set([
1620
3350
  function filterSupportedChains(chains) {
1621
3351
  const supportedChainTypes = /* @__PURE__ */ new Set(["evm", "solana", "cosmos", "bitcoin"]);
1622
3352
  return chains.filter((chain) => {
1623
- const chainType = normalizeChainType(chain);
3353
+ const chainType = normalizeChainType2(chain);
1624
3354
  if (!chainType) return false;
1625
3355
  if (!supportedChainTypes.has(chainType)) {
1626
3356
  return false;
@@ -1778,7 +3508,7 @@ function getChainPopularityRank(chain) {
1778
3508
  chain.axelarChainName
1779
3509
  ];
1780
3510
  for (const alias of aliases) {
1781
- const key = normalizeChainKey(alias ?? null);
3511
+ const key = normalizeChainKey2(alias ?? null);
1782
3512
  if (!key) continue;
1783
3513
  const rank = popularityByKey[key];
1784
3514
  if (typeof rank === "number") {
@@ -1831,7 +3561,7 @@ var POPULAR_TOKEN_CONTRACTS = /* @__PURE__ */ new Set([
1831
3561
  function normalizeSymbol(symbol) {
1832
3562
  return (symbol ?? "").trim().toUpperCase();
1833
3563
  }
1834
- function normalizeAddress2(address) {
3564
+ function normalizeAddress3(address) {
1835
3565
  return (address ?? "").trim().toLowerCase();
1836
3566
  }
1837
3567
  function hasPositiveBalance(balance) {
@@ -1859,7 +3589,7 @@ function hasPositiveBalance(balance) {
1859
3589
  }
1860
3590
  function isPopularToken(token) {
1861
3591
  const normalizedSymbol = normalizeSymbol(token.symbol);
1862
- const normalizedAddress = normalizeAddress2(token.address);
3592
+ const normalizedAddress = normalizeAddress3(token.address);
1863
3593
  return POPULAR_TOKEN_SYMBOLS.has(normalizedSymbol) || POPULAR_TOKEN_CONTRACTS.has(normalizedAddress);
1864
3594
  }
1865
3595
  function compareText(a, b) {
@@ -2053,6 +3783,16 @@ var Trustware = {
2053
3783
  getWallet() {
2054
3784
  return walletManager.wallet;
2055
3785
  },
3786
+ getIdentity() {
3787
+ return walletManager.identity;
3788
+ },
3789
+ resolveAddressForChain(chain) {
3790
+ return walletManager.resolveAddressForChain(chain);
3791
+ },
3792
+ addIdentityAddress(address) {
3793
+ walletManager.addIdentityAddress(address);
3794
+ return Trustware;
3795
+ },
2056
3796
  /** Simple helpers */
2057
3797
  async getAddress() {
2058
3798
  const w = walletManager.wallet;
@@ -2061,6 +3801,7 @@ var Trustware = {
2061
3801
  },
2062
3802
  // ---- REST methods (re-export) ----
2063
3803
  buildRoute,
3804
+ buildDepositAddress,
2064
3805
  submitReceipt,
2065
3806
  getStatus,
2066
3807
  pollStatus,
@@ -2068,6 +3809,8 @@ var Trustware = {
2068
3809
  getBalancesByAddress,
2069
3810
  useChains,
2070
3811
  useTokens,
3812
+ validateAddressForChain,
3813
+ validateRouteAddresses,
2071
3814
  // ---- Tx helpers ----
2072
3815
  sendRouteTransaction,
2073
3816
  runTopUp
@@ -2631,7 +4374,7 @@ function useRouteBuilder({
2631
4374
  const hasFromChainId = fromChainId !== void 0 && fromChainId !== null && String(fromChainId).trim() !== "";
2632
4375
  const hasToChainId = toChainId !== void 0 && toChainId !== null && String(toChainId).trim() !== "";
2633
4376
  (0, import_react5.useEffect)(() => {
2634
- if (!fromChain || !toChain || !hasFromChainId || !hasToChainId || !fromToken || !toToken || !fromAmountWei || !fromAddress || !toAddress)
4377
+ if (!fromChain || !hasFromChainId || !hasToChainId || !fromToken || !toToken || !fromAmountWei || !fromAddress || !toAddress)
2635
4378
  return;
2636
4379
  abortRef.current?.abort();
2637
4380
  if (!routeKey) {
@@ -2676,6 +4419,9 @@ function useRouteBuilder({
2676
4419
  });
2677
4420
  if (ac.signal.aborted) return;
2678
4421
  const estimate = result?.route?.estimate;
4422
+ if (!result?.txReq?.data || !isEvmTxRequest(result.txReq) && !isSerializedSolanaTxRequest(result.txReq)) {
4423
+ throw new Error("Invalid route response");
4424
+ }
2679
4425
  const fees = estimate?.fees;
2680
4426
  let networkFeesUSD = null;
2681
4427
  if (estimate?.fromAmountUsd && estimate?.toAmountMinUsd) {
@@ -3114,9 +4860,9 @@ function TrustwareProvider({
3114
4860
  const revalidate = (0, import_react9.useCallback)(async () => {
3115
4861
  try {
3116
4862
  await initialize();
3117
- } catch (e) {
4863
+ } catch (e2) {
3118
4864
  setStatus("error");
3119
- setErrors(e instanceof Error ? e.message : String(e));
4865
+ setErrors(e2 instanceof Error ? e2.message : String(e2));
3120
4866
  }
3121
4867
  }, [initialize]);
3122
4868
  (0, import_react9.useEffect)(() => {
@@ -3124,16 +4870,16 @@ function TrustwareProvider({
3124
4870
  const setStatusSafe = (s) => {
3125
4871
  if (!cancelled) setStatus(s);
3126
4872
  };
3127
- const setErrorsSafe = (e) => {
3128
- if (!cancelled) setErrors(e);
4873
+ const setErrorsSafe = (e2) => {
4874
+ if (!cancelled) setErrors(e2);
3129
4875
  };
3130
4876
  (async () => {
3131
4877
  try {
3132
4878
  await initialize(setStatusSafe, setErrorsSafe);
3133
- } catch (e) {
4879
+ } catch (e2) {
3134
4880
  if (!cancelled) {
3135
4881
  setStatus("error");
3136
- setErrors(e instanceof Error ? e.message : String(e));
4882
+ setErrors(e2 instanceof Error ? e2.message : String(e2));
3137
4883
  }
3138
4884
  }
3139
4885
  })();
@@ -3498,7 +5244,7 @@ function DepositProvider({
3498
5244
  const tokensByCanonicalKey = /* @__PURE__ */ new Map();
3499
5245
  for (const token of tokens) {
3500
5246
  const tokenChain = chains.find(
3501
- (chain) => normalizeChainKey(chain.chainId) === normalizeChainKey(token.chainId)
5247
+ (chain) => normalizeChainKey2(chain.chainId) === normalizeChainKey2(token.chainId)
3502
5248
  );
3503
5249
  if (!tokenChain) continue;
3504
5250
  const canonicalAddress = canonicalTokenAddressForChain(
@@ -3506,12 +5252,12 @@ function DepositProvider({
3506
5252
  token.address,
3507
5253
  tokens
3508
5254
  );
3509
- const key = `${normalizeChainKey(token.chainId)}:${canonicalAddress}`;
5255
+ const key = `${normalizeChainKey2(token.chainId)}:${canonicalAddress}`;
3510
5256
  tokensByCanonicalKey.set(key, token);
3511
5257
  }
3512
5258
  const updatedArr = flatenedTokenWithBalancesArr.flatMap((balanceRow) => {
3513
5259
  const chain = chains.find(
3514
- (c) => normalizeChainKey(c.chainId) === normalizeChainKey(balanceRow.chain_id)
5260
+ (c) => normalizeChainKey2(c.chainId) === normalizeChainKey2(balanceRow.chain_id)
3515
5261
  );
3516
5262
  if (!chain) return [];
3517
5263
  const balanceAddress = balanceRow.contract ?? balanceRow.address;
@@ -3520,17 +5266,17 @@ function DepositProvider({
3520
5266
  balanceAddress,
3521
5267
  tokens
3522
5268
  );
3523
- const canonicalKey = `${normalizeChainKey(balanceRow.chain_id)}:${canonicalBalanceAddress}`;
5269
+ const canonicalKey = `${normalizeChainKey2(balanceRow.chain_id)}:${canonicalBalanceAddress}`;
3524
5270
  let foundToken = tokensByCanonicalKey.get(canonicalKey);
3525
5271
  if (!foundToken) {
3526
5272
  const isNativeCategory = balanceRow.category === "native";
3527
5273
  if (isNativeCategory) {
3528
5274
  const nativeAddress = canonicalTokenAddressForChain(
3529
5275
  chain,
3530
- getNativeTokenAddress(chain.type),
5276
+ getNativeTokenAddress2(chain.type),
3531
5277
  tokens
3532
5278
  );
3533
- const nativeKey = `${normalizeChainKey(balanceRow.chain_id)}:${nativeAddress}`;
5279
+ const nativeKey = `${normalizeChainKey2(balanceRow.chain_id)}:${nativeAddress}`;
3534
5280
  foundToken = tokensByCanonicalKey.get(nativeKey);
3535
5281
  }
3536
5282
  }
@@ -3546,11 +5292,9 @@ function DepositProvider({
3546
5292
  iconUrl: foundToken.iconUrl ?? foundToken.logoURI ?? "",
3547
5293
  chainId: balanceRow.chain_id,
3548
5294
  usdPrice: foundToken.usdPrice,
3549
- address: canonicalTokenAddressForChain(
3550
- chain,
3551
- foundToken.address,
3552
- tokens
3553
- ),
5295
+ // Preserve the registry/backend token identifier for downstream
5296
+ // route payloads; canonicalization is only for comparisons.
5297
+ address: foundToken.address,
3554
5298
  chainIconURI: chain?.chainIconURI || "",
3555
5299
  chainData: chain
3556
5300
  }
@@ -3816,8 +5560,8 @@ function AmountSlider({
3816
5560
  }, [max, min, value]);
3817
5561
  const percentage = (0, import_react12.useMemo)(() => getPercentage(), [getPercentage]);
3818
5562
  const handleChange = (0, import_react12.useCallback)(
3819
- (e) => {
3820
- const newValue = Math.min(Math.max(Number(e.target.value), min), max);
5563
+ (e2) => {
5564
+ const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
3821
5565
  onChange(newValue);
3822
5566
  },
3823
5567
  [onChange, min, max]
@@ -4153,7 +5897,7 @@ function AmountInputDisplay({
4153
5897
  type: "text",
4154
5898
  inputMode: "decimal",
4155
5899
  value: amount,
4156
- onChange: (e) => onAmountChange(e.target.value),
5900
+ onChange: (e2) => onAmountChange(e2.target.value),
4157
5901
  onBlur: () => setIsEditing(false),
4158
5902
  readOnly: isFixedAmount,
4159
5903
  style: {
@@ -4312,9 +6056,9 @@ var Dialog = ({
4312
6056
  const firstButtonRef = (0, import_react15.useRef)(null);
4313
6057
  const lastButtonRef = (0, import_react15.useRef)(null);
4314
6058
  (0, import_react15.useEffect)(() => {
4315
- const handleEscape = (e) => {
4316
- if (e.key === "Escape" && open) {
4317
- e.preventDefault();
6059
+ const handleEscape = (e2) => {
6060
+ if (e2.key === "Escape" && open) {
6061
+ e2.preventDefault();
4318
6062
  onCancel();
4319
6063
  }
4320
6064
  };
@@ -4326,17 +6070,17 @@ var Dialog = ({
4326
6070
  };
4327
6071
  }, [open, onCancel]);
4328
6072
  (0, import_react15.useEffect)(() => {
4329
- const handleTabKey = (e) => {
6073
+ const handleTabKey = (e2) => {
4330
6074
  if (!open) return;
4331
- if (e.key === "Tab") {
4332
- if (e.shiftKey) {
6075
+ if (e2.key === "Tab") {
6076
+ if (e2.shiftKey) {
4333
6077
  if (document.activeElement === firstButtonRef.current) {
4334
- e.preventDefault();
6078
+ e2.preventDefault();
4335
6079
  lastButtonRef.current?.focus();
4336
6080
  }
4337
6081
  } else {
4338
6082
  if (document.activeElement === lastButtonRef.current) {
4339
- e.preventDefault();
6083
+ e2.preventDefault();
4340
6084
  firstButtonRef.current?.focus();
4341
6085
  }
4342
6086
  }
@@ -4362,50 +6106,50 @@ var Dialog = ({
4362
6106
  };
4363
6107
  }
4364
6108
  }, [open]);
4365
- const handleOverlayClick = (e) => {
4366
- if (e.target === e.currentTarget) {
6109
+ const handleOverlayClick = (e2) => {
6110
+ if (e2.target === e2.currentTarget) {
4367
6111
  onCancel();
4368
6112
  }
4369
6113
  };
4370
- const handleCancelKeyDown = (e) => {
4371
- if (e.key === "Enter" && !e.shiftKey) {
4372
- e.preventDefault();
6114
+ const handleCancelKeyDown = (e2) => {
6115
+ if (e2.key === "Enter" && !e2.shiftKey) {
6116
+ e2.preventDefault();
4373
6117
  onCancel();
4374
6118
  }
4375
6119
  };
4376
- const handleConfirmKeyDown = (e) => {
4377
- if (e.key === "Enter" && !e.shiftKey) {
4378
- e.preventDefault();
6120
+ const handleConfirmKeyDown = (e2) => {
6121
+ if (e2.key === "Enter" && !e2.shiftKey) {
6122
+ e2.preventDefault();
4379
6123
  onConfirm();
4380
6124
  }
4381
6125
  };
4382
- const handleCancelMouseEnter = (e) => {
4383
- e.currentTarget.style.backgroundColor = "var(--cancel-hover, #e5e7eb)";
6126
+ const handleCancelMouseEnter = (e2) => {
6127
+ e2.currentTarget.style.backgroundColor = "var(--cancel-hover, #e5e7eb)";
4384
6128
  };
4385
- const handleCancelMouseLeave = (e) => {
4386
- e.currentTarget.style.backgroundColor = "var(--cancel-bg, #f3f4f6)";
6129
+ const handleCancelMouseLeave = (e2) => {
6130
+ e2.currentTarget.style.backgroundColor = "var(--cancel-bg, #f3f4f6)";
4387
6131
  };
4388
- const handleConfirmMouseEnter = (e) => {
4389
- e.currentTarget.style.backgroundColor = "var(--confirm-hover, #dc2626)";
6132
+ const handleConfirmMouseEnter = (e2) => {
6133
+ e2.currentTarget.style.backgroundColor = "var(--confirm-hover, #dc2626)";
4390
6134
  };
4391
- const handleConfirmMouseLeave = (e) => {
4392
- e.currentTarget.style.backgroundColor = "var(--confirm-bg, #ef4444)";
6135
+ const handleConfirmMouseLeave = (e2) => {
6136
+ e2.currentTarget.style.backgroundColor = "var(--confirm-bg, #ef4444)";
4393
6137
  };
4394
- const handleCancelFocus = (e) => {
4395
- e.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.5)";
4396
- e.currentTarget.style.borderColor = "#3b82f6";
6138
+ const handleCancelFocus = (e2) => {
6139
+ e2.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.5)";
6140
+ e2.currentTarget.style.borderColor = "#3b82f6";
4397
6141
  };
4398
- const handleCancelBlur = (e) => {
4399
- e.currentTarget.style.boxShadow = "";
4400
- e.currentTarget.style.borderColor = "var(--cancel-border, #d1d5db)";
6142
+ const handleCancelBlur = (e2) => {
6143
+ e2.currentTarget.style.boxShadow = "";
6144
+ e2.currentTarget.style.borderColor = "var(--cancel-border, #d1d5db)";
4401
6145
  };
4402
- const handleConfirmFocus = (e) => {
4403
- e.currentTarget.style.boxShadow = "0 0 0 3px rgba(239, 68, 68, 0.5)";
4404
- e.currentTarget.style.borderColor = "#ef4444";
6146
+ const handleConfirmFocus = (e2) => {
6147
+ e2.currentTarget.style.boxShadow = "0 0 0 3px rgba(239, 68, 68, 0.5)";
6148
+ e2.currentTarget.style.borderColor = "#ef4444";
4405
6149
  };
4406
- const handleConfirmBlur = (e) => {
4407
- e.currentTarget.style.boxShadow = "";
4408
- e.currentTarget.style.borderColor = "transparent";
6150
+ const handleConfirmBlur = (e2) => {
6151
+ e2.currentTarget.style.boxShadow = "";
6152
+ e2.currentTarget.style.borderColor = "transparent";
4409
6153
  };
4410
6154
  if (!open) return null;
4411
6155
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -4656,19 +6400,19 @@ function SwipeToConfirmTokens({
4656
6400
  longPressAnimationRef.current = requestAnimationFrame(animateProgress);
4657
6401
  }, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
4658
6402
  const handleKeyDown = (0, import_react16.useCallback)(
4659
- (e) => {
6403
+ (e2) => {
4660
6404
  if (disabled || isComplete) return;
4661
- if (e.key === "Enter" || e.key === " ") {
4662
- e.preventDefault();
6405
+ if (e2.key === "Enter" || e2.key === " ") {
6406
+ e2.preventDefault();
4663
6407
  startLongPress();
4664
6408
  }
4665
6409
  },
4666
6410
  [disabled, isComplete, startLongPress]
4667
6411
  );
4668
6412
  const handleKeyUp = (0, import_react16.useCallback)(
4669
- (e) => {
4670
- if (e.key === "Enter" || e.key === " ") {
4671
- e.preventDefault();
6413
+ (e2) => {
6414
+ if (e2.key === "Enter" || e2.key === " ") {
6415
+ e2.preventDefault();
4672
6416
  cancelLongPress();
4673
6417
  }
4674
6418
  },
@@ -4681,17 +6425,17 @@ function SwipeToConfirmTokens({
4681
6425
  cancelAnimationFrame(longPressAnimationRef.current);
4682
6426
  };
4683
6427
  }, []);
4684
- const handleMouseDown = (e) => {
4685
- e.preventDefault();
6428
+ const handleMouseDown = (e2) => {
6429
+ e2.preventDefault();
4686
6430
  handleDragStart();
4687
6431
  };
4688
6432
  const handleMouseMove = (0, import_react16.useCallback)(
4689
- (e) => handleDragMove(e.clientX),
6433
+ (e2) => handleDragMove(e2.clientX),
4690
6434
  [handleDragMove]
4691
6435
  );
4692
6436
  const handleMouseUp = (0, import_react16.useCallback)(() => handleDragEnd(), [handleDragEnd]);
4693
6437
  const handleTouchStart = () => handleDragStart();
4694
- const handleTouchMove = (e) => handleDragMove(e.touches[0].clientX);
6438
+ const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
4695
6439
  const handleTouchEnd = () => handleDragEnd();
4696
6440
  (0, import_react16.useEffect)(() => {
4697
6441
  if (isDragging) {
@@ -5442,7 +7186,13 @@ function TokenSwipePill({
5442
7186
  const startXRef = (0, import_react18.useRef)(0);
5443
7187
  const containerRef = (0, import_react18.useRef)(null);
5444
7188
  const currentIndex = tokens.findIndex(
5445
- (t) => t.address === selectedToken.address && t.symbol === selectedToken.symbol
7189
+ (t) => normalizeAddress2(
7190
+ t.address,
7191
+ t.chainData?.type ?? t.chainData?.chainType
7192
+ ) === normalizeAddress2(
7193
+ selectedToken.address,
7194
+ selectedToken.chainData?.type ?? selectedToken.chainData?.chainType
7195
+ ) && t.symbol === selectedToken.symbol
5446
7196
  );
5447
7197
  const swipeThreshold = 30;
5448
7198
  const hasMultipleTokens = tokens.length > 1;
@@ -5480,27 +7230,27 @@ function TokenSwipePill({
5480
7230
  }
5481
7231
  setDragOffset(0);
5482
7232
  }, [isDragging, dragOffset, currentIndex, tokens, onTokenChange]);
5483
- const handleMouseDown = (e) => {
7233
+ const handleMouseDown = (e2) => {
5484
7234
  if (!hasMultipleTokens) return;
5485
- e.preventDefault();
5486
- handleDragStart(e.clientX);
7235
+ e2.preventDefault();
7236
+ handleDragStart(e2.clientX);
5487
7237
  };
5488
7238
  const handleMouseMove = (0, import_react18.useCallback)(
5489
- (e) => {
5490
- handleDragMove(e.clientX);
7239
+ (e2) => {
7240
+ handleDragMove(e2.clientX);
5491
7241
  },
5492
7242
  [handleDragMove]
5493
7243
  );
5494
7244
  const handleMouseUp = (0, import_react18.useCallback)(() => {
5495
7245
  handleDragEnd();
5496
7246
  }, [handleDragEnd]);
5497
- const handleTouchStart = (e) => {
7247
+ const handleTouchStart = (e2) => {
5498
7248
  if (!hasMultipleTokens) return;
5499
- handleDragStart(e.touches[0].clientX);
7249
+ handleDragStart(e2.touches[0].clientX);
5500
7250
  };
5501
- const handleTouchMove = (e) => {
7251
+ const handleTouchMove = (e2) => {
5502
7252
  if (!hasMultipleTokens) return;
5503
- handleDragMove(e.touches[0].clientX);
7253
+ handleDragMove(e2.touches[0].clientX);
5504
7254
  };
5505
7255
  const handleTouchEnd = () => {
5506
7256
  handleDragEnd();
@@ -5747,8 +7497,8 @@ function TokenSwipePill({
5747
7497
  return tokens.map((token, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
5748
7498
  "div",
5749
7499
  {
5750
- onClick: (e) => {
5751
- e.stopPropagation();
7500
+ onClick: (e2) => {
7501
+ e2.stopPropagation();
5752
7502
  onTokenChange(token);
5753
7503
  },
5754
7504
  style: {
@@ -5802,8 +7552,8 @@ function TokenSwipePill({
5802
7552
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
5803
7553
  "div",
5804
7554
  {
5805
- onClick: (e) => {
5806
- e.stopPropagation();
7555
+ onClick: (e2) => {
7556
+ e2.stopPropagation();
5807
7557
  onTokenChange(token);
5808
7558
  },
5809
7559
  style: {
@@ -5906,8 +7656,8 @@ function TokenSwipePill({
5906
7656
  cursor: "pointer",
5907
7657
  backgroundColor: "transparent"
5908
7658
  },
5909
- onClick: (e) => {
5910
- e.stopPropagation();
7659
+ onClick: (e2) => {
7660
+ e2.stopPropagation();
5911
7661
  onExpandClick?.();
5912
7662
  },
5913
7663
  children: [
@@ -6189,8 +7939,8 @@ function WidgetContainer({
6189
7939
  if (theme === "system") {
6190
7940
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
6191
7941
  setResolvedTheme(mediaQuery.matches ? "dark" : "light");
6192
- const handler = (e) => {
6193
- setResolvedTheme(e.matches ? "dark" : "light");
7942
+ const handler = (e2) => {
7943
+ setResolvedTheme(e2.matches ? "dark" : "light");
6194
7944
  };
6195
7945
  mediaQuery.addEventListener("change", handler);
6196
7946
  return () => mediaQuery.removeEventListener("change", handler);
@@ -6474,7 +8224,6 @@ function Home({ style: _style }) {
6474
8224
  amount,
6475
8225
  setAmount,
6476
8226
  setCurrentStep,
6477
- walletAddress,
6478
8227
  connectWallet,
6479
8228
  amountInputMode,
6480
8229
  setAmountInputMode,
@@ -6534,10 +8283,6 @@ function Home({ style: _style }) {
6534
8283
  })();
6535
8284
  const handleWalletSelect = async (wallet) => {
6536
8285
  setIsCryptoDropdownOpen(false);
6537
- if (walletAddress) {
6538
- setCurrentStep("crypto-pay");
6539
- return;
6540
- }
6541
8286
  try {
6542
8287
  await connectWallet(wallet);
6543
8288
  setCurrentStep("crypto-pay");
@@ -7536,6 +9281,7 @@ function SelectToken({ style }) {
7536
9281
  const handleChainSelect = (chain) => {
7537
9282
  const chainId = Number(chain.chainId ?? chain.id);
7538
9283
  setSelectedChain({
9284
+ ...chain,
7539
9285
  chainId,
7540
9286
  name: resolveChainLabel(chain),
7541
9287
  shortName: chain.nativeCurrency?.symbol ?? resolveChainLabel(chain).slice(0, 3).toUpperCase(),
@@ -7551,8 +9297,9 @@ function SelectToken({ style }) {
7551
9297
  selectedChain?.chainId,
7552
9298
  walletAddress
7553
9299
  );
9300
+ const chainType = normalizeChainType2(selectedChain);
7554
9301
  const match = balance.find(
7555
- (b) => b.contract?.toLowerCase() === token.address.toLowerCase()
9302
+ (b) => normalizeAddress2(b.contract ?? b.address ?? "", chainType) === normalizeAddress2(token.address, chainType)
7556
9303
  );
7557
9304
  const tokenWithBalance = {
7558
9305
  ...token,
@@ -8125,7 +9872,7 @@ function SelectToken({ style }) {
8125
9872
  type: "text",
8126
9873
  placeholder: "Search tokens...",
8127
9874
  value: searchQuery,
8128
- onChange: (e) => setSearchQuery(e.target.value),
9875
+ onChange: (e2) => setSearchQuery(e2.target.value),
8129
9876
  style: {
8130
9877
  width: "100%",
8131
9878
  paddingLeft: spacing[8],
@@ -8718,8 +10465,8 @@ function SelectToken({ style }) {
8718
10465
  objectFit: "cover",
8719
10466
  flexShrink: 0
8720
10467
  },
8721
- onError: (e) => {
8722
- const target = e.target;
10468
+ onError: (e2) => {
10469
+ const target = e2.target;
8723
10470
  target.style.display = "none";
8724
10471
  if (target.nextElementSibling) {
8725
10472
  target.nextElementSibling.style.display = "flex";
@@ -8936,7 +10683,7 @@ function SelectToken({ style }) {
8936
10683
 
8937
10684
  // src/widget/pages/CryptoPay.tsx
8938
10685
  var import_react23 = require("react");
8939
- var import_viem = require("viem");
10686
+ var import_viem2 = require("viem");
8940
10687
  var import_jsx_runtime17 = require("react/jsx-runtime");
8941
10688
  function normalizeTokenAddressForCompare(chain, addr) {
8942
10689
  const chainType = (chain.type ?? chain.chainType ?? "").toLowerCase();
@@ -9129,18 +10876,18 @@ function CryptoPay({ style }) {
9129
10876
  const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
9130
10877
  const routeConfig = (0, import_react23.useMemo)(() => {
9131
10878
  const toChainId = config.routes.toChain;
9132
- const toChainKey = normalizeChainKey(toChainId);
10879
+ const toChainKey = normalizeChainKey2(toChainId);
9133
10880
  const toChain = toChainKey ? chains.find(
9134
- (chain) => normalizeChainKey(chain.chainId ?? chain.id) === toChainKey
10881
+ (chain) => normalizeChainKey2(chain.chainId ?? chain.id) === toChainKey
9135
10882
  ) ?? null : null;
9136
10883
  const object = {
9137
10884
  fromChain: selectedChain?.chainId ?? selectedChain?.id ?? "",
9138
10885
  fromChainId: selectedChain?.chainId ?? selectedChain?.id,
9139
- toChain,
10886
+ toChain: toChain ?? toChainId,
9140
10887
  toChainId,
9141
10888
  toToken: config.routes.toToken,
9142
10889
  toAddress: config.routes.toAddress || walletAddress || void 0,
9143
- fromToken: selectedToken?.address ?? getNativeTokenAddress(selectedChain?.type ?? selectedChain?.chainType),
10890
+ fromToken: selectedToken?.address ?? getNativeTokenAddress2(selectedChain?.type ?? selectedChain?.chainType),
9144
10891
  fromAmountWei: amountWei ?? 0n,
9145
10892
  fromAmountUsd: amountComputation.usdAmount || void 0,
9146
10893
  fromAddress: walletAddress || void 0,
@@ -9195,7 +10942,7 @@ function CryptoPay({ style }) {
9195
10942
  selectedToken,
9196
10943
  walletAddress
9197
10944
  ]);
9198
- const routeError = routeBuilderError && "No successful provider response";
10945
+ const routeError = routeBuilderError ?? null;
9199
10946
  const actionErrorMessage = routePrerequisiteError || routeError || null;
9200
10947
  const { emitError } = useTrustware();
9201
10948
  (0, import_react23.useEffect)(() => {
@@ -9252,15 +10999,15 @@ function CryptoPay({ style }) {
9252
10999
  if (!rpcUrl) {
9253
11000
  return null;
9254
11001
  }
9255
- return (0, import_viem.createPublicClient)({
9256
- transport: (0, import_viem.http)(rpcUrl)
11002
+ return (0, import_viem2.createPublicClient)({
11003
+ transport: (0, import_viem2.http)(rpcUrl)
9257
11004
  });
9258
11005
  }, [rpcUrl]);
9259
11006
  const isNativeSelected = (0, import_react23.useMemo)(() => {
9260
11007
  const address = selectedToken?.address;
9261
11008
  return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
9262
11009
  selectedChain,
9263
- getNativeTokenAddress(chainType)
11010
+ getNativeTokenAddress2(chainType)
9264
11011
  );
9265
11012
  }, [chainType, selectedChain, selectedToken?.address]);
9266
11013
  const spender = (0, import_react23.useMemo)(() => {
@@ -9280,7 +11027,7 @@ function CryptoPay({ style }) {
9280
11027
  setIsReadingAllowance(true);
9281
11028
  const res = await client.readContract({
9282
11029
  address: selectedToken.address,
9283
- abi: import_viem.erc20Abi,
11030
+ abi: import_viem2.erc20Abi,
9284
11031
  functionName: "allowance",
9285
11032
  args: [walletAddress, spender]
9286
11033
  });
@@ -9307,7 +11054,7 @@ function CryptoPay({ style }) {
9307
11054
  return;
9308
11055
  }
9309
11056
  const wallet = Trustware.getWallet();
9310
- if (!wallet) {
11057
+ if (!wallet || wallet.ecosystem !== "evm") {
9311
11058
  return;
9312
11059
  }
9313
11060
  setIsApproving(true);
@@ -9324,8 +11071,8 @@ function CryptoPay({ style }) {
9324
11071
  }
9325
11072
  }
9326
11073
  }
9327
- const data = (0, import_viem.encodeFunctionData)({
9328
- abi: import_viem.erc20Abi,
11074
+ const data = (0, import_viem2.encodeFunctionData)({
11075
+ abi: import_viem2.erc20Abi,
9329
11076
  functionName: "approve",
9330
11077
  args: [spender, amountWei]
9331
11078
  });
@@ -9526,8 +11273,12 @@ function CryptoPay({ style }) {
9526
11273
  await handleConfirm();
9527
11274
  }, [handleApproveExact, handleConfirm, needsApproval]);
9528
11275
  const orderedTokens = (0, import_react23.useMemo)(() => {
11276
+ const selectedTokenChainType = selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType;
9529
11277
  const index = yourWalletTokens.findIndex(
9530
- (t) => t.address?.toLowerCase() === selectedToken?.address?.toLowerCase()
11278
+ (t) => normalizeAddress2(
11279
+ t.address,
11280
+ t.chainData?.type ?? t.chainData?.chainType
11281
+ ) === normalizeAddress2(selectedToken?.address ?? "", selectedTokenChainType)
9531
11282
  );
9532
11283
  let _tok = [];
9533
11284
  if (index === -1) {
@@ -9587,7 +11338,10 @@ function CryptoPay({ style }) {
9587
11338
  const isWalletConnected = walletStatus === "connected";
9588
11339
  const canSwipe = parsedAmount > 0 && selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
9589
11340
  const swipeResetKey = (0, import_react23.useMemo)(() => {
9590
- const tokenAddress = selectedToken?.address?.toLowerCase() ?? "no-token";
11341
+ const tokenAddress = selectedToken ? normalizeAddress2(
11342
+ selectedToken.address,
11343
+ selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
11344
+ ) : "no-token";
9591
11345
  const chainId = selectedToken?.chainData?.chainId ?? selectedChain?.chainId ?? "no-chain";
9592
11346
  return [
9593
11347
  tokenAddress,
@@ -11940,6 +13694,7 @@ init_constants();
11940
13694
  DEFAULT_RETRY_CONFIG,
11941
13695
  DEFAULT_SLIPPAGE,
11942
13696
  DEFAULT_THEME,
13697
+ IdentityStore,
11943
13698
  RateLimitError,
11944
13699
  SDK_NAME,
11945
13700
  SDK_VERSION,
@@ -11948,12 +13703,22 @@ init_constants();
11948
13703
  TrustwareProvider,
11949
13704
  TrustwareWidget,
11950
13705
  WALLETCONNECT_PROJECT_ID,
13706
+ buildWalletIdentityAddress,
11951
13707
  connectDetectedWallet,
13708
+ createWalletIdentity,
13709
+ resolveWalletAddressForChain,
11952
13710
  toWalletInterfaceFromDetected,
13711
+ upsertWalletIdentityAddress,
11953
13712
  useEIP1193,
11954
13713
  useTrustware,
11955
13714
  useWagmi,
11956
13715
  useWalletDetection,
11957
- useWireDetectionIntoManager
13716
+ useWireDetectionIntoManager,
13717
+ validateAddressForChain,
13718
+ validateBtcAddress,
13719
+ validateEvmAddress,
13720
+ validateRouteAddresses,
13721
+ validateSeiAddress,
13722
+ validateSolanaAddress
11958
13723
  });
11959
13724
  //# sourceMappingURL=index.cjs.map