@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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/index.cjs +2035 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +193 -31
- package/dist/index.d.ts +193 -31
- package/dist/index.mjs +2017 -263
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
4
|
var __esm = (fn, res) => function __init() {
|
|
4
5
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
6
|
};
|
|
@@ -7,6 +8,7 @@ var __export = (target, all) => {
|
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
10
|
};
|
|
11
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
12
|
|
|
11
13
|
// src/config/defaults.ts
|
|
12
14
|
var DEFAULT_SLIPPAGE, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_THEME, DEFAULT_MESSAGES;
|
|
@@ -52,7 +54,7 @@ var init_constants = __esm({
|
|
|
52
54
|
"src/constants.ts"() {
|
|
53
55
|
"use strict";
|
|
54
56
|
SDK_NAME = "@trustware/sdk";
|
|
55
|
-
SDK_VERSION = "1.0.
|
|
57
|
+
SDK_VERSION = "1.0.17-staging.14";
|
|
56
58
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
57
59
|
API_PREFIX = "/api";
|
|
58
60
|
ASSETS_BASE_URL = "https://app.trustware.io";
|
|
@@ -247,6 +249,75 @@ var init_store = __esm({
|
|
|
247
249
|
}
|
|
248
250
|
});
|
|
249
251
|
|
|
252
|
+
// src/utils/chains.ts
|
|
253
|
+
function inferChainTypeFromValue(normalized) {
|
|
254
|
+
if (!normalized) return void 0;
|
|
255
|
+
const aliased = CHAIN_TYPE_ALIASES[normalized];
|
|
256
|
+
if (aliased) return aliased;
|
|
257
|
+
if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
|
|
258
|
+
return normalized;
|
|
259
|
+
}
|
|
260
|
+
if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
|
|
261
|
+
return "evm";
|
|
262
|
+
}
|
|
263
|
+
if (normalized.startsWith("solana:") || normalized.includes("solana")) {
|
|
264
|
+
return "solana";
|
|
265
|
+
}
|
|
266
|
+
if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
|
|
267
|
+
return "cosmos";
|
|
268
|
+
}
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
271
|
+
function normalizeChainKey(value) {
|
|
272
|
+
if (value === void 0 || value === null) return "";
|
|
273
|
+
return String(value).trim().toLowerCase();
|
|
274
|
+
}
|
|
275
|
+
function normalizeChainType(chain) {
|
|
276
|
+
if (!chain) return void 0;
|
|
277
|
+
const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
|
|
278
|
+
if (!raw) return void 0;
|
|
279
|
+
const normalized = String(raw).trim().toLowerCase();
|
|
280
|
+
return inferChainTypeFromValue(normalized) ?? normalized;
|
|
281
|
+
}
|
|
282
|
+
function getNativeTokenAddress(chainType) {
|
|
283
|
+
return normalizeChainType(chainType) === "solana" ? NATIVE_SOLANA : NATIVE_EVM;
|
|
284
|
+
}
|
|
285
|
+
function isSolanaNativeTokenAlias(address) {
|
|
286
|
+
if (!address) return false;
|
|
287
|
+
const trimmed = address.trim();
|
|
288
|
+
if (!trimmed) return false;
|
|
289
|
+
return trimmed === NATIVE_SOLANA || trimmed.toLowerCase() === NATIVE_EVM;
|
|
290
|
+
}
|
|
291
|
+
function normalizeAddress(address, chainType) {
|
|
292
|
+
const trimmed = address.trim();
|
|
293
|
+
if (normalizeChainType(chainType) === "solana") {
|
|
294
|
+
if (isSolanaNativeTokenAlias(trimmed)) {
|
|
295
|
+
return NATIVE_SOLANA;
|
|
296
|
+
}
|
|
297
|
+
return trimmed;
|
|
298
|
+
}
|
|
299
|
+
return trimmed.toLowerCase();
|
|
300
|
+
}
|
|
301
|
+
function isZeroAddressLike(address, chainType) {
|
|
302
|
+
if (!address) return true;
|
|
303
|
+
const normalized = normalizeAddress(address, chainType);
|
|
304
|
+
return normalized === normalizeAddress(getNativeTokenAddress(chainType), chainType) || normalized === "0x0000000000000000000000000000000000000000";
|
|
305
|
+
}
|
|
306
|
+
var NATIVE_EVM, NATIVE_SOLANA, CHAIN_TYPE_ALIASES;
|
|
307
|
+
var init_chains = __esm({
|
|
308
|
+
"src/utils/chains.ts"() {
|
|
309
|
+
"use strict";
|
|
310
|
+
NATIVE_EVM = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
311
|
+
NATIVE_SOLANA = "So11111111111111111111111111111111111111111";
|
|
312
|
+
CHAIN_TYPE_ALIASES = {
|
|
313
|
+
btc: "bitcoin",
|
|
314
|
+
bitcoin: "bitcoin",
|
|
315
|
+
sei: "cosmos",
|
|
316
|
+
"pacific-1": "cosmos"
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
250
321
|
// src/config/index.ts
|
|
251
322
|
var init_config2 = __esm({
|
|
252
323
|
"src/config/index.ts"() {
|
|
@@ -401,16 +472,28 @@ __export(registry_exports, {
|
|
|
401
472
|
NATIVE: () => NATIVE,
|
|
402
473
|
Registry: () => Registry
|
|
403
474
|
});
|
|
475
|
+
function getChainAliases(chain) {
|
|
476
|
+
const values = [
|
|
477
|
+
chain.chainId,
|
|
478
|
+
chain.id,
|
|
479
|
+
chain.networkIdentifier,
|
|
480
|
+
chain.axelarChainName,
|
|
481
|
+
chain.networkName
|
|
482
|
+
];
|
|
483
|
+
return values.map((value) => normalizeChainKey(value)).filter(Boolean);
|
|
484
|
+
}
|
|
404
485
|
var NATIVE, Registry;
|
|
405
486
|
var init_registry = __esm({
|
|
406
487
|
"src/registry.ts"() {
|
|
407
488
|
"use strict";
|
|
408
489
|
init_store();
|
|
490
|
+
init_chains();
|
|
409
491
|
NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
410
492
|
Registry = class {
|
|
411
493
|
constructor(baseURL) {
|
|
412
494
|
this.baseURL = baseURL;
|
|
413
495
|
this._chainsById = /* @__PURE__ */ new Map();
|
|
496
|
+
this._chainAliases = /* @__PURE__ */ new Map();
|
|
414
497
|
this._tokensByChain = /* @__PURE__ */ new Map();
|
|
415
498
|
this._loaded = false;
|
|
416
499
|
this._loadingPromise = null;
|
|
@@ -428,13 +511,18 @@ var init_registry = __esm({
|
|
|
428
511
|
this._loadingPromise = null;
|
|
429
512
|
}
|
|
430
513
|
}
|
|
514
|
+
storeToken(chainKey, token) {
|
|
515
|
+
const list = this._tokensByChain.get(chainKey) ?? [];
|
|
516
|
+
list.push(token);
|
|
517
|
+
this._tokensByChain.set(chainKey, list);
|
|
518
|
+
}
|
|
431
519
|
async load() {
|
|
432
520
|
const cfg = TrustwareConfigStore.get();
|
|
433
521
|
const [chainsRes, tokensRes] = await Promise.all([
|
|
434
|
-
fetch(`${this.baseURL}/
|
|
522
|
+
fetch(`${this.baseURL}/v1/routes/chains`, {
|
|
435
523
|
headers: { Accept: "application/json", "X-API-Key": cfg.apiKey }
|
|
436
524
|
}),
|
|
437
|
-
fetch(`${this.baseURL}/
|
|
525
|
+
fetch(`${this.baseURL}/v1/routes/tokens`, {
|
|
438
526
|
headers: { Accept: "application/json", "X-API-Key": cfg.apiKey }
|
|
439
527
|
})
|
|
440
528
|
]);
|
|
@@ -443,58 +531,80 @@ var init_registry = __esm({
|
|
|
443
531
|
const chains = await chainsRes.json();
|
|
444
532
|
const tokens = await tokensRes.json();
|
|
445
533
|
const chainsArr = Array.isArray(chains) ? chains : chains.data ?? [];
|
|
446
|
-
for (const
|
|
447
|
-
const canonical =
|
|
534
|
+
for (const chain of chainsArr) {
|
|
535
|
+
const canonical = chain?.chainId ?? chain?.id;
|
|
448
536
|
if (canonical == null) continue;
|
|
449
|
-
const chainId = c.chainId ?? canonical;
|
|
450
537
|
const normalized = {
|
|
451
|
-
...
|
|
452
|
-
id:
|
|
453
|
-
chainId
|
|
538
|
+
...chain,
|
|
539
|
+
id: chain.id ?? canonical,
|
|
540
|
+
chainId: chain.chainId ?? canonical
|
|
454
541
|
};
|
|
455
|
-
|
|
542
|
+
const canonicalKey = normalizeChainKey(canonical);
|
|
543
|
+
this._chainsById.set(canonicalKey, normalized);
|
|
544
|
+
for (const alias of getChainAliases(normalized)) {
|
|
545
|
+
this._chainAliases.set(alias, canonicalKey);
|
|
546
|
+
}
|
|
456
547
|
}
|
|
457
548
|
const tokensArr = Array.isArray(tokens) ? tokens : tokens.data ?? [];
|
|
458
|
-
for (const
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
const id = String(canonical);
|
|
549
|
+
for (const token of tokensArr) {
|
|
550
|
+
const chainRef = token?.chainId;
|
|
551
|
+
if (chainRef == null) continue;
|
|
462
552
|
const normalized = {
|
|
463
|
-
...
|
|
464
|
-
chainId:
|
|
553
|
+
...token,
|
|
554
|
+
chainId: token.chainId ?? chainRef
|
|
465
555
|
};
|
|
466
|
-
|
|
467
|
-
|
|
556
|
+
const resolvedChain = this.chain(chainRef);
|
|
557
|
+
const aliases = resolvedChain ? getChainAliases(resolvedChain) : [normalizeChainKey(chainRef)];
|
|
558
|
+
for (const alias of aliases) {
|
|
559
|
+
this.storeToken(alias, normalized);
|
|
560
|
+
}
|
|
468
561
|
}
|
|
469
562
|
this._loaded = true;
|
|
470
563
|
}
|
|
471
564
|
chains() {
|
|
472
565
|
return Array.from(this._chainsById.values());
|
|
473
566
|
}
|
|
474
|
-
chain(
|
|
475
|
-
|
|
567
|
+
chain(chainRef) {
|
|
568
|
+
const normalized = normalizeChainKey(chainRef);
|
|
569
|
+
const canonicalKey = this._chainAliases.get(normalized) ?? normalized;
|
|
570
|
+
return this._chainsById.get(canonicalKey);
|
|
476
571
|
}
|
|
477
572
|
allTokens() {
|
|
478
|
-
const
|
|
573
|
+
const unique = /* @__PURE__ */ new Map();
|
|
479
574
|
for (const list of this._tokensByChain.values()) {
|
|
480
|
-
|
|
575
|
+
for (const token of list) {
|
|
576
|
+
unique.set(`${token.chainId}:${token.address}`, token);
|
|
577
|
+
}
|
|
481
578
|
}
|
|
482
|
-
return
|
|
579
|
+
return Array.from(unique.values());
|
|
483
580
|
}
|
|
484
|
-
tokens(
|
|
485
|
-
return this._tokensByChain.get(
|
|
581
|
+
tokens(chainRef) {
|
|
582
|
+
return this._tokensByChain.get(normalizeChainKey(chainRef)) ?? [];
|
|
486
583
|
}
|
|
487
|
-
|
|
584
|
+
findToken(chainRef, address) {
|
|
585
|
+
const chain = this.chain(chainRef);
|
|
586
|
+
const chainType = normalizeChainType(chain);
|
|
587
|
+
const normalizedAddress = normalizeAddress(address, chainType);
|
|
588
|
+
return this.tokens(chainRef).find((token) => {
|
|
589
|
+
return normalizeAddress(token.address, chainType) === normalizedAddress;
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
resolveToken(chainRef, input) {
|
|
488
593
|
if (!input) return void 0;
|
|
489
594
|
const s = String(input).trim();
|
|
595
|
+
const chain = this.chain(chainRef);
|
|
596
|
+
const chainType = normalizeChainType(chain);
|
|
490
597
|
if (/^0x[0-9a-fA-F]{40}$/.test(s)) return s;
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
if (["ETH", "MATIC", "AVAX", "BNB", "NATIVE"].includes(s.toUpperCase()))
|
|
495
|
-
return NATIVE;
|
|
496
|
-
|
|
497
|
-
const hit =
|
|
598
|
+
if (chainType === "solana" && s.length > 20) return s;
|
|
599
|
+
const nativeAddress = getNativeTokenAddress(chainType);
|
|
600
|
+
const nativeSymbol = chain?.nativeCurrency?.symbol?.toUpperCase?.();
|
|
601
|
+
if (nativeSymbol && s.toUpperCase() === nativeSymbol || ["ETH", "MATIC", "AVAX", "BNB", "SOL", "NATIVE"].includes(s.toUpperCase())) {
|
|
602
|
+
return chainType === "solana" ? nativeAddress : NATIVE;
|
|
603
|
+
}
|
|
604
|
+
const hit = this.tokens(chainRef).find((token) => {
|
|
605
|
+
if (!token.symbol) return false;
|
|
606
|
+
return token.symbol.toUpperCase() === s.toUpperCase();
|
|
607
|
+
});
|
|
498
608
|
if (hit) return hit.address;
|
|
499
609
|
return s;
|
|
500
610
|
}
|
|
@@ -640,6 +750,7 @@ function useEIP1193(eth) {
|
|
|
640
750
|
if (!eth?.request) throw new Error("useEIP1193: invalid provider");
|
|
641
751
|
let switching = false;
|
|
642
752
|
return {
|
|
753
|
+
ecosystem: "evm",
|
|
643
754
|
type: "eip1193",
|
|
644
755
|
async getAddress() {
|
|
645
756
|
const [a] = await eth.request({
|
|
@@ -661,12 +772,12 @@ function useEIP1193(eth) {
|
|
|
661
772
|
method: "wallet_switchEthereumChain",
|
|
662
773
|
params: [{ chainId: hex }]
|
|
663
774
|
});
|
|
664
|
-
} catch (
|
|
665
|
-
if (
|
|
775
|
+
} catch (e2) {
|
|
776
|
+
if (e2?.code === 4902) {
|
|
666
777
|
await addThenSwitch(eth, chainId);
|
|
667
|
-
} else if (
|
|
778
|
+
} else if (e2?.code === 4001) {
|
|
668
779
|
} else {
|
|
669
|
-
throw
|
|
780
|
+
throw e2;
|
|
670
781
|
}
|
|
671
782
|
} finally {
|
|
672
783
|
switching = false;
|
|
@@ -711,11 +822,11 @@ function useWagmi(client) {
|
|
|
711
822
|
method: "wallet_switchEthereumChain",
|
|
712
823
|
params: [{ chainId: hex }]
|
|
713
824
|
});
|
|
714
|
-
} catch (
|
|
715
|
-
if (
|
|
716
|
-
else if (
|
|
825
|
+
} catch (e2) {
|
|
826
|
+
if (e2?.code === 4902) await addThenSwitch(eth, target);
|
|
827
|
+
else if (e2?.code === 4001)
|
|
717
828
|
;
|
|
718
|
-
else throw
|
|
829
|
+
else throw e2;
|
|
719
830
|
}
|
|
720
831
|
} finally {
|
|
721
832
|
switching = false;
|
|
@@ -747,6 +858,7 @@ function useWagmi(client) {
|
|
|
747
858
|
}
|
|
748
859
|
}
|
|
749
860
|
return {
|
|
861
|
+
ecosystem: "evm",
|
|
750
862
|
type: "wagmi",
|
|
751
863
|
getAddress,
|
|
752
864
|
getChainId,
|
|
@@ -755,9 +867,123 @@ function useWagmi(client) {
|
|
|
755
867
|
};
|
|
756
868
|
}
|
|
757
869
|
|
|
870
|
+
// src/wallets/solana.ts
|
|
871
|
+
import { Connection, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
872
|
+
var SOLANA_WALLET_IDS = [
|
|
873
|
+
"phantom-solana",
|
|
874
|
+
"solflare",
|
|
875
|
+
"backpack"
|
|
876
|
+
];
|
|
877
|
+
function getPublicKeyString(provider) {
|
|
878
|
+
const publicKey = provider?.publicKey;
|
|
879
|
+
if (!publicKey) return null;
|
|
880
|
+
const text = publicKey.toString().trim();
|
|
881
|
+
return text || null;
|
|
882
|
+
}
|
|
883
|
+
function decodeBase64(serializedTransaction) {
|
|
884
|
+
const trimmed = serializedTransaction.trim();
|
|
885
|
+
if (typeof Buffer !== "undefined") {
|
|
886
|
+
return Uint8Array.from(Buffer.from(trimmed, "base64"));
|
|
887
|
+
}
|
|
888
|
+
const binary = globalThis.atob(trimmed);
|
|
889
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
890
|
+
}
|
|
891
|
+
function decodeBase64Transaction(serializedTransaction) {
|
|
892
|
+
const bytes = decodeBase64(serializedTransaction);
|
|
893
|
+
try {
|
|
894
|
+
return VersionedTransaction.deserialize(bytes);
|
|
895
|
+
} catch {
|
|
896
|
+
return Transaction.from(bytes);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
function getSolanaProviders() {
|
|
900
|
+
if (typeof window === "undefined") return {};
|
|
901
|
+
const win = window;
|
|
902
|
+
const providers = {};
|
|
903
|
+
const phantom = win.phantom?.solana ?? (win.solana?.isPhantom ? win.solana : void 0);
|
|
904
|
+
const solflare = win.solflare ?? (win.solana?.isSolflare ? win.solana : void 0);
|
|
905
|
+
const backpack = win.backpack?.solana ?? (win.solana?.isBackpack ? win.solana : void 0);
|
|
906
|
+
if (phantom) providers["phantom-solana"] = phantom;
|
|
907
|
+
if (solflare) providers.solflare = solflare;
|
|
908
|
+
if (backpack) providers.backpack = backpack;
|
|
909
|
+
return providers;
|
|
910
|
+
}
|
|
911
|
+
function detectSolanaWallets(wallets) {
|
|
912
|
+
const providers = getSolanaProviders();
|
|
913
|
+
return SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
914
|
+
const provider = providers[walletId];
|
|
915
|
+
const meta = wallets.find((item) => item.id === walletId);
|
|
916
|
+
if (!provider || !meta) return [];
|
|
917
|
+
return [{ meta, provider, via: "solana-window" }];
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
function bindSolanaProviderEvents(provider, handlers) {
|
|
921
|
+
const onConnect = () => handlers.onConnect?.();
|
|
922
|
+
const onAccountChanged = () => handlers.onAccountChanged?.();
|
|
923
|
+
const onDisconnect = () => handlers.onDisconnect?.();
|
|
924
|
+
provider.on?.("connect", onConnect);
|
|
925
|
+
provider.on?.("accountChanged", onAccountChanged);
|
|
926
|
+
provider.on?.("disconnect", onDisconnect);
|
|
927
|
+
return () => {
|
|
928
|
+
provider.off?.("connect", onConnect);
|
|
929
|
+
provider.off?.("accountChanged", onAccountChanged);
|
|
930
|
+
provider.off?.("disconnect", onDisconnect);
|
|
931
|
+
provider.removeListener?.("connect", onConnect);
|
|
932
|
+
provider.removeListener?.("accountChanged", onAccountChanged);
|
|
933
|
+
provider.removeListener?.("disconnect", onDisconnect);
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function toSolanaWalletInterface(provider) {
|
|
937
|
+
return {
|
|
938
|
+
ecosystem: "solana",
|
|
939
|
+
type: "solana",
|
|
940
|
+
async getAddress() {
|
|
941
|
+
const current = getPublicKeyString(provider);
|
|
942
|
+
if (current) return current;
|
|
943
|
+
if (!provider.connect) {
|
|
944
|
+
throw new Error("Selected Solana wallet cannot connect");
|
|
945
|
+
}
|
|
946
|
+
await provider.connect();
|
|
947
|
+
const next = getPublicKeyString(provider);
|
|
948
|
+
if (!next) throw new Error("No connected Solana address");
|
|
949
|
+
return next;
|
|
950
|
+
},
|
|
951
|
+
async disconnect() {
|
|
952
|
+
await provider.disconnect?.();
|
|
953
|
+
},
|
|
954
|
+
async getChainKey() {
|
|
955
|
+
return "solana-mainnet-beta";
|
|
956
|
+
},
|
|
957
|
+
async sendSerializedTransaction(serializedTransactionBase64, rpcUrl) {
|
|
958
|
+
const transaction = decodeBase64Transaction(serializedTransactionBase64);
|
|
959
|
+
if (provider.signAndSendTransaction) {
|
|
960
|
+
const result = await provider.signAndSendTransaction(transaction, {
|
|
961
|
+
preflightCommitment: "confirmed"
|
|
962
|
+
});
|
|
963
|
+
if (typeof result === "string") return result;
|
|
964
|
+
if (result?.signature) return result.signature;
|
|
965
|
+
}
|
|
966
|
+
if (!provider.signTransaction) {
|
|
967
|
+
throw new Error("Connected Solana wallet cannot sign transactions");
|
|
968
|
+
}
|
|
969
|
+
const signed = await provider.signTransaction(transaction);
|
|
970
|
+
const connection = new Connection(
|
|
971
|
+
rpcUrl?.trim() || "https://api.mainnet-beta.solana.com",
|
|
972
|
+
"confirmed"
|
|
973
|
+
);
|
|
974
|
+
const signature = await connection.sendRawTransaction(signed.serialize());
|
|
975
|
+
await connection.confirmTransaction(signature, "confirmed");
|
|
976
|
+
return signature;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
|
|
758
981
|
// src/wallets/adapters.ts
|
|
759
982
|
function toWalletInterfaceFromDetected(dw) {
|
|
760
983
|
if (!dw?.provider) throw new Error("No provider on detected wallet");
|
|
984
|
+
if (dw.via === "solana-window" || dw.meta.ecosystem === "solana") {
|
|
985
|
+
return toSolanaWalletInterface(dw.provider);
|
|
986
|
+
}
|
|
761
987
|
const eth = dw.provider;
|
|
762
988
|
return useEIP1193(eth);
|
|
763
989
|
}
|
|
@@ -785,6 +1011,11 @@ async function connectDetectedWallet(dw, opts) {
|
|
|
785
1011
|
}
|
|
786
1012
|
throw new Error("WalletConnect connection failed. Please try again.");
|
|
787
1013
|
}
|
|
1014
|
+
if (dw.via === "solana-window" || dw.meta.ecosystem === "solana") {
|
|
1015
|
+
const api2 = toWalletInterfaceFromDetected(dw);
|
|
1016
|
+
if (touchAddress) await api2.getAddress();
|
|
1017
|
+
return { via: "eip1193", api: api2 };
|
|
1018
|
+
}
|
|
788
1019
|
if (wagmi) {
|
|
789
1020
|
const conn = pickWagmiConnector(
|
|
790
1021
|
wagmi,
|
|
@@ -827,6 +1058,7 @@ var WALLETS = [
|
|
|
827
1058
|
id: "metamask",
|
|
828
1059
|
name: "MetaMask",
|
|
829
1060
|
category: "injected",
|
|
1061
|
+
ecosystem: "evm",
|
|
830
1062
|
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
831
1063
|
emoji: "\u{1F98A}",
|
|
832
1064
|
homepage: "https://metamask.io/",
|
|
@@ -834,20 +1066,11 @@ var WALLETS = [
|
|
|
834
1066
|
detectFlags: ["isMetaMask"],
|
|
835
1067
|
deepLink: (url) => formatDeepLink("metamask", url) ?? ""
|
|
836
1068
|
},
|
|
837
|
-
{
|
|
838
|
-
id: "rabby",
|
|
839
|
-
name: "Rabby",
|
|
840
|
-
category: "injected",
|
|
841
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/rabby.svg`,
|
|
842
|
-
emoji: "\u{1F430}",
|
|
843
|
-
homepage: "https://rabby.io/",
|
|
844
|
-
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
845
|
-
detectFlags: ["isRabby"]
|
|
846
|
-
},
|
|
847
1069
|
{
|
|
848
1070
|
id: "coinbase",
|
|
849
1071
|
name: "Coinbase Wallet",
|
|
850
1072
|
category: "app",
|
|
1073
|
+
ecosystem: "evm",
|
|
851
1074
|
logo: `${ASSETS_BASE_URL}/assets/wallets/coinbase.svg`,
|
|
852
1075
|
emoji: "\u{1F7E6}",
|
|
853
1076
|
homepage: "https://www.coinbase.com/wallet",
|
|
@@ -858,6 +1081,7 @@ var WALLETS = [
|
|
|
858
1081
|
id: "walletconnect",
|
|
859
1082
|
name: "WalletConnect",
|
|
860
1083
|
category: "walletconnect",
|
|
1084
|
+
ecosystem: "multi",
|
|
861
1085
|
logo: `${ASSETS_BASE_URL}/assets/wallets/walletconnect.svg`,
|
|
862
1086
|
emoji: "\u{1FA9D}",
|
|
863
1087
|
homepage: "https://walletconnect.com/"
|
|
@@ -866,6 +1090,7 @@ var WALLETS = [
|
|
|
866
1090
|
id: "rainbow",
|
|
867
1091
|
name: "Rainbow",
|
|
868
1092
|
category: "app",
|
|
1093
|
+
ecosystem: "evm",
|
|
869
1094
|
logo: `${ASSETS_BASE_URL}/assets/wallets/rainbow.svg`,
|
|
870
1095
|
emoji: "\u{1F308}",
|
|
871
1096
|
homepage: "https://rainbow.me/",
|
|
@@ -873,27 +1098,82 @@ var WALLETS = [
|
|
|
873
1098
|
detectFlags: ["isRainbow"]
|
|
874
1099
|
},
|
|
875
1100
|
{
|
|
876
|
-
id: "
|
|
877
|
-
name: "
|
|
1101
|
+
id: "phantom-evm",
|
|
1102
|
+
name: "Phantom (EVM)",
|
|
878
1103
|
category: "injected",
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1104
|
+
ecosystem: "evm",
|
|
1105
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1106
|
+
emoji: "\u{1F47B}",
|
|
1107
|
+
homepage: "https://phantom.app/",
|
|
1108
|
+
detectFlags: ["isPhantom"]
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
id: "phantom-solana",
|
|
1112
|
+
name: "Phantom (Solana)",
|
|
1113
|
+
category: "injected",
|
|
1114
|
+
ecosystem: "solana",
|
|
1115
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
1116
|
+
emoji: "\u{1F47B}",
|
|
1117
|
+
homepage: "https://phantom.app/",
|
|
1118
|
+
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1119
|
+
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1120
|
+
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
id: "solflare",
|
|
1124
|
+
name: "Solflare",
|
|
1125
|
+
category: "injected",
|
|
1126
|
+
ecosystem: "solana",
|
|
1127
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/solflare-logo.svg`,
|
|
1128
|
+
emoji: "\u2600\uFE0F",
|
|
1129
|
+
homepage: "https://solflare.com/",
|
|
1130
|
+
deepLink: (url) => `solflare://ul/v1/browse/${encodeURIComponent(url)}`
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
id: "backpack",
|
|
1134
|
+
name: "Backpack",
|
|
1135
|
+
category: "injected",
|
|
1136
|
+
ecosystem: "solana",
|
|
1137
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/backpack-logo.svg`,
|
|
1138
|
+
emoji: "\u{1F392}",
|
|
1139
|
+
homepage: "https://backpack.app/"
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
id: "rabby",
|
|
1143
|
+
name: "Rabby",
|
|
1144
|
+
category: "injected",
|
|
1145
|
+
ecosystem: "evm",
|
|
1146
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/rabby.svg`,
|
|
1147
|
+
emoji: "\u{1F430}",
|
|
1148
|
+
homepage: "https://rabby.io/",
|
|
1149
|
+
chromeWebStore: "https://chromewebstore.google.com/detail/rabby/acmacodkjbdgmoleebolmdjonilkdbch",
|
|
1150
|
+
detectFlags: ["isRabby"]
|
|
883
1151
|
},
|
|
884
1152
|
{
|
|
885
1153
|
id: "brave",
|
|
886
1154
|
name: "Brave Wallet",
|
|
887
1155
|
category: "injected",
|
|
1156
|
+
ecosystem: "evm",
|
|
888
1157
|
logo: `${ASSETS_BASE_URL}/assets/wallets/brave.svg`,
|
|
889
1158
|
emoji: "\u{1F981}",
|
|
890
1159
|
homepage: "https://brave.com/wallet/",
|
|
891
1160
|
detectFlags: ["isBraveWallet"]
|
|
892
1161
|
},
|
|
1162
|
+
{
|
|
1163
|
+
id: "okx",
|
|
1164
|
+
name: "OKX",
|
|
1165
|
+
category: "injected",
|
|
1166
|
+
ecosystem: "evm",
|
|
1167
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/okx.svg`,
|
|
1168
|
+
emoji: "\u2B1B",
|
|
1169
|
+
homepage: "https://www.okx.com/web3",
|
|
1170
|
+
detectFlags: ["isOkxWallet"]
|
|
1171
|
+
},
|
|
893
1172
|
{
|
|
894
1173
|
id: "zerion",
|
|
895
1174
|
name: "Zerion",
|
|
896
1175
|
category: "app",
|
|
1176
|
+
ecosystem: "evm",
|
|
897
1177
|
logo: `${ASSETS_BASE_URL}/assets/wallets/zerion.png`,
|
|
898
1178
|
emoji: "\u{1F9FF}",
|
|
899
1179
|
homepage: "https://zerion.io/wallet/"
|
|
@@ -902,6 +1182,7 @@ var WALLETS = [
|
|
|
902
1182
|
id: "taho",
|
|
903
1183
|
name: "Taho",
|
|
904
1184
|
category: "injected",
|
|
1185
|
+
ecosystem: "evm",
|
|
905
1186
|
logo: `${ASSETS_BASE_URL}/assets/wallets/taho.png`,
|
|
906
1187
|
emoji: "\u{1F7EA}",
|
|
907
1188
|
homepage: "https://taho.xyz/",
|
|
@@ -911,6 +1192,7 @@ var WALLETS = [
|
|
|
911
1192
|
id: "trust",
|
|
912
1193
|
name: "Trust Wallet",
|
|
913
1194
|
category: "app",
|
|
1195
|
+
ecosystem: "multi",
|
|
914
1196
|
logo: `${ASSETS_BASE_URL}/assets/wallets/trust.svg`,
|
|
915
1197
|
emoji: "\u{1F6E1}\uFE0F",
|
|
916
1198
|
homepage: "https://trustwallet.com/",
|
|
@@ -920,24 +1202,17 @@ var WALLETS = [
|
|
|
920
1202
|
id: "bitget",
|
|
921
1203
|
name: "Bitget Wallet",
|
|
922
1204
|
category: "injected",
|
|
1205
|
+
ecosystem: "evm",
|
|
923
1206
|
logo: `${ASSETS_BASE_URL}/assets/wallets/bitget.svg`,
|
|
924
1207
|
emoji: "\u{1F7E9}",
|
|
925
1208
|
homepage: "https://web3.bitget.com/",
|
|
926
1209
|
detectFlags: ["isBitGetWallet"]
|
|
927
1210
|
},
|
|
928
|
-
{
|
|
929
|
-
id: "phantom-evm",
|
|
930
|
-
name: "Phantom (EVM)",
|
|
931
|
-
category: "injected",
|
|
932
|
-
logo: `${ASSETS_BASE_URL}/assets/wallets/phantom.svg`,
|
|
933
|
-
emoji: "\u{1F47B}",
|
|
934
|
-
homepage: "https://phantom.app/",
|
|
935
|
-
detectFlags: ["isPhantom"]
|
|
936
|
-
},
|
|
937
1211
|
{
|
|
938
1212
|
id: "safe",
|
|
939
1213
|
name: "Safe",
|
|
940
1214
|
category: "app",
|
|
1215
|
+
ecosystem: "evm",
|
|
941
1216
|
logo: `${ASSETS_BASE_URL}/assets/wallets/safe.svg`,
|
|
942
1217
|
emoji: "\u{1F7E9}",
|
|
943
1218
|
homepage: "https://safe.global/"
|
|
@@ -946,6 +1221,7 @@ var WALLETS = [
|
|
|
946
1221
|
id: "kucoin",
|
|
947
1222
|
name: "KuCoin Wallet",
|
|
948
1223
|
category: "app",
|
|
1224
|
+
ecosystem: "evm",
|
|
949
1225
|
logo: `${ASSETS_BASE_URL}/assets/wallets/kucoin.svg`,
|
|
950
1226
|
emoji: "\u{1F7E6}",
|
|
951
1227
|
homepage: "https://www.kucoin.com/"
|
|
@@ -1026,6 +1302,7 @@ function createGenericWalletMeta(name) {
|
|
|
1026
1302
|
id: rawId,
|
|
1027
1303
|
name,
|
|
1028
1304
|
category: "injected",
|
|
1305
|
+
ecosystem: "evm",
|
|
1029
1306
|
logo: "",
|
|
1030
1307
|
emoji: "\u{1F45B}"
|
|
1031
1308
|
};
|
|
@@ -1096,8 +1373,8 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1096
1373
|
const w = window;
|
|
1097
1374
|
const announced = [];
|
|
1098
1375
|
const providerDetailMap = /* @__PURE__ */ new Map();
|
|
1099
|
-
const onAnnounce = (
|
|
1100
|
-
const ce =
|
|
1376
|
+
const onAnnounce = (e2) => {
|
|
1377
|
+
const ce = e2;
|
|
1101
1378
|
if (ce?.detail?.provider?.request) {
|
|
1102
1379
|
const detail = {
|
|
1103
1380
|
info: ce.detail.info,
|
|
@@ -1139,6 +1416,11 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1139
1416
|
out.push(wallet);
|
|
1140
1417
|
}
|
|
1141
1418
|
}
|
|
1419
|
+
for (const wallet of detectSolanaWallets(WALLETS)) {
|
|
1420
|
+
if (seenIds.has(wallet.meta.id)) continue;
|
|
1421
|
+
seenIds.add(wallet.meta.id);
|
|
1422
|
+
out.push(wallet);
|
|
1423
|
+
}
|
|
1142
1424
|
setDetected(rankDetected(out));
|
|
1143
1425
|
w.removeEventListener?.("eip6963:announceProvider", onAnnounce);
|
|
1144
1426
|
done = true;
|
|
@@ -1155,6 +1437,1114 @@ function useWalletDetection(timeoutMs = 400) {
|
|
|
1155
1437
|
return { detected, detectedIds };
|
|
1156
1438
|
}
|
|
1157
1439
|
|
|
1440
|
+
// src/validation/address.ts
|
|
1441
|
+
import { isAddress as isEvmAddress } from "viem";
|
|
1442
|
+
|
|
1443
|
+
// node_modules/@solana/errors/dist/index.node.mjs
|
|
1444
|
+
var SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED = 1;
|
|
1445
|
+
var SOLANA_ERROR__INVALID_NONCE = 2;
|
|
1446
|
+
var SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = 3;
|
|
1447
|
+
var SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE = 4;
|
|
1448
|
+
var SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = 5;
|
|
1449
|
+
var SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE = 6;
|
|
1450
|
+
var SOLANA_ERROR__MALFORMED_BIGINT_STRING = 7;
|
|
1451
|
+
var SOLANA_ERROR__MALFORMED_NUMBER_STRING = 8;
|
|
1452
|
+
var SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE = 9;
|
|
1453
|
+
var SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR = 10;
|
|
1454
|
+
var SOLANA_ERROR__JSON_RPC__PARSE_ERROR = -32700;
|
|
1455
|
+
var SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = -32603;
|
|
1456
|
+
var SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = -32602;
|
|
1457
|
+
var SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND = -32601;
|
|
1458
|
+
var SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = -32600;
|
|
1459
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE = -32019;
|
|
1460
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_NOT_EPOCH_BOUNDARY = -32018;
|
|
1461
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_EPOCH_REWARDS_PERIOD_ACTIVE = -32017;
|
|
1462
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED = -32016;
|
|
1463
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION = -32015;
|
|
1464
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET = -32014;
|
|
1465
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH = -32013;
|
|
1466
|
+
var SOLANA_ERROR__JSON_RPC__SCAN_ERROR = -32012;
|
|
1467
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE = -32011;
|
|
1468
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX = -32010;
|
|
1469
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED = -32009;
|
|
1470
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT = -32008;
|
|
1471
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED = -32007;
|
|
1472
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE = -32006;
|
|
1473
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY = -32005;
|
|
1474
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE = -32004;
|
|
1475
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE = -32003;
|
|
1476
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE = -32002;
|
|
1477
|
+
var SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP = -32001;
|
|
1478
|
+
var SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH = 28e5;
|
|
1479
|
+
var SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE = 2800001;
|
|
1480
|
+
var SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS = 2800002;
|
|
1481
|
+
var SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY = 2800003;
|
|
1482
|
+
var SOLANA_ERROR__ADDRESSES__MALFORMED_PDA = 2800004;
|
|
1483
|
+
var SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE = 2800005;
|
|
1484
|
+
var SOLANA_ERROR__ADDRESSES__MAX_NUMBER_OF_PDA_SEEDS_EXCEEDED = 2800006;
|
|
1485
|
+
var SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED = 2800007;
|
|
1486
|
+
var SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE = 2800008;
|
|
1487
|
+
var SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED = 2800009;
|
|
1488
|
+
var SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER = 2800010;
|
|
1489
|
+
var SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS = 2800011;
|
|
1490
|
+
var SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND = 323e4;
|
|
1491
|
+
var SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND = 32300001;
|
|
1492
|
+
var SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT = 3230002;
|
|
1493
|
+
var SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT = 3230003;
|
|
1494
|
+
var SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED = 3230004;
|
|
1495
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = 361e4;
|
|
1496
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = 3610001;
|
|
1497
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = 3610002;
|
|
1498
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED = 3610003;
|
|
1499
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
|
|
1500
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
|
|
1501
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
|
|
1502
|
+
var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
|
|
1503
|
+
var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
|
|
1504
|
+
var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
|
|
1505
|
+
var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
|
|
1506
|
+
var SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH = 3704002;
|
|
1507
|
+
var SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE = 3704003;
|
|
1508
|
+
var SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY = 3704004;
|
|
1509
|
+
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS = 4128e3;
|
|
1510
|
+
var SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA = 4128001;
|
|
1511
|
+
var SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH = 4128002;
|
|
1512
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN = 4615e3;
|
|
1513
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR = 4615001;
|
|
1514
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT = 4615002;
|
|
1515
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA = 4615003;
|
|
1516
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA = 4615004;
|
|
1517
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL = 4615005;
|
|
1518
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS = 4615006;
|
|
1519
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID = 4615007;
|
|
1520
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE = 4615008;
|
|
1521
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED = 4615009;
|
|
1522
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT = 4615010;
|
|
1523
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION = 4615011;
|
|
1524
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID = 4615012;
|
|
1525
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND = 4615013;
|
|
1526
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED = 4615014;
|
|
1527
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE = 4615015;
|
|
1528
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED = 4615016;
|
|
1529
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX = 4615017;
|
|
1530
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED = 4615018;
|
|
1531
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED = 4615019;
|
|
1532
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 4615020;
|
|
1533
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED = 4615021;
|
|
1534
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE = 4615022;
|
|
1535
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED = 4615023;
|
|
1536
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 4615024;
|
|
1537
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC = 4615025;
|
|
1538
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM = 4615026;
|
|
1539
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR = 4615027;
|
|
1540
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED = 4615028;
|
|
1541
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE = 4615029;
|
|
1542
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT = 4615030;
|
|
1543
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID = 4615031;
|
|
1544
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH = 4615032;
|
|
1545
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT = 4615033;
|
|
1546
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED = 4615034;
|
|
1547
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED = 4615035;
|
|
1548
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS = 4615036;
|
|
1549
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC = 4615037;
|
|
1550
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED = 4615038;
|
|
1551
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION = 4615039;
|
|
1552
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE = 4615040;
|
|
1553
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE = 4615041;
|
|
1554
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE = 4615042;
|
|
1555
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE = 4615043;
|
|
1556
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY = 4615044;
|
|
1557
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR = 4615045;
|
|
1558
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT = 4615046;
|
|
1559
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER = 4615047;
|
|
1560
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW = 4615048;
|
|
1561
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR = 4615049;
|
|
1562
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER = 4615050;
|
|
1563
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 4615051;
|
|
1564
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED = 4615052;
|
|
1565
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 4615053;
|
|
1566
|
+
var SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 4615054;
|
|
1567
|
+
var SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS = 5508e3;
|
|
1568
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER = 5508001;
|
|
1569
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER = 5508002;
|
|
1570
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER = 5508003;
|
|
1571
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER = 5508004;
|
|
1572
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER = 5508005;
|
|
1573
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER = 5508006;
|
|
1574
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER = 5508007;
|
|
1575
|
+
var SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER = 5508008;
|
|
1576
|
+
var SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = 5508009;
|
|
1577
|
+
var SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = 5508010;
|
|
1578
|
+
var SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = 5508011;
|
|
1579
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED = 5607e3;
|
|
1580
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__RESTRICTED_ASCII_BODY_CHARACTER_OUT_OF_RANGE = 5607001;
|
|
1581
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__APPLICATION_DOMAIN_STRING_LENGTH_OUT_OF_RANGE = 5607002;
|
|
1582
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__INVALID_APPLICATION_DOMAIN_BYTE_LENGTH = 5607003;
|
|
1583
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH = 5607004;
|
|
1584
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO = 5607005;
|
|
1585
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__VERSION_NUMBER_NOT_SUPPORTED = 5607006;
|
|
1586
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH = 5607007;
|
|
1587
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_LENGTH_MISMATCH = 5607008;
|
|
1588
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY = 5607009;
|
|
1589
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO = 5607010;
|
|
1590
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING = 5607011;
|
|
1591
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__ENVELOPE_SIGNERS_MISMATCH = 5607012;
|
|
1592
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__ADDRESSES_CANNOT_SIGN_OFFCHAIN_MESSAGE = 5607013;
|
|
1593
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION = 5607014;
|
|
1594
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED = 5607015;
|
|
1595
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE = 5607016;
|
|
1596
|
+
var SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE = 5607017;
|
|
1597
|
+
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = 5663e3;
|
|
1598
|
+
var SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE = 5663001;
|
|
1599
|
+
var SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = 5663002;
|
|
1600
|
+
var SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = 5663003;
|
|
1601
|
+
var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = 5663004;
|
|
1602
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = 5663005;
|
|
1603
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_INDEX_OUT_OF_RANGE = 5663006;
|
|
1604
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = 5663007;
|
|
1605
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = 5663008;
|
|
1606
|
+
var SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = 5663009;
|
|
1607
|
+
var SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = 5663010;
|
|
1608
|
+
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = 5663011;
|
|
1609
|
+
var SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = 5663012;
|
|
1610
|
+
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = 5663013;
|
|
1611
|
+
var SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = 5663014;
|
|
1612
|
+
var SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = 5663015;
|
|
1613
|
+
var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
|
|
1614
|
+
var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
|
|
1615
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
|
|
1616
|
+
var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
|
|
1617
|
+
var SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = 5663020;
|
|
1618
|
+
var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED = 5663021;
|
|
1619
|
+
var SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE = 5663022;
|
|
1620
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
|
|
1621
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
|
|
1622
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
|
|
1623
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND = 7050003;
|
|
1624
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND = 7050004;
|
|
1625
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE = 7050005;
|
|
1626
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE = 7050006;
|
|
1627
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED = 7050007;
|
|
1628
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND = 7050008;
|
|
1629
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP = 7050009;
|
|
1630
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE = 7050010;
|
|
1631
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX = 7050011;
|
|
1632
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE = 7050012;
|
|
1633
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION = 7050013;
|
|
1634
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE = 7050014;
|
|
1635
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE = 7050015;
|
|
1636
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING = 7050016;
|
|
1637
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 7050017;
|
|
1638
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION = 7050018;
|
|
1639
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT = 7050019;
|
|
1640
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 7050020;
|
|
1641
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT = 7050021;
|
|
1642
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS = 7050022;
|
|
1643
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND = 7050023;
|
|
1644
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER = 7050024;
|
|
1645
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA = 7050025;
|
|
1646
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 7050026;
|
|
1647
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT = 7050027;
|
|
1648
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 7050028;
|
|
1649
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT = 7050029;
|
|
1650
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION = 7050030;
|
|
1651
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT = 7050031;
|
|
1652
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED = 7050032;
|
|
1653
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT = 7050033;
|
|
1654
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED = 7050034;
|
|
1655
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED = 7050035;
|
|
1656
|
+
var SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION = 7050036;
|
|
1657
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN = 7618e3;
|
|
1658
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE = 7618001;
|
|
1659
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__EMPTY_INSTRUCTION_PLAN = 7618002;
|
|
1660
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN = 7618003;
|
|
1661
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__NON_DIVISIBLE_TRANSACTION_PLANS_NOT_SUPPORTED = 7618004;
|
|
1662
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_SINGLE_TRANSACTION_PLAN_RESULT_NOT_FOUND = 7618005;
|
|
1663
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_INSTRUCTION_PLAN = 7618006;
|
|
1664
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN = 7618007;
|
|
1665
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN_RESULT = 7618008;
|
|
1666
|
+
var SOLANA_ERROR__INSTRUCTION_PLANS__EXPECTED_SUCCESSFUL_TRANSACTION_PLAN_RESULT = 7618009;
|
|
1667
|
+
var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
|
|
1668
|
+
var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
|
|
1669
|
+
var SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH = 8078002;
|
|
1670
|
+
var SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH = 8078003;
|
|
1671
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
|
|
1672
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
|
|
1673
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
|
|
1674
|
+
var SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = 8078007;
|
|
1675
|
+
var SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE = 8078008;
|
|
1676
|
+
var SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT = 8078009;
|
|
1677
|
+
var SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT = 8078010;
|
|
1678
|
+
var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
|
|
1679
|
+
var SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = 8078012;
|
|
1680
|
+
var SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH = 8078013;
|
|
1681
|
+
var SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE = 8078014;
|
|
1682
|
+
var SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT = 8078015;
|
|
1683
|
+
var SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = 8078016;
|
|
1684
|
+
var SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE = 8078017;
|
|
1685
|
+
var SOLANA_ERROR__CODECS__INVALID_CONSTANT = 8078018;
|
|
1686
|
+
var SOLANA_ERROR__CODECS__EXPECTED_ZERO_VALUE_TO_MATCH_ITEM_FIXED_SIZE = 8078019;
|
|
1687
|
+
var SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL = 8078020;
|
|
1688
|
+
var SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = 8078021;
|
|
1689
|
+
var SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS = 8078022;
|
|
1690
|
+
var SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY = 8078023;
|
|
1691
|
+
var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
|
|
1692
|
+
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
|
|
1693
|
+
var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
|
|
1694
|
+
var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
|
|
1695
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
|
|
1696
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
|
|
1697
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
|
|
1698
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
|
|
1699
|
+
var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
|
|
1700
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
|
|
1701
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
|
|
1702
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
|
|
1703
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
|
|
1704
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
|
|
1705
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_INSTRUCTION_PLAN_KIND = 9900005;
|
|
1706
|
+
var SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_TRANSACTION_PLAN_KIND = 9900006;
|
|
1707
|
+
function encodeValue(value) {
|
|
1708
|
+
if (Array.isArray(value)) {
|
|
1709
|
+
const commaSeparatedValues = value.map(encodeValue).join(
|
|
1710
|
+
"%2C%20"
|
|
1711
|
+
/* ", " */
|
|
1712
|
+
);
|
|
1713
|
+
return "%5B" + commaSeparatedValues + /* "]" */
|
|
1714
|
+
"%5D";
|
|
1715
|
+
} else if (typeof value === "bigint") {
|
|
1716
|
+
return `${value}n`;
|
|
1717
|
+
} else {
|
|
1718
|
+
return encodeURIComponent(
|
|
1719
|
+
String(
|
|
1720
|
+
value != null && Object.getPrototypeOf(value) === null ? (
|
|
1721
|
+
// Plain objects with no prototype don't have a `toString` method.
|
|
1722
|
+
// Convert them before stringifying them.
|
|
1723
|
+
{ ...value }
|
|
1724
|
+
) : value
|
|
1725
|
+
)
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
function encodeObjectContextEntry([key, value]) {
|
|
1730
|
+
return `${key}=${encodeValue(value)}`;
|
|
1731
|
+
}
|
|
1732
|
+
function encodeContextObject(context) {
|
|
1733
|
+
const searchParamsString = Object.entries(context).map(encodeObjectContextEntry).join("&");
|
|
1734
|
+
return Buffer.from(searchParamsString, "utf8").toString("base64");
|
|
1735
|
+
}
|
|
1736
|
+
var SolanaErrorMessages = {
|
|
1737
|
+
[SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
|
|
1738
|
+
[SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
|
|
1739
|
+
[SOLANA_ERROR__ACCOUNTS__EXPECTED_DECODED_ACCOUNT]: "Expected decoded account at address: $address",
|
|
1740
|
+
[SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT]: "Failed to decode account data at address: $address",
|
|
1741
|
+
[SOLANA_ERROR__ACCOUNTS__ONE_OR_MORE_ACCOUNTS_NOT_FOUND]: "Accounts not found at addresses: $addresses",
|
|
1742
|
+
[SOLANA_ERROR__ADDRESSES__FAILED_TO_FIND_VIABLE_PDA_BUMP_SEED]: "Unable to find a viable program address bump seed.",
|
|
1743
|
+
[SOLANA_ERROR__ADDRESSES__INVALID_BASE58_ENCODED_ADDRESS]: "$putativeAddress is not a base58-encoded address.",
|
|
1744
|
+
[SOLANA_ERROR__ADDRESSES__INVALID_BYTE_LENGTH]: "Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",
|
|
1745
|
+
[SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY]: "The `CryptoKey` must be an `Ed25519` public key.",
|
|
1746
|
+
[SOLANA_ERROR__ADDRESSES__INVALID_OFF_CURVE_ADDRESS]: "$putativeOffCurveAddress is not a base58-encoded off-curve address.",
|
|
1747
|
+
[SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE]: "Invalid seeds; point must fall off the Ed25519 curve.",
|
|
1748
|
+
[SOLANA_ERROR__ADDRESSES__MALFORMED_PDA]: "Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",
|
|
1749
|
+
[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.",
|
|
1750
|
+
[SOLANA_ERROR__ADDRESSES__MAX_PDA_SEED_LENGTH_EXCEEDED]: "The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",
|
|
1751
|
+
[SOLANA_ERROR__ADDRESSES__PDA_BUMP_SEED_OUT_OF_RANGE]: "Expected program derived address bump to be in the range [0, 255], got: $bump.",
|
|
1752
|
+
[SOLANA_ERROR__ADDRESSES__PDA_ENDS_WITH_PDA_MARKER]: "Program address cannot end with PDA marker.",
|
|
1753
|
+
[SOLANA_ERROR__ADDRESSES__STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",
|
|
1754
|
+
[SOLANA_ERROR__BLOCKHASH_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",
|
|
1755
|
+
[SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED]: "The network has progressed past the last block for which this transaction could have been committed.",
|
|
1756
|
+
[SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY]: "Codec [$codecDescription] cannot decode empty byte arrays.",
|
|
1757
|
+
[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`.",
|
|
1758
|
+
[SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL]: "Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",
|
|
1759
|
+
[SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH]: "Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",
|
|
1760
|
+
[SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH]: "Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",
|
|
1761
|
+
[SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH]: "Encoder and decoder must either both be fixed-size or variable-size.",
|
|
1762
|
+
[SOLANA_ERROR__CODECS__ENUM_DISCRIMINATOR_OUT_OF_RANGE]: "Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",
|
|
1763
|
+
[SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH]: "Expected a fixed-size codec, got a variable-size one.",
|
|
1764
|
+
[SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH]: "Codec [$codecDescription] expected a positive byte length, got $bytesLength.",
|
|
1765
|
+
[SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH]: "Expected a variable-size codec, got a fixed-size one.",
|
|
1766
|
+
[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].",
|
|
1767
|
+
[SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH]: "Codec [$codecDescription] expected $expected bytes, got $bytesLength.",
|
|
1768
|
+
[SOLANA_ERROR__CODECS__INVALID_CONSTANT]: "Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",
|
|
1769
|
+
[SOLANA_ERROR__CODECS__INVALID_DISCRIMINATED_UNION_VARIANT]: "Invalid discriminated union variant. Expected one of [$variants], got $value.",
|
|
1770
|
+
[SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT]: "Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",
|
|
1771
|
+
[SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT]: "Invalid literal union variant. Expected one of [$variants], got $value.",
|
|
1772
|
+
[SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS]: "Expected [$codecDescription] to have $expected items, got $actual.",
|
|
1773
|
+
[SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE]: "Invalid value $value for base $base with alphabet $alphabet.",
|
|
1774
|
+
[SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE]: "Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
|
|
1775
|
+
[SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
|
|
1776
|
+
[SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE]: "Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",
|
|
1777
|
+
[SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
|
|
1778
|
+
[SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
|
|
1779
|
+
[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?",
|
|
1780
|
+
[SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED]: "No random values implementation could be found.",
|
|
1781
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
|
|
1782
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
|
|
1783
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "instruction left account with an outstanding borrowed reference",
|
|
1784
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_SIZE_CHANGED]: "program other than the account's owner changed the size of the account data",
|
|
1785
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_DATA_TOO_SMALL]: "account data too small for instruction",
|
|
1786
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_EXECUTABLE]: "instruction expected an executable account",
|
|
1787
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_NOT_RENT_EXEMPT]: "An account does not have enough lamports to be rent-exempt",
|
|
1788
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ARITHMETIC_OVERFLOW]: "Program arithmetic overflowed",
|
|
1789
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR]: "Failed to serialize or deserialize account data: $encodedData",
|
|
1790
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS]: "Builtin programs must consume compute units",
|
|
1791
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__CALL_DEPTH]: "Cross-program invocation call depth too deep",
|
|
1792
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__COMPUTATIONAL_BUDGET_EXCEEDED]: "Computational budget exceeded",
|
|
1793
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM]: "custom program error: #$code",
|
|
1794
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_INDEX]: "instruction contains duplicate accounts",
|
|
1795
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__DUPLICATE_ACCOUNT_OUT_OF_SYNC]: "instruction modifications of multiply-passed account differ",
|
|
1796
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT]: "executable accounts must be rent exempt",
|
|
1797
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_DATA_MODIFIED]: "instruction changed executable accounts data",
|
|
1798
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_LAMPORT_CHANGE]: "instruction changed the balance of an executable account",
|
|
1799
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXECUTABLE_MODIFIED]: "instruction changed executable bit of an account",
|
|
1800
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_DATA_MODIFIED]: "instruction modified data of an account it does not own",
|
|
1801
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__EXTERNAL_ACCOUNT_LAMPORT_SPEND]: "instruction spent from the balance of an account it does not own",
|
|
1802
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__GENERIC_ERROR]: "generic instruction error",
|
|
1803
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__ILLEGAL_OWNER]: "Provided owner is not allowed",
|
|
1804
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__IMMUTABLE]: "Account is immutable",
|
|
1805
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_AUTHORITY]: "Incorrect authority provided",
|
|
1806
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INCORRECT_PROGRAM_ID]: "incorrect program id for instruction",
|
|
1807
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS]: "insufficient funds for instruction",
|
|
1808
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_DATA]: "invalid account data for instruction",
|
|
1809
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ACCOUNT_OWNER]: "Invalid account owner",
|
|
1810
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ARGUMENT]: "invalid program argument",
|
|
1811
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_ERROR]: "program returned invalid error code",
|
|
1812
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_INSTRUCTION_DATA]: "invalid instruction data",
|
|
1813
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_REALLOC]: "Failed to reallocate account data",
|
|
1814
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__INVALID_SEEDS]: "Provided seeds do not result in a valid address",
|
|
1815
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED]: "Accounts data allocations exceeded the maximum allowed per transaction",
|
|
1816
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_ACCOUNTS_EXCEEDED]: "Max accounts exceeded",
|
|
1817
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED]: "Max instruction trace length exceeded",
|
|
1818
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MAX_SEED_LENGTH_EXCEEDED]: "Length of the seed is too long for address generation",
|
|
1819
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_ACCOUNT]: "An account required by the instruction is missing",
|
|
1820
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MISSING_REQUIRED_SIGNATURE]: "missing required signature for instruction",
|
|
1821
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__MODIFIED_PROGRAM_ID]: "instruction illegally modified the program id of an account",
|
|
1822
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: "insufficient account keys for instruction",
|
|
1823
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__PRIVILEGE_ESCALATION]: "Cross-program invocation with unauthorized signer or writable account",
|
|
1824
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_ENVIRONMENT_SETUP_FAILURE]: "Failed to create program execution environment",
|
|
1825
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPILE]: "Program failed to compile",
|
|
1826
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__PROGRAM_FAILED_TO_COMPLETE]: "Program failed to complete",
|
|
1827
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_DATA_MODIFIED]: "instruction modified data of a read-only account",
|
|
1828
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__READONLY_LAMPORT_CHANGE]: "instruction changed the balance of a read-only account",
|
|
1829
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__REENTRANCY_NOT_ALLOWED]: "Cross-program invocation reentrancy not allowed for this instruction",
|
|
1830
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__RENT_EPOCH_MODIFIED]: "instruction modified rent epoch of an account",
|
|
1831
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__UNBALANCED_INSTRUCTION]: "sum of account balances before and after instruction do not match",
|
|
1832
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__UNINITIALIZED_ACCOUNT]: "instruction requires an initialized account",
|
|
1833
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN]: "",
|
|
1834
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_PROGRAM_ID]: "Unsupported program id",
|
|
1835
|
+
[SOLANA_ERROR__INSTRUCTION_ERROR__UNSUPPORTED_SYSVAR]: "Unsupported sysvar",
|
|
1836
|
+
[SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_INSTRUCTION_PLAN_KIND]: "Invalid instruction plan kind: $kind.",
|
|
1837
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__EMPTY_INSTRUCTION_PLAN]: "The provided instruction plan is empty.",
|
|
1838
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_SINGLE_TRANSACTION_PLAN_RESULT_NOT_FOUND]: "No failed transaction plan result was found in the provided transaction plan result.",
|
|
1839
|
+
[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.",
|
|
1840
|
+
[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.",
|
|
1841
|
+
[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).",
|
|
1842
|
+
[SOLANA_ERROR__INVARIANT_VIOLATION__INVALID_TRANSACTION_PLAN_KIND]: "Invalid transaction plan kind: $kind.",
|
|
1843
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE]: "No more instructions to pack; the message packer has completed the instruction plan.",
|
|
1844
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_INSTRUCTION_PLAN]: "Unexpected instruction plan. Expected $expectedKind plan, got $actualKind plan.",
|
|
1845
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN]: "Unexpected transaction plan. Expected $expectedKind plan, got $actualKind plan.",
|
|
1846
|
+
[SOLANA_ERROR__INSTRUCTION_PLANS__UNEXPECTED_TRANSACTION_PLAN_RESULT]: "Unexpected transaction plan result. Expected $expectedKind plan, got $actualKind plan.",
|
|
1847
|
+
[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.",
|
|
1848
|
+
[SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS]: "The instruction does not have any accounts.",
|
|
1849
|
+
[SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA]: "The instruction does not have any data.",
|
|
1850
|
+
[SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH]: "Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",
|
|
1851
|
+
[SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
|
|
1852
|
+
[SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
|
|
1853
|
+
[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",
|
|
1854
|
+
[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.",
|
|
1855
|
+
[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",
|
|
1856
|
+
[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",
|
|
1857
|
+
[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",
|
|
1858
|
+
[SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
|
|
1859
|
+
[SOLANA_ERROR__JSON_RPC__INVALID_PARAMS]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
|
|
1860
|
+
[SOLANA_ERROR__JSON_RPC__INVALID_REQUEST]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
|
|
1861
|
+
[SOLANA_ERROR__JSON_RPC__METHOD_NOT_FOUND]: "JSON-RPC error: The method does not exist / is not available ($__serverMessage)",
|
|
1862
|
+
[SOLANA_ERROR__JSON_RPC__PARSE_ERROR]: "JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",
|
|
1863
|
+
[SOLANA_ERROR__JSON_RPC__SCAN_ERROR]: "$__serverMessage",
|
|
1864
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP]: "$__serverMessage",
|
|
1865
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE]: "$__serverMessage",
|
|
1866
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET]: "$__serverMessage",
|
|
1867
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_EPOCH_REWARDS_PERIOD_ACTIVE]: "Epoch rewards period still active at slot $slot",
|
|
1868
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX]: "$__serverMessage",
|
|
1869
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED]: "$__serverMessage",
|
|
1870
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE]: "Failed to query long-term storage; please try again",
|
|
1871
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED]: "Minimum context slot has not been reached",
|
|
1872
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY]: "Node is unhealthy; behind by $numSlotsBehind slots",
|
|
1873
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NO_SNAPSHOT]: "No snapshot",
|
|
1874
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE]: "Transaction simulation failed",
|
|
1875
|
+
[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",
|
|
1876
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED]: "$__serverMessage",
|
|
1877
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE]: "Transaction history is not available from this node",
|
|
1878
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE]: "$__serverMessage",
|
|
1879
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH]: "Transaction signature length mismatch",
|
|
1880
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE]: "Transaction signature verification failure",
|
|
1881
|
+
[SOLANA_ERROR__JSON_RPC__SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION]: "$__serverMessage",
|
|
1882
|
+
[SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH]: "Key pair bytes must be of length 64, got $byteLength.",
|
|
1883
|
+
[SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH]: "Expected private key bytes with length 32. Actual length: $actualLength.",
|
|
1884
|
+
[SOLANA_ERROR__KEYS__INVALID_SIGNATURE_BYTE_LENGTH]: "Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",
|
|
1885
|
+
[SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY]: "The provided private key does not match the provided public key.",
|
|
1886
|
+
[SOLANA_ERROR__KEYS__SIGNATURE_STRING_LENGTH_OUT_OF_RANGE]: "Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",
|
|
1887
|
+
[SOLANA_ERROR__LAMPORTS_OUT_OF_RANGE]: "Lamports value must be in the range [0, 2e64-1]",
|
|
1888
|
+
[SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
|
|
1889
|
+
[SOLANA_ERROR__MALFORMED_JSON_RPC_ERROR]: "$message",
|
|
1890
|
+
[SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
|
|
1891
|
+
[SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
|
|
1892
|
+
[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.",
|
|
1893
|
+
[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",
|
|
1894
|
+
[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.",
|
|
1895
|
+
[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]`.",
|
|
1896
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__MAXIMUM_LENGTH_EXCEEDED]: "The message body provided has a byte-length of $actualBytes. The maximum allowable byte-length is $maxBytes",
|
|
1897
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_FORMAT_MISMATCH]: "Expected message format $expectedMessageFormat, got $actualMessageFormat",
|
|
1898
|
+
[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.",
|
|
1899
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__MESSAGE_MUST_BE_NON_EMPTY]: "Offchain message content must be non-empty",
|
|
1900
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_REQUIRED_SIGNERS_CANNOT_BE_ZERO]: "Offchain message must specify the address of at least one required signer",
|
|
1901
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_ENVELOPE_SIGNATURES_CANNOT_BE_ZERO]: "Offchain message envelope must reserve space for at least one signature",
|
|
1902
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__NUM_SIGNATURES_MISMATCH]: "The offchain message preamble specifies $numRequiredSignatures required signature(s), got $signaturesLength.",
|
|
1903
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_SORTED]: "The signatories of this offchain message must be listed in lexicographical order",
|
|
1904
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATORIES_MUST_BE_UNIQUE]: "An address must be listed no more than once among the signatories of an offchain message",
|
|
1905
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING]: "Offchain message is missing signatures for addresses: $addresses.",
|
|
1906
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE]: "Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",
|
|
1907
|
+
[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].",
|
|
1908
|
+
[SOLANA_ERROR__OFFCHAIN_MESSAGE__UNEXPECTED_VERSION]: "Expected offchain message version $expectedVersion. Got $actualVersion.",
|
|
1909
|
+
[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.",
|
|
1910
|
+
[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'.",
|
|
1911
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
|
|
1912
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED]: "WebSocket connection closed",
|
|
1913
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT]: "WebSocket failed to connect",
|
|
1914
|
+
[SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
|
|
1915
|
+
[SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD]: "Could not find an API plan for RPC method: `$method`",
|
|
1916
|
+
[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`.",
|
|
1917
|
+
[SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
|
|
1918
|
+
[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.",
|
|
1919
|
+
[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.",
|
|
1920
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER]: "The provided value does not implement the `KeyPairSigner` interface",
|
|
1921
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER]: "The provided value does not implement the `MessageModifyingSigner` interface",
|
|
1922
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER]: "The provided value does not implement the `MessagePartialSigner` interface",
|
|
1923
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER]: "The provided value does not implement any of the `MessageSigner` interfaces",
|
|
1924
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER]: "The provided value does not implement the `TransactionModifyingSigner` interface",
|
|
1925
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER]: "The provided value does not implement the `TransactionPartialSigner` interface",
|
|
1926
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER]: "The provided value does not implement the `TransactionSendingSigner` interface",
|
|
1927
|
+
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER]: "The provided value does not implement any of the `TransactionSigner` interfaces",
|
|
1928
|
+
[SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
|
|
1929
|
+
[SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",
|
|
1930
|
+
[SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
|
|
1931
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
|
|
1932
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
|
|
1933
|
+
[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.",
|
|
1934
|
+
[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.",
|
|
1935
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__EXPORT_FUNCTION_UNIMPLEMENTED]: "No signature verification implementation could be found.",
|
|
1936
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
|
|
1937
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
|
|
1938
|
+
[SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
|
|
1939
|
+
[SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
|
|
1940
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
|
|
1941
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
|
|
1942
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
|
|
1943
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND]: "Attempt to debit an account but found no record of a prior credit.",
|
|
1944
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ADDRESS_LOOKUP_TABLE_NOT_FOUND]: "Transaction loads an address table account that doesn't exist",
|
|
1945
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__ALREADY_PROCESSED]: "This transaction has already been processed",
|
|
1946
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND]: "Blockhash not found",
|
|
1947
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__CALL_CHAIN_TOO_DEEP]: "Loader call chain is too deep",
|
|
1948
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__CLUSTER_MAINTENANCE]: "Transactions are currently disabled due to cluster maintenance",
|
|
1949
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION]: "Transaction contains a duplicate instruction ($index) that is not allowed",
|
|
1950
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE]: "Insufficient funds for fee",
|
|
1951
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT]: "Transaction results in an account ($accountIndex) with insufficient funds for rent",
|
|
1952
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_FOR_FEE]: "This account may not be used to pay transaction fees",
|
|
1953
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ACCOUNT_INDEX]: "Transaction contains an invalid account reference",
|
|
1954
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_DATA]: "Transaction loads an address table account with invalid data",
|
|
1955
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_INDEX]: "Transaction address table lookup uses an invalid index",
|
|
1956
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_ADDRESS_LOOKUP_TABLE_OWNER]: "Transaction loads an address table account with an invalid owner",
|
|
1957
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_LOADED_ACCOUNTS_DATA_SIZE_LIMIT]: "LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",
|
|
1958
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_PROGRAM_FOR_EXECUTION]: "This program may not be used for executing instructions",
|
|
1959
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_RENT_PAYING_ACCOUNT]: "Transaction leaves an account with a lower balance than rent-exempt minimum",
|
|
1960
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__INVALID_WRITABLE_ACCOUNT]: "Transaction loads a writable account that cannot be written",
|
|
1961
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__MAX_LOADED_ACCOUNTS_DATA_SIZE_EXCEEDED]: "Transaction exceeded max loaded accounts data size cap",
|
|
1962
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__MISSING_SIGNATURE_FOR_FEE]: "Transaction requires a fee but has no signature present",
|
|
1963
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_ACCOUNT_NOT_FOUND]: "Attempt to load a program that does not exist",
|
|
1964
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED]: "Execution of the program referenced by account at index $accountIndex is temporarily restricted.",
|
|
1965
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__RESANITIZATION_NEEDED]: "ResanitizationNeeded",
|
|
1966
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__SANITIZE_FAILURE]: "Transaction failed to sanitize accounts offsets correctly",
|
|
1967
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__SIGNATURE_FAILURE]: "Transaction did not pass signature verification",
|
|
1968
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__TOO_MANY_ACCOUNT_LOCKS]: "Transaction locked too many accounts",
|
|
1969
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__UNBALANCED_TRANSACTION]: "Sum of account balances before and after transaction do not match",
|
|
1970
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN]: "The transaction failed with the error `$errorName`",
|
|
1971
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__UNSUPPORTED_VERSION]: "Transaction version is unsupported",
|
|
1972
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT]: "Transaction would exceed account data limit within the block",
|
|
1973
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT]: "Transaction would exceed total account data limit",
|
|
1974
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT]: "Transaction would exceed max account limit within the block",
|
|
1975
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_BLOCK_COST_LIMIT]: "Transaction would exceed max Block Cost Limit",
|
|
1976
|
+
[SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT]: "Transaction would exceed max Vote Cost Limit",
|
|
1977
|
+
[SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION]: "Attempted to sign a transaction with an address that is not a signer for it",
|
|
1978
|
+
[SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING]: "Transaction is missing an address at index: $index.",
|
|
1979
|
+
[SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES]: "Transaction has no expected signers therefore it cannot be encoded",
|
|
1980
|
+
[SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT]: "Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",
|
|
1981
|
+
[SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
|
|
1982
|
+
[SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
|
|
1983
|
+
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
|
|
1984
|
+
[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",
|
|
1985
|
+
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
|
|
1986
|
+
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
|
|
1987
|
+
[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",
|
|
1988
|
+
[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",
|
|
1989
|
+
[SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
|
|
1990
|
+
[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.",
|
|
1991
|
+
[SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
|
|
1992
|
+
[SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING]: "Transaction with no instructions cannot be durable nonce transaction.",
|
|
1993
|
+
[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",
|
|
1994
|
+
[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",
|
|
1995
|
+
[SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH]: "The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",
|
|
1996
|
+
[SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING]: "Transaction is missing signatures for addresses: $addresses.",
|
|
1997
|
+
[SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given",
|
|
1998
|
+
[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.",
|
|
1999
|
+
[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."
|
|
2000
|
+
};
|
|
2001
|
+
var START_INDEX = "i";
|
|
2002
|
+
var TYPE = "t";
|
|
2003
|
+
function getHumanReadableErrorMessage(code, context = {}) {
|
|
2004
|
+
const messageFormatString = SolanaErrorMessages[code];
|
|
2005
|
+
if (messageFormatString.length === 0) {
|
|
2006
|
+
return "";
|
|
2007
|
+
}
|
|
2008
|
+
let state;
|
|
2009
|
+
function commitStateUpTo(endIndex) {
|
|
2010
|
+
if (state[TYPE] === 2) {
|
|
2011
|
+
const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex);
|
|
2012
|
+
fragments.push(
|
|
2013
|
+
variableName in context ? (
|
|
2014
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
2015
|
+
`${context[variableName]}`
|
|
2016
|
+
) : `$${variableName}`
|
|
2017
|
+
);
|
|
2018
|
+
} else if (state[TYPE] === 1) {
|
|
2019
|
+
fragments.push(messageFormatString.slice(state[START_INDEX], endIndex));
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
const fragments = [];
|
|
2023
|
+
messageFormatString.split("").forEach((char, ii) => {
|
|
2024
|
+
if (ii === 0) {
|
|
2025
|
+
state = {
|
|
2026
|
+
[START_INDEX]: 0,
|
|
2027
|
+
[TYPE]: messageFormatString[0] === "\\" ? 0 : messageFormatString[0] === "$" ? 2 : 1
|
|
2028
|
+
/* Text */
|
|
2029
|
+
};
|
|
2030
|
+
return;
|
|
2031
|
+
}
|
|
2032
|
+
let nextState;
|
|
2033
|
+
switch (state[TYPE]) {
|
|
2034
|
+
case 0:
|
|
2035
|
+
nextState = {
|
|
2036
|
+
[START_INDEX]: ii,
|
|
2037
|
+
[TYPE]: 1
|
|
2038
|
+
/* Text */
|
|
2039
|
+
};
|
|
2040
|
+
break;
|
|
2041
|
+
case 1:
|
|
2042
|
+
if (char === "\\") {
|
|
2043
|
+
nextState = {
|
|
2044
|
+
[START_INDEX]: ii,
|
|
2045
|
+
[TYPE]: 0
|
|
2046
|
+
/* EscapeSequence */
|
|
2047
|
+
};
|
|
2048
|
+
} else if (char === "$") {
|
|
2049
|
+
nextState = {
|
|
2050
|
+
[START_INDEX]: ii,
|
|
2051
|
+
[TYPE]: 2
|
|
2052
|
+
/* Variable */
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
break;
|
|
2056
|
+
case 2:
|
|
2057
|
+
if (char === "\\") {
|
|
2058
|
+
nextState = {
|
|
2059
|
+
[START_INDEX]: ii,
|
|
2060
|
+
[TYPE]: 0
|
|
2061
|
+
/* EscapeSequence */
|
|
2062
|
+
};
|
|
2063
|
+
} else if (char === "$") {
|
|
2064
|
+
nextState = {
|
|
2065
|
+
[START_INDEX]: ii,
|
|
2066
|
+
[TYPE]: 2
|
|
2067
|
+
/* Variable */
|
|
2068
|
+
};
|
|
2069
|
+
} else if (!char.match(/\w/)) {
|
|
2070
|
+
nextState = {
|
|
2071
|
+
[START_INDEX]: ii,
|
|
2072
|
+
[TYPE]: 1
|
|
2073
|
+
/* Text */
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
break;
|
|
2077
|
+
}
|
|
2078
|
+
if (nextState) {
|
|
2079
|
+
if (state !== nextState) {
|
|
2080
|
+
commitStateUpTo(ii);
|
|
2081
|
+
}
|
|
2082
|
+
state = nextState;
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
commitStateUpTo();
|
|
2086
|
+
return fragments.join("");
|
|
2087
|
+
}
|
|
2088
|
+
function getErrorMessage(code, context = {}) {
|
|
2089
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2090
|
+
return getHumanReadableErrorMessage(code, context);
|
|
2091
|
+
} else {
|
|
2092
|
+
let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \`npx @solana/errors decode -- ${code}`;
|
|
2093
|
+
if (Object.keys(context).length) {
|
|
2094
|
+
decodingAdviceMessage += ` '${encodeContextObject(context)}'`;
|
|
2095
|
+
}
|
|
2096
|
+
return `${decodingAdviceMessage}\``;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
var SolanaError = class extends Error {
|
|
2100
|
+
constructor(...[code, contextAndErrorOptions]) {
|
|
2101
|
+
let context;
|
|
2102
|
+
let errorOptions;
|
|
2103
|
+
if (contextAndErrorOptions) {
|
|
2104
|
+
Object.entries(Object.getOwnPropertyDescriptors(contextAndErrorOptions)).forEach(([name, descriptor]) => {
|
|
2105
|
+
if (name === "cause") {
|
|
2106
|
+
errorOptions = { cause: descriptor.value };
|
|
2107
|
+
} else {
|
|
2108
|
+
if (context === void 0) {
|
|
2109
|
+
context = {
|
|
2110
|
+
__code: code
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
Object.defineProperty(context, name, descriptor);
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
const message = getErrorMessage(code, context);
|
|
2118
|
+
super(message, errorOptions);
|
|
2119
|
+
/**
|
|
2120
|
+
* Indicates the root cause of this {@link SolanaError}, if any.
|
|
2121
|
+
*
|
|
2122
|
+
* For example, a transaction error might have an instruction error as its root cause. In this
|
|
2123
|
+
* case, you will be able to access the instruction error on the transaction error as `cause`.
|
|
2124
|
+
*/
|
|
2125
|
+
__publicField(this, "cause", this.cause);
|
|
2126
|
+
/**
|
|
2127
|
+
* Contains context that can assist in understanding or recovering from a {@link SolanaError}.
|
|
2128
|
+
*/
|
|
2129
|
+
__publicField(this, "context");
|
|
2130
|
+
this.context = Object.freeze(
|
|
2131
|
+
context === void 0 ? {
|
|
2132
|
+
__code: code
|
|
2133
|
+
} : context
|
|
2134
|
+
);
|
|
2135
|
+
this.name = "SolanaError";
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
|
|
2139
|
+
// node_modules/@solana/codecs-core/dist/index.node.mjs
|
|
2140
|
+
function getEncodedSize(value, encoder) {
|
|
2141
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
2142
|
+
}
|
|
2143
|
+
function createEncoder(encoder) {
|
|
2144
|
+
return Object.freeze({
|
|
2145
|
+
...encoder,
|
|
2146
|
+
encode: (value) => {
|
|
2147
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
2148
|
+
encoder.write(value, bytes, 0);
|
|
2149
|
+
return bytes;
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
// node_modules/@solana/codecs-strings/dist/index.node.mjs
|
|
2155
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
2156
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
2157
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
|
|
2158
|
+
alphabet: alphabet4,
|
|
2159
|
+
base: alphabet4.length,
|
|
2160
|
+
value: givenValue
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
2165
|
+
return createEncoder({
|
|
2166
|
+
getSizeFromValue: (value) => {
|
|
2167
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
2168
|
+
if (!tailChars) return value.length;
|
|
2169
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
2170
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
2171
|
+
},
|
|
2172
|
+
write(value, bytes, offset) {
|
|
2173
|
+
assertValidBaseString(alphabet4, value);
|
|
2174
|
+
if (value === "") return offset;
|
|
2175
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
2176
|
+
if (!tailChars) {
|
|
2177
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
2178
|
+
return offset + leadingZeroes.length;
|
|
2179
|
+
}
|
|
2180
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
2181
|
+
const tailBytes = [];
|
|
2182
|
+
while (base10Number > 0n) {
|
|
2183
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
2184
|
+
base10Number /= 256n;
|
|
2185
|
+
}
|
|
2186
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
2187
|
+
bytes.set(bytesToAdd, offset);
|
|
2188
|
+
return offset + bytesToAdd.length;
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
};
|
|
2192
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
2193
|
+
const [leadingZeros, tailChars] = value.split(new RegExp(`((?!${zeroCharacter}).*)`));
|
|
2194
|
+
return [leadingZeros, tailChars];
|
|
2195
|
+
}
|
|
2196
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
2197
|
+
const base = BigInt(alphabet4.length);
|
|
2198
|
+
let sum = 0n;
|
|
2199
|
+
for (const char of value) {
|
|
2200
|
+
sum *= base;
|
|
2201
|
+
sum += BigInt(alphabet4.indexOf(char));
|
|
2202
|
+
}
|
|
2203
|
+
return sum;
|
|
2204
|
+
}
|
|
2205
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2206
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
2207
|
+
var e = globalThis.TextDecoder;
|
|
2208
|
+
var o = globalThis.TextEncoder;
|
|
2209
|
+
|
|
2210
|
+
// node_modules/@solana/addresses/dist/index.node.mjs
|
|
2211
|
+
var memoizedBase58Encoder;
|
|
2212
|
+
function getMemoizedBase58Encoder() {
|
|
2213
|
+
if (!memoizedBase58Encoder) memoizedBase58Encoder = getBase58Encoder();
|
|
2214
|
+
return memoizedBase58Encoder;
|
|
2215
|
+
}
|
|
2216
|
+
function isAddress(putativeAddress) {
|
|
2217
|
+
if (
|
|
2218
|
+
// Lowest address (32 bytes of zeroes)
|
|
2219
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
2220
|
+
putativeAddress.length > 44
|
|
2221
|
+
) {
|
|
2222
|
+
return false;
|
|
2223
|
+
}
|
|
2224
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
2225
|
+
try {
|
|
2226
|
+
return base58Encoder.encode(putativeAddress).byteLength === 32;
|
|
2227
|
+
} catch {
|
|
2228
|
+
return false;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
// src/validation/address.ts
|
|
2233
|
+
init_chains();
|
|
2234
|
+
var BECH32_CHARSET = /^[023456789acdefghjklmnpqrstuvwxyz]+$/i;
|
|
2235
|
+
function hasMixedCase(value) {
|
|
2236
|
+
return value !== value.toLowerCase() && value !== value.toUpperCase();
|
|
2237
|
+
}
|
|
2238
|
+
function validateBech32LikeAddress(address, prefix) {
|
|
2239
|
+
const trimmed = address.trim();
|
|
2240
|
+
if (!trimmed) {
|
|
2241
|
+
return { isValid: false, error: "Address is required." };
|
|
2242
|
+
}
|
|
2243
|
+
if (hasMixedCase(trimmed)) {
|
|
2244
|
+
return { isValid: false, error: "Bech32 addresses cannot mix case." };
|
|
2245
|
+
}
|
|
2246
|
+
const lower = trimmed.toLowerCase();
|
|
2247
|
+
const expectedPrefix = `${prefix.toLowerCase()}1`;
|
|
2248
|
+
if (!lower.startsWith(expectedPrefix)) {
|
|
2249
|
+
return {
|
|
2250
|
+
isValid: false,
|
|
2251
|
+
error: `Address must start with ${expectedPrefix}.`
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
const dataPart = lower.slice(expectedPrefix.length);
|
|
2255
|
+
if (dataPart.length < 6 || !BECH32_CHARSET.test(dataPart)) {
|
|
2256
|
+
return {
|
|
2257
|
+
isValid: false,
|
|
2258
|
+
error: "Bech32 address format is invalid."
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
return { isValid: true };
|
|
2262
|
+
}
|
|
2263
|
+
function validateEvmAddress(address) {
|
|
2264
|
+
if (!isEvmAddress(address.trim())) {
|
|
2265
|
+
return {
|
|
2266
|
+
isValid: false,
|
|
2267
|
+
error: "EVM addresses must be 0x-prefixed 20-byte hex strings."
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
return { isValid: true };
|
|
2271
|
+
}
|
|
2272
|
+
function validateSeiAddress(address) {
|
|
2273
|
+
const trimmed = address.trim();
|
|
2274
|
+
if (isEvmAddress(trimmed)) {
|
|
2275
|
+
return { isValid: true };
|
|
2276
|
+
}
|
|
2277
|
+
const result = validateBech32LikeAddress(trimmed, "sei");
|
|
2278
|
+
if (result.isValid) return result;
|
|
2279
|
+
return {
|
|
2280
|
+
isValid: false,
|
|
2281
|
+
error: "SEI addresses must be 0x-prefixed EVM or sei1 bech32 strings."
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
function validateSolanaAddress(address) {
|
|
2285
|
+
const trimmed = address.trim();
|
|
2286
|
+
if (trimmed.startsWith("0x") || isEvmAddress(trimmed)) {
|
|
2287
|
+
return {
|
|
2288
|
+
isValid: false,
|
|
2289
|
+
error: "Solana addresses must be base58-encoded strings."
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
if (trimmed.toLowerCase().startsWith("bc1") || trimmed.toLowerCase().startsWith("sei1")) {
|
|
2293
|
+
return {
|
|
2294
|
+
isValid: false,
|
|
2295
|
+
error: "Solana addresses cannot be bech32 strings."
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
if (!isAddress(trimmed)) {
|
|
2299
|
+
return {
|
|
2300
|
+
isValid: false,
|
|
2301
|
+
error: "Solana addresses must be base58-encoded strings."
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
return { isValid: true };
|
|
2305
|
+
}
|
|
2306
|
+
function validateBtcAddress(address) {
|
|
2307
|
+
const trimmed = address.trim();
|
|
2308
|
+
if (hasMixedCase(trimmed)) {
|
|
2309
|
+
return { isValid: false, error: "Bitcoin addresses cannot mix case." };
|
|
2310
|
+
}
|
|
2311
|
+
const result = validateBech32LikeAddress(trimmed, "bc");
|
|
2312
|
+
if (result.isValid) return result;
|
|
2313
|
+
return {
|
|
2314
|
+
isValid: false,
|
|
2315
|
+
error: "Bitcoin addresses must use native SegWit (bc1...) format."
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
function validateAddressForChain(address, chain) {
|
|
2319
|
+
const trimmed = address.trim();
|
|
2320
|
+
if (!trimmed) return { isValid: true };
|
|
2321
|
+
const chainType = normalizeChainType(chain);
|
|
2322
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
2323
|
+
switch (chainType) {
|
|
2324
|
+
case "evm":
|
|
2325
|
+
return validateEvmAddress(trimmed);
|
|
2326
|
+
case "solana":
|
|
2327
|
+
return validateSolanaAddress(trimmed);
|
|
2328
|
+
case "bitcoin":
|
|
2329
|
+
return validateBtcAddress(trimmed);
|
|
2330
|
+
case "cosmos":
|
|
2331
|
+
if (chainDef?.networkIdentifier?.toLowerCase() === "sei") {
|
|
2332
|
+
return validateSeiAddress(trimmed);
|
|
2333
|
+
}
|
|
2334
|
+
return validateBech32LikeAddress(trimmed, "sei");
|
|
2335
|
+
default:
|
|
2336
|
+
return { isValid: false, error: "Unsupported or unknown chain type." };
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
function validateAddressForRouteChain(address, chainType) {
|
|
2340
|
+
switch (normalizeChainType(chainType)) {
|
|
2341
|
+
case "evm":
|
|
2342
|
+
return validateEvmAddress(address);
|
|
2343
|
+
case "solana":
|
|
2344
|
+
return validateSolanaAddress(address);
|
|
2345
|
+
case "bitcoin":
|
|
2346
|
+
return validateBtcAddress(address);
|
|
2347
|
+
case "cosmos":
|
|
2348
|
+
return validateSeiAddress(address);
|
|
2349
|
+
default:
|
|
2350
|
+
return { isValid: false, error: "Unsupported chain type." };
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
function validateRouteAddresses(params) {
|
|
2354
|
+
const fromType = normalizeChainType(params.fromChain);
|
|
2355
|
+
const toType = normalizeChainType(params.toChain);
|
|
2356
|
+
if (!fromType || !toType) {
|
|
2357
|
+
return {
|
|
2358
|
+
isValid: false,
|
|
2359
|
+
error: "Missing chain types for route validation."
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
const fromAddress = params.fromAddress.trim();
|
|
2363
|
+
const toAddress = params.toAddress.trim();
|
|
2364
|
+
if (!fromAddress || !toAddress) {
|
|
2365
|
+
return { isValid: false, error: "Route addresses are required." };
|
|
2366
|
+
}
|
|
2367
|
+
const normalizedDirection = params.direction?.trim().toLowerCase();
|
|
2368
|
+
const isDepositFlow = normalizedDirection === "deposit" || (toType === "evm" || toType === "cosmos") && (fromType === "bitcoin" || fromType === "solana");
|
|
2369
|
+
if (isDepositFlow) {
|
|
2370
|
+
const fromResult2 = validateAddressForRouteChain(fromAddress, fromType);
|
|
2371
|
+
if (!fromResult2.isValid) {
|
|
2372
|
+
return {
|
|
2373
|
+
isValid: false,
|
|
2374
|
+
error: `From address: ${fromResult2.error ?? "Invalid address."}`
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
const toResult2 = toType === "cosmos" ? validateSeiAddress(toAddress) : validateEvmAddress(toAddress);
|
|
2378
|
+
if (!toResult2.isValid) {
|
|
2379
|
+
return {
|
|
2380
|
+
isValid: false,
|
|
2381
|
+
error: `To address: ${toResult2.error ?? "Invalid address."}`
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
if (fromType === "bitcoin") {
|
|
2385
|
+
const refundAddress = params.refundAddress?.trim();
|
|
2386
|
+
if (!refundAddress) {
|
|
2387
|
+
return {
|
|
2388
|
+
isValid: false,
|
|
2389
|
+
error: "Refund address is required for BTC deposit routes."
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
const refundResult = validateBtcAddress(refundAddress);
|
|
2393
|
+
if (!refundResult.isValid) {
|
|
2394
|
+
return {
|
|
2395
|
+
isValid: false,
|
|
2396
|
+
error: `Refund address: ${refundResult.error ?? "Invalid address."}`
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
return { isValid: true };
|
|
2401
|
+
}
|
|
2402
|
+
const fromResult = validateAddressForRouteChain(fromAddress, fromType);
|
|
2403
|
+
if (!fromResult.isValid) {
|
|
2404
|
+
return {
|
|
2405
|
+
isValid: false,
|
|
2406
|
+
error: `From address: ${fromResult.error ?? "Invalid address."}`
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
const toResult = validateAddressForRouteChain(toAddress, toType);
|
|
2410
|
+
if (!toResult.isValid) {
|
|
2411
|
+
return {
|
|
2412
|
+
isValid: false,
|
|
2413
|
+
error: `To address: ${toResult.error ?? "Invalid address."}`
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
return { isValid: true };
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
// src/identity/index.ts
|
|
2420
|
+
init_chains();
|
|
2421
|
+
function normalizeIdentityChainId(chain) {
|
|
2422
|
+
if (!chain || typeof chain === "string") return void 0;
|
|
2423
|
+
const raw = chain.chainId ?? chain.id;
|
|
2424
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
2425
|
+
const normalized = String(raw).trim();
|
|
2426
|
+
return normalized || void 0;
|
|
2427
|
+
}
|
|
2428
|
+
function identityEntryMatchesChain(entry, chainType, chainKey, chainId) {
|
|
2429
|
+
if (chainKey && entry.chainKey && entry.chainKey === chainKey) return true;
|
|
2430
|
+
if (chainId && entry.chainId && entry.chainId === chainId) return true;
|
|
2431
|
+
if (chainType && entry.chainType === chainType) return true;
|
|
2432
|
+
return false;
|
|
2433
|
+
}
|
|
2434
|
+
function createWalletIdentity(addresses = []) {
|
|
2435
|
+
return { addresses };
|
|
2436
|
+
}
|
|
2437
|
+
function upsertWalletIdentityAddress(identity, next) {
|
|
2438
|
+
const normalizedAddress = next.address.trim();
|
|
2439
|
+
const normalizedChainKey = next.chainKey ? normalizeChainKey(next.chainKey) : void 0;
|
|
2440
|
+
const normalizedChainId = next.chainId?.trim() || void 0;
|
|
2441
|
+
const addresses = identity.addresses.filter((entry) => {
|
|
2442
|
+
if (entry.chainType !== next.chainType) return true;
|
|
2443
|
+
if (normalizedChainKey && entry.chainKey === normalizedChainKey)
|
|
2444
|
+
return false;
|
|
2445
|
+
if (normalizedChainId && entry.chainId === normalizedChainId) return false;
|
|
2446
|
+
if (!normalizedChainKey && !normalizedChainId) return false;
|
|
2447
|
+
return true;
|
|
2448
|
+
});
|
|
2449
|
+
if (!normalizedAddress) return createWalletIdentity(addresses);
|
|
2450
|
+
return createWalletIdentity([
|
|
2451
|
+
...addresses,
|
|
2452
|
+
{
|
|
2453
|
+
...next,
|
|
2454
|
+
address: normalizedAddress,
|
|
2455
|
+
chainKey: normalizedChainKey,
|
|
2456
|
+
chainId: normalizedChainId
|
|
2457
|
+
}
|
|
2458
|
+
]);
|
|
2459
|
+
}
|
|
2460
|
+
function resolveWalletAddressForChain(identity, chain) {
|
|
2461
|
+
const chainType = normalizeChainType(chain);
|
|
2462
|
+
const chainDef = typeof chain === "object" && chain ? chain : void 0;
|
|
2463
|
+
const chainKey = chainDef ? normalizeChainKey(
|
|
2464
|
+
chainDef.networkIdentifier ?? chainDef.chainId ?? chainDef.id
|
|
2465
|
+
) : typeof chain === "string" ? normalizeChainKey(chain) : void 0;
|
|
2466
|
+
const chainId = normalizeIdentityChainId(chain);
|
|
2467
|
+
if (!chainType) {
|
|
2468
|
+
return {
|
|
2469
|
+
status: "missing",
|
|
2470
|
+
reason: "unknown_chain_type",
|
|
2471
|
+
chainKey,
|
|
2472
|
+
chainId
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
const match = identity.addresses.find(
|
|
2476
|
+
(entry) => identityEntryMatchesChain(entry, chainType, chainKey, chainId)
|
|
2477
|
+
);
|
|
2478
|
+
if (!match) {
|
|
2479
|
+
return {
|
|
2480
|
+
status: "missing",
|
|
2481
|
+
reason: "missing_chain_address",
|
|
2482
|
+
chainType,
|
|
2483
|
+
chainKey,
|
|
2484
|
+
chainId
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
const validation = validateAddressForChain(
|
|
2488
|
+
match.address,
|
|
2489
|
+
chainDef ?? chainType
|
|
2490
|
+
);
|
|
2491
|
+
if (!validation.isValid) {
|
|
2492
|
+
return {
|
|
2493
|
+
status: "invalid",
|
|
2494
|
+
reason: validation.error ?? "invalid_chain_address",
|
|
2495
|
+
address: match.address,
|
|
2496
|
+
source: match.source,
|
|
2497
|
+
chainType,
|
|
2498
|
+
chainKey,
|
|
2499
|
+
chainId
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
return {
|
|
2503
|
+
status: "resolved",
|
|
2504
|
+
address: match.address.trim(),
|
|
2505
|
+
source: match.source,
|
|
2506
|
+
chainType,
|
|
2507
|
+
chainKey,
|
|
2508
|
+
chainId
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2511
|
+
function buildWalletIdentityAddress(params) {
|
|
2512
|
+
const chainType = normalizeChainType(params.chain);
|
|
2513
|
+
if (!chainType) return null;
|
|
2514
|
+
const address = params.address.trim();
|
|
2515
|
+
const chainId = normalizeIdentityChainId(params.chain);
|
|
2516
|
+
const chainDef = typeof params.chain === "object" && params.chain ? params.chain : void 0;
|
|
2517
|
+
const chainKey = chainDef ? normalizeChainKey(
|
|
2518
|
+
chainDef.networkIdentifier ?? chainDef.chainId ?? chainDef.id
|
|
2519
|
+
) : void 0;
|
|
2520
|
+
return {
|
|
2521
|
+
address,
|
|
2522
|
+
chainType,
|
|
2523
|
+
chainId,
|
|
2524
|
+
chainKey,
|
|
2525
|
+
providerId: params.providerId,
|
|
2526
|
+
source: params.source
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
var IdentityStore = class {
|
|
2530
|
+
constructor() {
|
|
2531
|
+
this._identity = createWalletIdentity();
|
|
2532
|
+
}
|
|
2533
|
+
get snapshot() {
|
|
2534
|
+
return this._identity;
|
|
2535
|
+
}
|
|
2536
|
+
reset() {
|
|
2537
|
+
this._identity = createWalletIdentity();
|
|
2538
|
+
}
|
|
2539
|
+
upsert(next) {
|
|
2540
|
+
this._identity = upsertWalletIdentityAddress(this._identity, next);
|
|
2541
|
+
return this._identity;
|
|
2542
|
+
}
|
|
2543
|
+
resolve(chain) {
|
|
2544
|
+
return resolveWalletAddressForChain(this._identity, chain);
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
|
|
1158
2548
|
// src/wallets/manager.ts
|
|
1159
2549
|
import { useEffect as useEffect2 } from "react";
|
|
1160
2550
|
var WalletManager = class {
|
|
@@ -1163,6 +2553,9 @@ var WalletManager = class {
|
|
|
1163
2553
|
this._wallet = null;
|
|
1164
2554
|
this._detected = [];
|
|
1165
2555
|
this._listeners = /* @__PURE__ */ new Set();
|
|
2556
|
+
this._identity = new IdentityStore();
|
|
2557
|
+
this._providerCleanup = null;
|
|
2558
|
+
this._connectedWalletId = null;
|
|
1166
2559
|
}
|
|
1167
2560
|
get status() {
|
|
1168
2561
|
return this._status;
|
|
@@ -1178,8 +2571,14 @@ var WalletManager = class {
|
|
|
1178
2571
|
}
|
|
1179
2572
|
get simple() {
|
|
1180
2573
|
if (!this._wallet) return null;
|
|
1181
|
-
const { getAddress,
|
|
1182
|
-
return { getAddress,
|
|
2574
|
+
const { getAddress, disconnect } = this._wallet;
|
|
2575
|
+
return { getAddress, disconnect };
|
|
2576
|
+
}
|
|
2577
|
+
get identity() {
|
|
2578
|
+
return this._identity.snapshot;
|
|
2579
|
+
}
|
|
2580
|
+
get connectedWalletId() {
|
|
2581
|
+
return this._connectedWalletId;
|
|
1183
2582
|
}
|
|
1184
2583
|
onChange(fn) {
|
|
1185
2584
|
this._listeners.add(fn);
|
|
@@ -1200,17 +2599,28 @@ var WalletManager = class {
|
|
|
1200
2599
|
await this.connectDetected(target, opts);
|
|
1201
2600
|
}
|
|
1202
2601
|
async connectDetected(target, opts) {
|
|
2602
|
+
if (this._status === "connected" && this._connectedWalletId === target.meta.id && this._wallet) {
|
|
2603
|
+
this.emit();
|
|
2604
|
+
return;
|
|
2605
|
+
}
|
|
1203
2606
|
this._status = "connecting";
|
|
2607
|
+
this.clearConnectedWalletState();
|
|
1204
2608
|
this.emit();
|
|
1205
2609
|
try {
|
|
1206
2610
|
const { api } = await connectDetectedWallet(target, {
|
|
1207
2611
|
wagmi: opts?.wagmi
|
|
1208
2612
|
});
|
|
1209
|
-
if (api)
|
|
2613
|
+
if (api) {
|
|
2614
|
+
this._wallet = api;
|
|
2615
|
+
this._connectedWalletId = target.meta.id;
|
|
2616
|
+
this.bindProviderEvents(target);
|
|
2617
|
+
await this.syncIdentityFromWallet(target.meta.id);
|
|
2618
|
+
}
|
|
1210
2619
|
this._status = "connected";
|
|
1211
|
-
} catch (
|
|
1212
|
-
this._error =
|
|
2620
|
+
} catch (e2) {
|
|
2621
|
+
this._error = e2;
|
|
1213
2622
|
this._status = "error";
|
|
2623
|
+
this.clearConnectedWalletState();
|
|
1214
2624
|
} finally {
|
|
1215
2625
|
this.emit();
|
|
1216
2626
|
}
|
|
@@ -1218,14 +2628,21 @@ var WalletManager = class {
|
|
|
1218
2628
|
async disconnect(wagmi) {
|
|
1219
2629
|
if (wagmi) await wagmi.disconnect().catch(() => {
|
|
1220
2630
|
});
|
|
1221
|
-
this._wallet
|
|
2631
|
+
if (this._wallet?.disconnect) {
|
|
2632
|
+
await this._wallet.disconnect().catch(() => {
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
this.clearConnectedWalletState();
|
|
1222
2636
|
this._status = "idle";
|
|
1223
2637
|
this.emit();
|
|
1224
2638
|
}
|
|
1225
2639
|
/** Directly attach a pre-provided wallet interface (from old provider prop). */
|
|
1226
2640
|
attachWallet(api) {
|
|
2641
|
+
this.clearConnectedWalletState();
|
|
1227
2642
|
this._wallet = api;
|
|
2643
|
+
this._connectedWalletId = null;
|
|
1228
2644
|
this._status = "connected";
|
|
2645
|
+
void this.syncIdentityFromWallet();
|
|
1229
2646
|
this.emit();
|
|
1230
2647
|
}
|
|
1231
2648
|
/** Optional helper to set explicit status (e.g., "initializing" UX). */
|
|
@@ -1233,6 +2650,90 @@ var WalletManager = class {
|
|
|
1233
2650
|
this._status = s;
|
|
1234
2651
|
this.emit();
|
|
1235
2652
|
}
|
|
2653
|
+
addIdentityAddress(address) {
|
|
2654
|
+
this._identity.upsert(address);
|
|
2655
|
+
}
|
|
2656
|
+
resolveAddressForChain(chain) {
|
|
2657
|
+
return this._identity.resolve(chain);
|
|
2658
|
+
}
|
|
2659
|
+
clearProviderCleanup() {
|
|
2660
|
+
this._providerCleanup?.();
|
|
2661
|
+
this._providerCleanup = null;
|
|
2662
|
+
}
|
|
2663
|
+
clearConnectedWalletState() {
|
|
2664
|
+
this.clearProviderCleanup();
|
|
2665
|
+
this._wallet = null;
|
|
2666
|
+
this._connectedWalletId = null;
|
|
2667
|
+
}
|
|
2668
|
+
bindProviderEvents(target) {
|
|
2669
|
+
if (!target.provider) return;
|
|
2670
|
+
if (target.via === "solana-window") {
|
|
2671
|
+
this._providerCleanup = bindSolanaProviderEvents(target.provider, {
|
|
2672
|
+
onConnect: () => {
|
|
2673
|
+
this._status = "connected";
|
|
2674
|
+
void this.syncIdentityFromWallet(target.meta.id);
|
|
2675
|
+
this.emit();
|
|
2676
|
+
},
|
|
2677
|
+
onAccountChanged: () => {
|
|
2678
|
+
void this.syncIdentityFromWallet(target.meta.id);
|
|
2679
|
+
this.emit();
|
|
2680
|
+
},
|
|
2681
|
+
onDisconnect: () => {
|
|
2682
|
+
this.clearConnectedWalletState();
|
|
2683
|
+
this._status = "idle";
|
|
2684
|
+
this.emit();
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
return;
|
|
2688
|
+
}
|
|
2689
|
+
const provider = target.provider;
|
|
2690
|
+
const onAccountsChanged = (accounts) => {
|
|
2691
|
+
const nextAccounts = Array.isArray(accounts) ? accounts : [];
|
|
2692
|
+
if (nextAccounts.length === 0) {
|
|
2693
|
+
this.clearConnectedWalletState();
|
|
2694
|
+
this._status = "idle";
|
|
2695
|
+
this.emit();
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
this._status = "connected";
|
|
2699
|
+
void this.syncIdentityFromWallet(target.meta.id);
|
|
2700
|
+
this.emit();
|
|
2701
|
+
};
|
|
2702
|
+
const onDisconnect = () => {
|
|
2703
|
+
this.clearConnectedWalletState();
|
|
2704
|
+
this._status = "idle";
|
|
2705
|
+
this.emit();
|
|
2706
|
+
};
|
|
2707
|
+
provider.on?.("accountsChanged", onAccountsChanged);
|
|
2708
|
+
provider.on?.("disconnect", onDisconnect);
|
|
2709
|
+
this._providerCleanup = () => {
|
|
2710
|
+
provider.off?.("accountsChanged", onAccountsChanged);
|
|
2711
|
+
provider.off?.("disconnect", onDisconnect);
|
|
2712
|
+
provider.removeListener?.("accountsChanged", onAccountsChanged);
|
|
2713
|
+
provider.removeListener?.("disconnect", onDisconnect);
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
async syncIdentityFromWallet(providerId) {
|
|
2717
|
+
if (!this._wallet) return;
|
|
2718
|
+
try {
|
|
2719
|
+
const address = await this._wallet.getAddress();
|
|
2720
|
+
const chain = this._wallet.ecosystem === "evm" ? { chainId: String(await this._wallet.getChainId()), type: "evm" } : {
|
|
2721
|
+
chainId: "solana-mainnet-beta",
|
|
2722
|
+
networkIdentifier: "solana-mainnet-beta",
|
|
2723
|
+
type: "solana"
|
|
2724
|
+
};
|
|
2725
|
+
const identityAddress = buildWalletIdentityAddress({
|
|
2726
|
+
address,
|
|
2727
|
+
chain,
|
|
2728
|
+
source: "provider",
|
|
2729
|
+
providerId
|
|
2730
|
+
});
|
|
2731
|
+
if (identityAddress) {
|
|
2732
|
+
this._identity.upsert(identityAddress);
|
|
2733
|
+
}
|
|
2734
|
+
} catch {
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
1236
2737
|
};
|
|
1237
2738
|
var walletManager = new WalletManager();
|
|
1238
2739
|
function useWireDetectionIntoManager() {
|
|
@@ -1245,13 +2746,30 @@ function useWireDetectionIntoManager() {
|
|
|
1245
2746
|
// src/core/routes.ts
|
|
1246
2747
|
init_http();
|
|
1247
2748
|
init_store();
|
|
2749
|
+
function isEvmTxRequest(txReq) {
|
|
2750
|
+
return Boolean(txReq?.data && (txReq.to || txReq.target));
|
|
2751
|
+
}
|
|
2752
|
+
function isSerializedSolanaTxRequest(txReq) {
|
|
2753
|
+
return Boolean(txReq?.data && !txReq?.to && !txReq?.target);
|
|
2754
|
+
}
|
|
1248
2755
|
async function buildRoute(body, signal) {
|
|
2756
|
+
const addressValidation = validateRouteAddresses({
|
|
2757
|
+
fromChain: body.fromChain,
|
|
2758
|
+
toChain: body.toChain,
|
|
2759
|
+
fromAddress: body.fromAddress,
|
|
2760
|
+
toAddress: body.toAddress,
|
|
2761
|
+
refundAddress: body.refundAddress,
|
|
2762
|
+
direction: body.direction
|
|
2763
|
+
});
|
|
2764
|
+
if (!addressValidation.isValid) {
|
|
2765
|
+
throw new Error(addressValidation.error || "Invalid route addresses.");
|
|
2766
|
+
}
|
|
1249
2767
|
const cfg = TrustwareConfigStore.get();
|
|
1250
|
-
const url = `${apiBase()}/routes/route`;
|
|
2768
|
+
const url = `${apiBase()}/v1/routes/route`;
|
|
1251
2769
|
const payload = {
|
|
1252
2770
|
...body,
|
|
1253
|
-
slippageBps: body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100),
|
|
1254
|
-
fromAmountUSD: body.fromAmountUsd
|
|
2771
|
+
slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
|
|
2772
|
+
fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
|
|
1255
2773
|
};
|
|
1256
2774
|
const r = await rateLimitedFetch(url, {
|
|
1257
2775
|
method: "POST",
|
|
@@ -1275,16 +2793,58 @@ async function buildRoute(body, signal) {
|
|
|
1275
2793
|
const estimate = route?.estimate ?? {};
|
|
1276
2794
|
const finalExchangeRate = {
|
|
1277
2795
|
fromAmountUSD: estimate.fromAmountUsd,
|
|
1278
|
-
toAmountMinUSD: estimate?.toAmountUsd
|
|
2796
|
+
toAmountMinUSD: estimate?.toAmountMinUsd ?? estimate?.toAmountUsd
|
|
1279
2797
|
};
|
|
1280
|
-
if (!txReq?.data
|
|
1281
|
-
throw new Error("Invalid route: missing
|
|
2798
|
+
if (!txReq?.data) {
|
|
2799
|
+
throw new Error("Invalid route: missing transaction data");
|
|
1282
2800
|
}
|
|
1283
2801
|
return { intentId, txReq, actions, finalExchangeRate, route };
|
|
1284
2802
|
}
|
|
2803
|
+
async function buildDepositAddress(body, signal) {
|
|
2804
|
+
const cfg = TrustwareConfigStore.get();
|
|
2805
|
+
const url = `${apiBase()}/v1/routes/deposit-address`;
|
|
2806
|
+
const payload = {
|
|
2807
|
+
...body,
|
|
2808
|
+
slippageBps: body.slippageBps ?? (body.slippage === void 0 ? void 0 : Math.round(body.slippage * 100)),
|
|
2809
|
+
fromAmountUSD: body.fromAmountUSD ?? body.fromAmountUsd
|
|
2810
|
+
};
|
|
2811
|
+
const r = await rateLimitedFetch(url, {
|
|
2812
|
+
method: "POST",
|
|
2813
|
+
headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
|
|
2814
|
+
body: JSON.stringify(payload),
|
|
2815
|
+
signal
|
|
2816
|
+
});
|
|
2817
|
+
let json = {};
|
|
2818
|
+
try {
|
|
2819
|
+
json = await r.json();
|
|
2820
|
+
} catch {
|
|
2821
|
+
}
|
|
2822
|
+
if (!r.ok) {
|
|
2823
|
+
const msg = json?.error || json?.message || "Failed to build deposit address";
|
|
2824
|
+
throw new Error(msg);
|
|
2825
|
+
}
|
|
2826
|
+
const intentId = json?.data?.intentId ?? json?.intentId ?? "";
|
|
2827
|
+
const route = json?.data?.route ?? json?.route;
|
|
2828
|
+
const depositAddress = json?.data?.depositAddress?.address ?? json?.depositAddress?.address ?? "";
|
|
2829
|
+
const actions = Array.isArray(route?.steps) ? route.steps : [];
|
|
2830
|
+
const estimate = route?.estimate ?? {};
|
|
2831
|
+
if (!depositAddress) {
|
|
2832
|
+
throw new Error("Invalid route: missing deposit address");
|
|
2833
|
+
}
|
|
2834
|
+
return {
|
|
2835
|
+
intentId,
|
|
2836
|
+
depositAddress,
|
|
2837
|
+
actions,
|
|
2838
|
+
finalExchangeRate: {
|
|
2839
|
+
fromAmountUSD: estimate.fromAmountUsd,
|
|
2840
|
+
toAmountMinUSD: estimate?.toAmountMinUsd ?? estimate?.toAmountUsd
|
|
2841
|
+
},
|
|
2842
|
+
route
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
1285
2845
|
async function submitReceipt(intentId, txHash) {
|
|
1286
2846
|
const r = await rateLimitedFetch(
|
|
1287
|
-
`${apiBase()}/route-intent/${intentId}/receipt`,
|
|
2847
|
+
`${apiBase()}/v1/route-intent/${intentId}/receipt`,
|
|
1288
2848
|
{
|
|
1289
2849
|
method: "POST",
|
|
1290
2850
|
headers: jsonHeaders({ "Idempotency-Key": txHash }),
|
|
@@ -1297,7 +2857,7 @@ async function submitReceipt(intentId, txHash) {
|
|
|
1297
2857
|
}
|
|
1298
2858
|
async function getStatus(intentId) {
|
|
1299
2859
|
const r = await rateLimitedFetch(
|
|
1300
|
-
`${apiBase()}/route-intent/${intentId}/status`,
|
|
2860
|
+
`${apiBase()}/v1/route-intent/${intentId}/status`,
|
|
1301
2861
|
{
|
|
1302
2862
|
headers: jsonHeaders()
|
|
1303
2863
|
}
|
|
@@ -1319,20 +2879,125 @@ async function pollStatus(intentId, { intervalMs = 2e3, timeoutMs = 5 * 6e4 } =
|
|
|
1319
2879
|
// src/core/balances.ts
|
|
1320
2880
|
init_http();
|
|
1321
2881
|
init_registry();
|
|
1322
|
-
|
|
2882
|
+
init_chains();
|
|
2883
|
+
var balanceCache = /* @__PURE__ */ new Map();
|
|
2884
|
+
function toStringOrUndefined(value) {
|
|
2885
|
+
if (typeof value !== "string") return void 0;
|
|
2886
|
+
const trimmed = value.trim();
|
|
2887
|
+
return trimmed || void 0;
|
|
2888
|
+
}
|
|
2889
|
+
function toNumberOrUndefined(value) {
|
|
2890
|
+
if (typeof value === "number") {
|
|
2891
|
+
return Number.isFinite(value) ? value : void 0;
|
|
2892
|
+
}
|
|
2893
|
+
if (typeof value === "string") {
|
|
2894
|
+
const parsed = Number(value.trim());
|
|
2895
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
2896
|
+
}
|
|
2897
|
+
return void 0;
|
|
2898
|
+
}
|
|
2899
|
+
function fallbackTokenSymbol(address, chainType) {
|
|
2900
|
+
if (chainType?.toLowerCase() === "solana") {
|
|
2901
|
+
return "SPL";
|
|
2902
|
+
}
|
|
2903
|
+
return `TOKEN-${address.slice(0, 6)}`;
|
|
2904
|
+
}
|
|
2905
|
+
function normalizeRows(rows, chain, address, registry) {
|
|
2906
|
+
const chainKey = chain.networkIdentifier ?? String(chain.chainId ?? chain.id);
|
|
2907
|
+
const chainType = normalizeChainType(chain);
|
|
2908
|
+
const nativeAddress = getNativeTokenAddress(chainType);
|
|
2909
|
+
const map = /* @__PURE__ */ new Map();
|
|
2910
|
+
for (const item of rows) {
|
|
2911
|
+
const category = toStringOrUndefined(item.category)?.toLowerCase();
|
|
2912
|
+
const addressRaw = item.contract ?? item.token_address ?? item.address ?? item.addr;
|
|
2913
|
+
const tokenAddress = typeof addressRaw === "string" ? addressRaw.trim() : void 0;
|
|
2914
|
+
const symbol = toStringOrUndefined(item.symbol ?? item.sym);
|
|
2915
|
+
const name = toStringOrUndefined(item.name ?? item.token_name ?? item.token) ?? symbol;
|
|
2916
|
+
const decimals = toNumberOrUndefined(item.decimals ?? item.dec);
|
|
2917
|
+
const balance = String(item.balance ?? item.bal ?? "0");
|
|
2918
|
+
const explicitNative = Boolean(item.native ?? item.is_native);
|
|
2919
|
+
const nativeFlag = explicitNative || category === "native" || isZeroAddressLike(tokenAddress, chainType);
|
|
2920
|
+
if (nativeFlag) {
|
|
2921
|
+
const nativeRow = {
|
|
2922
|
+
chain_key: chainKey,
|
|
2923
|
+
category: "native",
|
|
2924
|
+
contract: nativeAddress,
|
|
2925
|
+
address: nativeAddress,
|
|
2926
|
+
symbol: symbol ?? chain.nativeCurrency?.symbol ?? "NATIVE",
|
|
2927
|
+
name: name ?? chain.nativeCurrency?.name ?? symbol,
|
|
2928
|
+
decimals: decimals ?? chain.nativeCurrency?.decimals ?? 18,
|
|
2929
|
+
balance
|
|
2930
|
+
};
|
|
2931
|
+
map.set(`${chainKey}:${nativeAddress}`, nativeRow);
|
|
2932
|
+
continue;
|
|
2933
|
+
}
|
|
2934
|
+
if (!tokenAddress || decimals === void 0) continue;
|
|
2935
|
+
const metadata = registry.findToken(chain.chainId, tokenAddress);
|
|
2936
|
+
const displaySymbol = symbol ?? metadata?.symbol ?? fallbackTokenSymbol(tokenAddress, chainType);
|
|
2937
|
+
const displayName = name ?? metadata?.name ?? displaySymbol;
|
|
2938
|
+
const normalizedAddress = metadata?.address ?? tokenAddress;
|
|
2939
|
+
map.set(`${chainKey}:${normalizedAddress}`, {
|
|
2940
|
+
chain_key: chainKey,
|
|
2941
|
+
category: category ?? (chainType === "solana" ? "spl" : "erc20"),
|
|
2942
|
+
contract: normalizedAddress,
|
|
2943
|
+
address: normalizedAddress,
|
|
2944
|
+
symbol: displaySymbol,
|
|
2945
|
+
name: displayName,
|
|
2946
|
+
decimals: metadata?.decimals ?? decimals,
|
|
2947
|
+
balance,
|
|
2948
|
+
logoURI: metadata?.logoURI,
|
|
2949
|
+
usdPrice: metadata?.usdPrice
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2952
|
+
if (!Array.from(map.values()).some((row) => row.category === "native")) {
|
|
2953
|
+
map.set(`${chainKey}:${nativeAddress}`, {
|
|
2954
|
+
chain_key: chainKey,
|
|
2955
|
+
category: "native",
|
|
2956
|
+
contract: nativeAddress,
|
|
2957
|
+
address: nativeAddress,
|
|
2958
|
+
symbol: chain.nativeCurrency?.symbol ?? "NATIVE",
|
|
2959
|
+
name: chain.nativeCurrency?.name ?? chain.nativeCurrency?.symbol,
|
|
2960
|
+
decimals: chain.nativeCurrency?.decimals ?? 18,
|
|
2961
|
+
balance: "0"
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
return Array.from(map.values()).sort((a, b) => {
|
|
2965
|
+
try {
|
|
2966
|
+
return Number(BigInt(b.balance) - BigInt(a.balance));
|
|
2967
|
+
} catch {
|
|
2968
|
+
return 0;
|
|
2969
|
+
}
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2972
|
+
async function getBalances(chainRef, address) {
|
|
1323
2973
|
const reg = await ensureRegistry();
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
const
|
|
1327
|
-
const
|
|
2974
|
+
const chain = reg.chain(chainRef);
|
|
2975
|
+
if (!chain) return [];
|
|
2976
|
+
const trimmedAddress = address.trim();
|
|
2977
|
+
const validation = validateAddressForChain(trimmedAddress, chain);
|
|
2978
|
+
if (!validation.isValid) return [];
|
|
2979
|
+
const chainKey = chain.networkIdentifier ?? String(chain.chainId ?? chain.id);
|
|
2980
|
+
const cacheKey = [
|
|
2981
|
+
chainKey,
|
|
2982
|
+
trimmedAddress,
|
|
2983
|
+
chain.nativeCurrency?.symbol ?? "",
|
|
2984
|
+
chain.nativeCurrency?.decimals ?? "",
|
|
2985
|
+
normalizeChainType(chain) ?? ""
|
|
2986
|
+
].join(":");
|
|
2987
|
+
const cached = balanceCache.get(cacheKey);
|
|
2988
|
+
if (cached) return cached;
|
|
2989
|
+
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
2990
|
+
const response = await fetch(url, {
|
|
1328
2991
|
method: "GET",
|
|
1329
2992
|
credentials: "omit",
|
|
1330
2993
|
headers: jsonHeaders()
|
|
1331
2994
|
});
|
|
1332
|
-
if (!
|
|
1333
|
-
const
|
|
1334
|
-
const rows = Array.isArray(
|
|
1335
|
-
|
|
2995
|
+
if (!response.ok) throw new Error(`balances: HTTP ${response.status}`);
|
|
2996
|
+
const json = await response.json();
|
|
2997
|
+
const rows = Array.isArray(json) ? json : json.data ?? [];
|
|
2998
|
+
const normalized = normalizeRows(rows, chain, trimmedAddress, reg);
|
|
2999
|
+
balanceCache.set(cacheKey, normalized);
|
|
3000
|
+
return normalized;
|
|
1336
3001
|
}
|
|
1337
3002
|
async function getBalancesByAddress(address) {
|
|
1338
3003
|
const url = `${apiBase()}/data/balances/${address}`;
|
|
@@ -1343,8 +3008,7 @@ async function getBalancesByAddress(address) {
|
|
|
1343
3008
|
});
|
|
1344
3009
|
if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
|
|
1345
3010
|
const j = await r.json();
|
|
1346
|
-
|
|
1347
|
-
return rows;
|
|
3011
|
+
return Array.isArray(j) ? j : j.results ?? [];
|
|
1348
3012
|
}
|
|
1349
3013
|
var _registry;
|
|
1350
3014
|
async function ensureRegistry() {
|
|
@@ -1356,71 +3020,100 @@ async function ensureRegistry() {
|
|
|
1356
3020
|
}
|
|
1357
3021
|
|
|
1358
3022
|
// src/core/tx.ts
|
|
1359
|
-
function isUserRejected(
|
|
1360
|
-
const code =
|
|
3023
|
+
function isUserRejected(e2) {
|
|
3024
|
+
const code = e2?.code ?? e2?.data?.code;
|
|
1361
3025
|
if (code === 4001) return true;
|
|
1362
|
-
const msg = String(
|
|
3026
|
+
const msg = String(e2?.message || e2)?.toLowerCase?.() || "";
|
|
1363
3027
|
return msg.includes("user rejected") || msg.includes("user denied");
|
|
1364
3028
|
}
|
|
1365
3029
|
async function sendRouteTransaction(b, fallbackChainId) {
|
|
1366
3030
|
const w = walletManager.wallet;
|
|
1367
3031
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
3032
|
+
const txReq = b.txReq;
|
|
3033
|
+
if (isEvmTxRequest(txReq)) {
|
|
3034
|
+
if (w.ecosystem !== "evm") {
|
|
3035
|
+
throw new Error("An EVM wallet is required for this route");
|
|
3036
|
+
}
|
|
3037
|
+
const to = txReq.to ?? txReq.target;
|
|
3038
|
+
const data = txReq.data;
|
|
3039
|
+
const value = txReq.value ? BigInt(txReq.value) : 0n;
|
|
3040
|
+
const target = Number(txReq.chainId ?? fallbackChainId);
|
|
3041
|
+
if (Number.isFinite(target)) {
|
|
3042
|
+
const current = await w.getChainId();
|
|
3043
|
+
if (current !== target) {
|
|
3044
|
+
try {
|
|
3045
|
+
await w.switchChain(target);
|
|
3046
|
+
} catch {
|
|
3047
|
+
}
|
|
1379
3048
|
}
|
|
1380
3049
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
3050
|
+
if (w.type === "eip1193") {
|
|
3051
|
+
const from = await w.getAddress();
|
|
3052
|
+
const hexValue = value ? `0x${value.toString(16)}` : "0x0";
|
|
3053
|
+
const params = {
|
|
3054
|
+
from,
|
|
3055
|
+
to,
|
|
3056
|
+
data,
|
|
3057
|
+
value: hexValue
|
|
3058
|
+
};
|
|
3059
|
+
if (Number.isFinite(target)) {
|
|
3060
|
+
params.chainId = `0x${target.toString(16)}`;
|
|
3061
|
+
}
|
|
3062
|
+
const hash = await w.request({
|
|
3063
|
+
method: "eth_sendTransaction",
|
|
3064
|
+
params: [params]
|
|
3065
|
+
});
|
|
3066
|
+
return hash;
|
|
3067
|
+
}
|
|
3068
|
+
const response = await w.sendTransaction({
|
|
1394
3069
|
to,
|
|
1395
3070
|
data,
|
|
1396
3071
|
value,
|
|
1397
3072
|
chainId: Number.isFinite(target) ? target : void 0
|
|
1398
3073
|
});
|
|
1399
|
-
return
|
|
3074
|
+
return response.hash;
|
|
3075
|
+
}
|
|
3076
|
+
if (isSerializedSolanaTxRequest(txReq)) {
|
|
3077
|
+
if (w.ecosystem !== "solana") {
|
|
3078
|
+
throw new Error("A Solana wallet is required for this route");
|
|
3079
|
+
}
|
|
3080
|
+
const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
|
|
3081
|
+
const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3082
|
+
const registry = new Registry2(apiBase2());
|
|
3083
|
+
await registry.ensureLoaded();
|
|
3084
|
+
const chain = registry.chain(
|
|
3085
|
+
String(fallbackChainId ?? txReq.chainId ?? "")
|
|
3086
|
+
);
|
|
3087
|
+
const rpcUrl = chain?.rpc ?? chain?.rpcList?.[0];
|
|
3088
|
+
return w.sendSerializedTransaction(txReq.data, rpcUrl);
|
|
1400
3089
|
}
|
|
3090
|
+
throw new Error("Invalid route transaction payload");
|
|
1401
3091
|
}
|
|
1402
3092
|
async function runTopUp(params) {
|
|
1403
3093
|
const w = walletManager.wallet;
|
|
1404
3094
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
1405
|
-
const { Registry: Registry2
|
|
3095
|
+
const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
|
|
1406
3096
|
const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
1407
3097
|
const reg = new Registry2(apiBase2());
|
|
1408
3098
|
await reg.ensureLoaded();
|
|
1409
3099
|
const fromAddress = await w.getAddress();
|
|
1410
|
-
const
|
|
1411
|
-
const originalChain =
|
|
1412
|
-
const fromChain = params.fromChain ??
|
|
3100
|
+
const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
|
|
3101
|
+
const originalChain = w.ecosystem === "evm" ? await w.getChainId() : void 0;
|
|
3102
|
+
const fromChain = params.fromChain ?? currentChainRef;
|
|
1413
3103
|
const { TrustwareConfigStore: TrustwareConfigStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
|
|
1414
3104
|
const cfg = TrustwareConfigStore2.get();
|
|
1415
3105
|
const toChain = params.toChain ?? String(cfg.routes.toChain);
|
|
1416
3106
|
const fromToken = reg.resolveToken(
|
|
1417
3107
|
fromChain,
|
|
1418
3108
|
params.fromToken ?? cfg.routes.fromToken ?? void 0
|
|
1419
|
-
) ??
|
|
3109
|
+
) ?? params.fromToken;
|
|
1420
3110
|
const toToken = reg.resolveToken(
|
|
1421
3111
|
toChain,
|
|
1422
3112
|
params.toToken ?? cfg.routes.toToken ?? void 0
|
|
1423
|
-
) ??
|
|
3113
|
+
) ?? params.toToken;
|
|
3114
|
+
if (!fromToken || !toToken) {
|
|
3115
|
+
throw new Error("Unable to resolve route tokens");
|
|
3116
|
+
}
|
|
1424
3117
|
try {
|
|
1425
3118
|
const build = await buildRoute({
|
|
1426
3119
|
fromChain,
|
|
@@ -1432,16 +3125,15 @@ async function runTopUp(params) {
|
|
|
1432
3125
|
toAddress: params.toAddress ?? cfg.routes.toAddress ?? cfg.routes.fromAddress ?? fromAddress,
|
|
1433
3126
|
slippage: cfg.routes.defaultSlippage
|
|
1434
3127
|
});
|
|
1435
|
-
const hash = await sendRouteTransaction(build,
|
|
3128
|
+
const hash = await sendRouteTransaction(build, fromChain);
|
|
1436
3129
|
await submitReceipt(build.intentId, hash);
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
throw e;
|
|
3130
|
+
return await pollStatus(build.intentId);
|
|
3131
|
+
} catch (e2) {
|
|
3132
|
+
if (isUserRejected(e2)) throw new Error("Transaction cancelled by user");
|
|
3133
|
+
throw e2;
|
|
1442
3134
|
} finally {
|
|
1443
3135
|
try {
|
|
1444
|
-
if (originalChain && originalChain !== Number(fromChain)) {
|
|
3136
|
+
if (w.ecosystem === "evm" && originalChain && originalChain !== Number(fromChain)) {
|
|
1445
3137
|
await w.switchChain(originalChain);
|
|
1446
3138
|
}
|
|
1447
3139
|
} catch {
|
|
@@ -1477,40 +3169,64 @@ function getSharedRegistry() {
|
|
|
1477
3169
|
}
|
|
1478
3170
|
|
|
1479
3171
|
// src/widget/helpers/chainHelpers.ts
|
|
1480
|
-
function
|
|
3172
|
+
function normalizeChainKey2(id) {
|
|
1481
3173
|
if (id === void 0 || id === null) return "";
|
|
1482
3174
|
return String(id).trim().toLowerCase();
|
|
1483
3175
|
}
|
|
1484
|
-
var
|
|
1485
|
-
var
|
|
1486
|
-
function
|
|
3176
|
+
var NATIVE_EVM2 = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
3177
|
+
var NATIVE_SOLANA2 = "So11111111111111111111111111111111111111111";
|
|
3178
|
+
function getNativeTokenAddress2(chainType) {
|
|
1487
3179
|
const normalized = chainType?.toLowerCase?.();
|
|
1488
|
-
return normalized === "solana" ?
|
|
3180
|
+
return normalized === "solana" ? NATIVE_SOLANA2 : NATIVE_EVM2;
|
|
1489
3181
|
}
|
|
1490
|
-
|
|
3182
|
+
function isSolanaNativeTokenAlias2(address) {
|
|
3183
|
+
if (!address) return false;
|
|
3184
|
+
const trimmed = address.trim();
|
|
3185
|
+
if (!trimmed) return false;
|
|
3186
|
+
return trimmed === NATIVE_SOLANA2 || trimmed.toLowerCase() === NATIVE_EVM2;
|
|
3187
|
+
}
|
|
3188
|
+
var CHAIN_TYPE_ALIASES2 = {
|
|
1491
3189
|
btc: "bitcoin",
|
|
1492
3190
|
bitcoin: "bitcoin",
|
|
1493
3191
|
sei: "cosmos",
|
|
1494
3192
|
"pacific-1": "cosmos"
|
|
1495
3193
|
};
|
|
1496
|
-
function
|
|
3194
|
+
function inferChainTypeFromValue2(normalized) {
|
|
3195
|
+
if (!normalized) return void 0;
|
|
3196
|
+
const aliased = CHAIN_TYPE_ALIASES2[normalized];
|
|
3197
|
+
if (aliased) return aliased;
|
|
3198
|
+
if (normalized === "evm" || normalized === "solana" || normalized === "cosmos" || normalized === "bitcoin") {
|
|
3199
|
+
return normalized;
|
|
3200
|
+
}
|
|
3201
|
+
if (/^eip155:\d+$/.test(normalized) || /^\d+$/.test(normalized)) {
|
|
3202
|
+
return "evm";
|
|
3203
|
+
}
|
|
3204
|
+
if (normalized.startsWith("solana:") || normalized.includes("solana")) {
|
|
3205
|
+
return "solana";
|
|
3206
|
+
}
|
|
3207
|
+
if (normalized.startsWith("cosmos:") || normalized.startsWith("sei:") || normalized === "sei-evm") {
|
|
3208
|
+
return "cosmos";
|
|
3209
|
+
}
|
|
3210
|
+
return void 0;
|
|
3211
|
+
}
|
|
3212
|
+
function normalizeChainType2(chain) {
|
|
1497
3213
|
if (!chain) return void 0;
|
|
1498
3214
|
const raw = typeof chain === "string" ? chain : chain.type ?? chain.chainType ?? chain.networkIdentifier ?? chain.chainId ?? chain.id ?? chain.networkName ?? chain.axelarChainName;
|
|
1499
3215
|
if (!raw) return void 0;
|
|
1500
3216
|
const normalized = String(raw).trim().toLowerCase();
|
|
1501
|
-
return
|
|
3217
|
+
return inferChainTypeFromValue2(normalized) ?? normalized;
|
|
1502
3218
|
}
|
|
1503
3219
|
function canonicalChainKeyForLink(chain) {
|
|
1504
3220
|
const seiKey = canonicalSeiChainKey(chain.chainId ?? chain.id);
|
|
1505
3221
|
if (seiKey) return seiKey;
|
|
1506
|
-
return
|
|
3222
|
+
return normalizeChainKey2(
|
|
1507
3223
|
chain.networkIdentifier ?? chain.axelarChainName ?? chain.id ?? chain.chainId ?? chain.networkName
|
|
1508
3224
|
);
|
|
1509
3225
|
}
|
|
1510
3226
|
var SEI_EVM_CHAIN_ID = "1329";
|
|
1511
3227
|
var SEI_COSMOS_CHAIN_ID = "pacific-1";
|
|
1512
3228
|
function canonicalSeiChainKey(chainId) {
|
|
1513
|
-
const normalized =
|
|
3229
|
+
const normalized = normalizeChainKey2(chainId);
|
|
1514
3230
|
if (!normalized) return null;
|
|
1515
3231
|
if (normalized === SEI_EVM_CHAIN_ID) return "sei-evm";
|
|
1516
3232
|
if (normalized === SEI_COSMOS_CHAIN_ID) return "sei";
|
|
@@ -1519,40 +3235,43 @@ function canonicalSeiChainKey(chainId) {
|
|
|
1519
3235
|
function isZeroAddrLike(a, chainType) {
|
|
1520
3236
|
if (!a) return true;
|
|
1521
3237
|
if (!chainType) return false;
|
|
1522
|
-
const s =
|
|
1523
|
-
return s ===
|
|
3238
|
+
const s = normalizeAddress2(a, chainType);
|
|
3239
|
+
return s === normalizeAddress2(getNativeTokenAddress2(chainType), chainType) || s === "0x0000000000000000000000000000000000000000";
|
|
1524
3240
|
}
|
|
1525
|
-
function
|
|
3241
|
+
function normalizeAddress2(address, chainType) {
|
|
1526
3242
|
if (chainType?.toLowerCase?.() === "solana") {
|
|
1527
3243
|
const trimmed = address.trim();
|
|
1528
|
-
|
|
3244
|
+
if (isSolanaNativeTokenAlias2(trimmed)) {
|
|
3245
|
+
return NATIVE_SOLANA2;
|
|
3246
|
+
}
|
|
3247
|
+
return trimmed;
|
|
1529
3248
|
}
|
|
1530
3249
|
return address.toLowerCase();
|
|
1531
3250
|
}
|
|
1532
3251
|
function isNativeTokenAddress(address, chainType) {
|
|
1533
3252
|
if (!address) return false;
|
|
1534
3253
|
if (!chainType) return false;
|
|
1535
|
-
return
|
|
3254
|
+
return normalizeAddress2(address, chainType) === normalizeAddress2(getNativeTokenAddress2(chainType), chainType);
|
|
1536
3255
|
}
|
|
1537
3256
|
function canonicalTokenAddressForChain(chain, address, chainTokens = []) {
|
|
1538
|
-
const chainType =
|
|
3257
|
+
const chainType = normalizeChainType2(chain);
|
|
1539
3258
|
const rawAddress = (address ?? "").trim();
|
|
1540
|
-
if (chainType === "solana") return rawAddress;
|
|
3259
|
+
if (chainType === "solana") return normalizeAddress2(rawAddress, "solana");
|
|
1541
3260
|
if (chainType === "cosmos") {
|
|
1542
|
-
const chainIdKey =
|
|
3261
|
+
const chainIdKey = normalizeChainKey2(chain.chainId ?? chain.id ?? "");
|
|
1543
3262
|
const nativeSymbol = chain.nativeCurrency?.symbol?.toUpperCase?.();
|
|
1544
3263
|
const nativeFromRegistry = chainTokens.find(
|
|
1545
|
-
(token) =>
|
|
3264
|
+
(token) => normalizeChainKey2(token.chainId) === chainIdKey && token.symbol?.toUpperCase?.() === nativeSymbol
|
|
1546
3265
|
);
|
|
1547
3266
|
const nativeDenom = (nativeFromRegistry?.address ?? "usei").toLowerCase();
|
|
1548
|
-
if (rawAddress.toLowerCase() ===
|
|
3267
|
+
if (rawAddress.toLowerCase() === NATIVE_EVM2) {
|
|
1549
3268
|
return nativeDenom;
|
|
1550
3269
|
}
|
|
1551
3270
|
return rawAddress.toLowerCase();
|
|
1552
3271
|
}
|
|
1553
3272
|
const lowerAddress = rawAddress.toLowerCase();
|
|
1554
3273
|
if (lowerAddress === "0x0000000000000000000000000000000000000000") {
|
|
1555
|
-
return
|
|
3274
|
+
return NATIVE_EVM2;
|
|
1556
3275
|
}
|
|
1557
3276
|
return lowerAddress;
|
|
1558
3277
|
}
|
|
@@ -1569,7 +3288,7 @@ var POPULAR_CHAIN_IDS = /* @__PURE__ */ new Set([
|
|
|
1569
3288
|
function filterSupportedChains(chains) {
|
|
1570
3289
|
const supportedChainTypes = /* @__PURE__ */ new Set(["evm", "solana", "cosmos", "bitcoin"]);
|
|
1571
3290
|
return chains.filter((chain) => {
|
|
1572
|
-
const chainType =
|
|
3291
|
+
const chainType = normalizeChainType2(chain);
|
|
1573
3292
|
if (!chainType) return false;
|
|
1574
3293
|
if (!supportedChainTypes.has(chainType)) {
|
|
1575
3294
|
return false;
|
|
@@ -1727,7 +3446,7 @@ function getChainPopularityRank(chain) {
|
|
|
1727
3446
|
chain.axelarChainName
|
|
1728
3447
|
];
|
|
1729
3448
|
for (const alias of aliases) {
|
|
1730
|
-
const key =
|
|
3449
|
+
const key = normalizeChainKey2(alias ?? null);
|
|
1731
3450
|
if (!key) continue;
|
|
1732
3451
|
const rank = popularityByKey[key];
|
|
1733
3452
|
if (typeof rank === "number") {
|
|
@@ -1780,7 +3499,7 @@ var POPULAR_TOKEN_CONTRACTS = /* @__PURE__ */ new Set([
|
|
|
1780
3499
|
function normalizeSymbol(symbol) {
|
|
1781
3500
|
return (symbol ?? "").trim().toUpperCase();
|
|
1782
3501
|
}
|
|
1783
|
-
function
|
|
3502
|
+
function normalizeAddress3(address) {
|
|
1784
3503
|
return (address ?? "").trim().toLowerCase();
|
|
1785
3504
|
}
|
|
1786
3505
|
function hasPositiveBalance(balance) {
|
|
@@ -1808,7 +3527,7 @@ function hasPositiveBalance(balance) {
|
|
|
1808
3527
|
}
|
|
1809
3528
|
function isPopularToken(token) {
|
|
1810
3529
|
const normalizedSymbol = normalizeSymbol(token.symbol);
|
|
1811
|
-
const normalizedAddress =
|
|
3530
|
+
const normalizedAddress = normalizeAddress3(token.address);
|
|
1812
3531
|
return POPULAR_TOKEN_SYMBOLS.has(normalizedSymbol) || POPULAR_TOKEN_CONTRACTS.has(normalizedAddress);
|
|
1813
3532
|
}
|
|
1814
3533
|
function compareText(a, b) {
|
|
@@ -2002,6 +3721,16 @@ var Trustware = {
|
|
|
2002
3721
|
getWallet() {
|
|
2003
3722
|
return walletManager.wallet;
|
|
2004
3723
|
},
|
|
3724
|
+
getIdentity() {
|
|
3725
|
+
return walletManager.identity;
|
|
3726
|
+
},
|
|
3727
|
+
resolveAddressForChain(chain) {
|
|
3728
|
+
return walletManager.resolveAddressForChain(chain);
|
|
3729
|
+
},
|
|
3730
|
+
addIdentityAddress(address) {
|
|
3731
|
+
walletManager.addIdentityAddress(address);
|
|
3732
|
+
return Trustware;
|
|
3733
|
+
},
|
|
2005
3734
|
/** Simple helpers */
|
|
2006
3735
|
async getAddress() {
|
|
2007
3736
|
const w = walletManager.wallet;
|
|
@@ -2010,6 +3739,7 @@ var Trustware = {
|
|
|
2010
3739
|
},
|
|
2011
3740
|
// ---- REST methods (re-export) ----
|
|
2012
3741
|
buildRoute,
|
|
3742
|
+
buildDepositAddress,
|
|
2013
3743
|
submitReceipt,
|
|
2014
3744
|
getStatus,
|
|
2015
3745
|
pollStatus,
|
|
@@ -2017,6 +3747,8 @@ var Trustware = {
|
|
|
2017
3747
|
getBalancesByAddress,
|
|
2018
3748
|
useChains,
|
|
2019
3749
|
useTokens,
|
|
3750
|
+
validateAddressForChain,
|
|
3751
|
+
validateRouteAddresses,
|
|
2020
3752
|
// ---- Tx helpers ----
|
|
2021
3753
|
sendRouteTransaction,
|
|
2022
3754
|
runTopUp
|
|
@@ -2595,7 +4327,7 @@ function useRouteBuilder({
|
|
|
2595
4327
|
const hasFromChainId = fromChainId !== void 0 && fromChainId !== null && String(fromChainId).trim() !== "";
|
|
2596
4328
|
const hasToChainId = toChainId !== void 0 && toChainId !== null && String(toChainId).trim() !== "";
|
|
2597
4329
|
useEffect5(() => {
|
|
2598
|
-
if (!fromChain || !
|
|
4330
|
+
if (!fromChain || !hasFromChainId || !hasToChainId || !fromToken || !toToken || !fromAmountWei || !fromAddress || !toAddress)
|
|
2599
4331
|
return;
|
|
2600
4332
|
abortRef.current?.abort();
|
|
2601
4333
|
if (!routeKey) {
|
|
@@ -2640,6 +4372,9 @@ function useRouteBuilder({
|
|
|
2640
4372
|
});
|
|
2641
4373
|
if (ac.signal.aborted) return;
|
|
2642
4374
|
const estimate = result?.route?.estimate;
|
|
4375
|
+
if (!result?.txReq?.data || !isEvmTxRequest(result.txReq) && !isSerializedSolanaTxRequest(result.txReq)) {
|
|
4376
|
+
throw new Error("Invalid route response");
|
|
4377
|
+
}
|
|
2643
4378
|
const fees = estimate?.fees;
|
|
2644
4379
|
let networkFeesUSD = null;
|
|
2645
4380
|
if (estimate?.fromAmountUsd && estimate?.toAmountMinUsd) {
|
|
@@ -3085,9 +4820,9 @@ function TrustwareProvider({
|
|
|
3085
4820
|
const revalidate = useCallback2(async () => {
|
|
3086
4821
|
try {
|
|
3087
4822
|
await initialize();
|
|
3088
|
-
} catch (
|
|
4823
|
+
} catch (e2) {
|
|
3089
4824
|
setStatus("error");
|
|
3090
|
-
setErrors(
|
|
4825
|
+
setErrors(e2 instanceof Error ? e2.message : String(e2));
|
|
3091
4826
|
}
|
|
3092
4827
|
}, [initialize]);
|
|
3093
4828
|
useEffect7(() => {
|
|
@@ -3095,16 +4830,16 @@ function TrustwareProvider({
|
|
|
3095
4830
|
const setStatusSafe = (s) => {
|
|
3096
4831
|
if (!cancelled) setStatus(s);
|
|
3097
4832
|
};
|
|
3098
|
-
const setErrorsSafe = (
|
|
3099
|
-
if (!cancelled) setErrors(
|
|
4833
|
+
const setErrorsSafe = (e2) => {
|
|
4834
|
+
if (!cancelled) setErrors(e2);
|
|
3100
4835
|
};
|
|
3101
4836
|
(async () => {
|
|
3102
4837
|
try {
|
|
3103
4838
|
await initialize(setStatusSafe, setErrorsSafe);
|
|
3104
|
-
} catch (
|
|
4839
|
+
} catch (e2) {
|
|
3105
4840
|
if (!cancelled) {
|
|
3106
4841
|
setStatus("error");
|
|
3107
|
-
setErrors(
|
|
4842
|
+
setErrors(e2 instanceof Error ? e2.message : String(e2));
|
|
3108
4843
|
}
|
|
3109
4844
|
}
|
|
3110
4845
|
})();
|
|
@@ -3469,7 +5204,7 @@ function DepositProvider({
|
|
|
3469
5204
|
const tokensByCanonicalKey = /* @__PURE__ */ new Map();
|
|
3470
5205
|
for (const token of tokens) {
|
|
3471
5206
|
const tokenChain = chains.find(
|
|
3472
|
-
(chain) =>
|
|
5207
|
+
(chain) => normalizeChainKey2(chain.chainId) === normalizeChainKey2(token.chainId)
|
|
3473
5208
|
);
|
|
3474
5209
|
if (!tokenChain) continue;
|
|
3475
5210
|
const canonicalAddress = canonicalTokenAddressForChain(
|
|
@@ -3477,12 +5212,12 @@ function DepositProvider({
|
|
|
3477
5212
|
token.address,
|
|
3478
5213
|
tokens
|
|
3479
5214
|
);
|
|
3480
|
-
const key = `${
|
|
5215
|
+
const key = `${normalizeChainKey2(token.chainId)}:${canonicalAddress}`;
|
|
3481
5216
|
tokensByCanonicalKey.set(key, token);
|
|
3482
5217
|
}
|
|
3483
5218
|
const updatedArr = flatenedTokenWithBalancesArr.flatMap((balanceRow) => {
|
|
3484
5219
|
const chain = chains.find(
|
|
3485
|
-
(c) =>
|
|
5220
|
+
(c) => normalizeChainKey2(c.chainId) === normalizeChainKey2(balanceRow.chain_id)
|
|
3486
5221
|
);
|
|
3487
5222
|
if (!chain) return [];
|
|
3488
5223
|
const balanceAddress = balanceRow.contract ?? balanceRow.address;
|
|
@@ -3491,17 +5226,17 @@ function DepositProvider({
|
|
|
3491
5226
|
balanceAddress,
|
|
3492
5227
|
tokens
|
|
3493
5228
|
);
|
|
3494
|
-
const canonicalKey = `${
|
|
5229
|
+
const canonicalKey = `${normalizeChainKey2(balanceRow.chain_id)}:${canonicalBalanceAddress}`;
|
|
3495
5230
|
let foundToken = tokensByCanonicalKey.get(canonicalKey);
|
|
3496
5231
|
if (!foundToken) {
|
|
3497
5232
|
const isNativeCategory = balanceRow.category === "native";
|
|
3498
5233
|
if (isNativeCategory) {
|
|
3499
5234
|
const nativeAddress = canonicalTokenAddressForChain(
|
|
3500
5235
|
chain,
|
|
3501
|
-
|
|
5236
|
+
getNativeTokenAddress2(chain.type),
|
|
3502
5237
|
tokens
|
|
3503
5238
|
);
|
|
3504
|
-
const nativeKey = `${
|
|
5239
|
+
const nativeKey = `${normalizeChainKey2(balanceRow.chain_id)}:${nativeAddress}`;
|
|
3505
5240
|
foundToken = tokensByCanonicalKey.get(nativeKey);
|
|
3506
5241
|
}
|
|
3507
5242
|
}
|
|
@@ -3517,11 +5252,9 @@ function DepositProvider({
|
|
|
3517
5252
|
iconUrl: foundToken.iconUrl ?? foundToken.logoURI ?? "",
|
|
3518
5253
|
chainId: balanceRow.chain_id,
|
|
3519
5254
|
usdPrice: foundToken.usdPrice,
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
tokens
|
|
3524
|
-
),
|
|
5255
|
+
// Preserve the registry/backend token identifier for downstream
|
|
5256
|
+
// route payloads; canonicalization is only for comparisons.
|
|
5257
|
+
address: foundToken.address,
|
|
3525
5258
|
chainIconURI: chain?.chainIconURI || "",
|
|
3526
5259
|
chainData: chain
|
|
3527
5260
|
}
|
|
@@ -3787,8 +5520,8 @@ function AmountSlider({
|
|
|
3787
5520
|
}, [max, min, value]);
|
|
3788
5521
|
const percentage = useMemo8(() => getPercentage(), [getPercentage]);
|
|
3789
5522
|
const handleChange = useCallback5(
|
|
3790
|
-
(
|
|
3791
|
-
const newValue = Math.min(Math.max(Number(
|
|
5523
|
+
(e2) => {
|
|
5524
|
+
const newValue = Math.min(Math.max(Number(e2.target.value), min), max);
|
|
3792
5525
|
onChange(newValue);
|
|
3793
5526
|
},
|
|
3794
5527
|
[onChange, min, max]
|
|
@@ -4124,7 +5857,7 @@ function AmountInputDisplay({
|
|
|
4124
5857
|
type: "text",
|
|
4125
5858
|
inputMode: "decimal",
|
|
4126
5859
|
value: amount,
|
|
4127
|
-
onChange: (
|
|
5860
|
+
onChange: (e2) => onAmountChange(e2.target.value),
|
|
4128
5861
|
onBlur: () => setIsEditing(false),
|
|
4129
5862
|
readOnly: isFixedAmount,
|
|
4130
5863
|
style: {
|
|
@@ -4283,9 +6016,9 @@ var Dialog = ({
|
|
|
4283
6016
|
const firstButtonRef = useRef5(null);
|
|
4284
6017
|
const lastButtonRef = useRef5(null);
|
|
4285
6018
|
useEffect11(() => {
|
|
4286
|
-
const handleEscape = (
|
|
4287
|
-
if (
|
|
4288
|
-
|
|
6019
|
+
const handleEscape = (e2) => {
|
|
6020
|
+
if (e2.key === "Escape" && open) {
|
|
6021
|
+
e2.preventDefault();
|
|
4289
6022
|
onCancel();
|
|
4290
6023
|
}
|
|
4291
6024
|
};
|
|
@@ -4297,17 +6030,17 @@ var Dialog = ({
|
|
|
4297
6030
|
};
|
|
4298
6031
|
}, [open, onCancel]);
|
|
4299
6032
|
useEffect11(() => {
|
|
4300
|
-
const handleTabKey = (
|
|
6033
|
+
const handleTabKey = (e2) => {
|
|
4301
6034
|
if (!open) return;
|
|
4302
|
-
if (
|
|
4303
|
-
if (
|
|
6035
|
+
if (e2.key === "Tab") {
|
|
6036
|
+
if (e2.shiftKey) {
|
|
4304
6037
|
if (document.activeElement === firstButtonRef.current) {
|
|
4305
|
-
|
|
6038
|
+
e2.preventDefault();
|
|
4306
6039
|
lastButtonRef.current?.focus();
|
|
4307
6040
|
}
|
|
4308
6041
|
} else {
|
|
4309
6042
|
if (document.activeElement === lastButtonRef.current) {
|
|
4310
|
-
|
|
6043
|
+
e2.preventDefault();
|
|
4311
6044
|
firstButtonRef.current?.focus();
|
|
4312
6045
|
}
|
|
4313
6046
|
}
|
|
@@ -4333,50 +6066,50 @@ var Dialog = ({
|
|
|
4333
6066
|
};
|
|
4334
6067
|
}
|
|
4335
6068
|
}, [open]);
|
|
4336
|
-
const handleOverlayClick = (
|
|
4337
|
-
if (
|
|
6069
|
+
const handleOverlayClick = (e2) => {
|
|
6070
|
+
if (e2.target === e2.currentTarget) {
|
|
4338
6071
|
onCancel();
|
|
4339
6072
|
}
|
|
4340
6073
|
};
|
|
4341
|
-
const handleCancelKeyDown = (
|
|
4342
|
-
if (
|
|
4343
|
-
|
|
6074
|
+
const handleCancelKeyDown = (e2) => {
|
|
6075
|
+
if (e2.key === "Enter" && !e2.shiftKey) {
|
|
6076
|
+
e2.preventDefault();
|
|
4344
6077
|
onCancel();
|
|
4345
6078
|
}
|
|
4346
6079
|
};
|
|
4347
|
-
const handleConfirmKeyDown = (
|
|
4348
|
-
if (
|
|
4349
|
-
|
|
6080
|
+
const handleConfirmKeyDown = (e2) => {
|
|
6081
|
+
if (e2.key === "Enter" && !e2.shiftKey) {
|
|
6082
|
+
e2.preventDefault();
|
|
4350
6083
|
onConfirm();
|
|
4351
6084
|
}
|
|
4352
6085
|
};
|
|
4353
|
-
const handleCancelMouseEnter = (
|
|
4354
|
-
|
|
6086
|
+
const handleCancelMouseEnter = (e2) => {
|
|
6087
|
+
e2.currentTarget.style.backgroundColor = "var(--cancel-hover, #e5e7eb)";
|
|
4355
6088
|
};
|
|
4356
|
-
const handleCancelMouseLeave = (
|
|
4357
|
-
|
|
6089
|
+
const handleCancelMouseLeave = (e2) => {
|
|
6090
|
+
e2.currentTarget.style.backgroundColor = "var(--cancel-bg, #f3f4f6)";
|
|
4358
6091
|
};
|
|
4359
|
-
const handleConfirmMouseEnter = (
|
|
4360
|
-
|
|
6092
|
+
const handleConfirmMouseEnter = (e2) => {
|
|
6093
|
+
e2.currentTarget.style.backgroundColor = "var(--confirm-hover, #dc2626)";
|
|
4361
6094
|
};
|
|
4362
|
-
const handleConfirmMouseLeave = (
|
|
4363
|
-
|
|
6095
|
+
const handleConfirmMouseLeave = (e2) => {
|
|
6096
|
+
e2.currentTarget.style.backgroundColor = "var(--confirm-bg, #ef4444)";
|
|
4364
6097
|
};
|
|
4365
|
-
const handleCancelFocus = (
|
|
4366
|
-
|
|
4367
|
-
|
|
6098
|
+
const handleCancelFocus = (e2) => {
|
|
6099
|
+
e2.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.5)";
|
|
6100
|
+
e2.currentTarget.style.borderColor = "#3b82f6";
|
|
4368
6101
|
};
|
|
4369
|
-
const handleCancelBlur = (
|
|
4370
|
-
|
|
4371
|
-
|
|
6102
|
+
const handleCancelBlur = (e2) => {
|
|
6103
|
+
e2.currentTarget.style.boxShadow = "";
|
|
6104
|
+
e2.currentTarget.style.borderColor = "var(--cancel-border, #d1d5db)";
|
|
4372
6105
|
};
|
|
4373
|
-
const handleConfirmFocus = (
|
|
4374
|
-
|
|
4375
|
-
|
|
6106
|
+
const handleConfirmFocus = (e2) => {
|
|
6107
|
+
e2.currentTarget.style.boxShadow = "0 0 0 3px rgba(239, 68, 68, 0.5)";
|
|
6108
|
+
e2.currentTarget.style.borderColor = "#ef4444";
|
|
4376
6109
|
};
|
|
4377
|
-
const handleConfirmBlur = (
|
|
4378
|
-
|
|
4379
|
-
|
|
6110
|
+
const handleConfirmBlur = (e2) => {
|
|
6111
|
+
e2.currentTarget.style.boxShadow = "";
|
|
6112
|
+
e2.currentTarget.style.borderColor = "transparent";
|
|
4380
6113
|
};
|
|
4381
6114
|
if (!open) return null;
|
|
4382
6115
|
return /* @__PURE__ */ jsx7(Fragment, { children: /* @__PURE__ */ jsx7(
|
|
@@ -4627,19 +6360,19 @@ function SwipeToConfirmTokens({
|
|
|
4627
6360
|
longPressAnimationRef.current = requestAnimationFrame(animateProgress);
|
|
4628
6361
|
}, [disabled, isComplete, isDragging, triggerConfirmation, cancelLongPress]);
|
|
4629
6362
|
const handleKeyDown = useCallback6(
|
|
4630
|
-
(
|
|
6363
|
+
(e2) => {
|
|
4631
6364
|
if (disabled || isComplete) return;
|
|
4632
|
-
if (
|
|
4633
|
-
|
|
6365
|
+
if (e2.key === "Enter" || e2.key === " ") {
|
|
6366
|
+
e2.preventDefault();
|
|
4634
6367
|
startLongPress();
|
|
4635
6368
|
}
|
|
4636
6369
|
},
|
|
4637
6370
|
[disabled, isComplete, startLongPress]
|
|
4638
6371
|
);
|
|
4639
6372
|
const handleKeyUp = useCallback6(
|
|
4640
|
-
(
|
|
4641
|
-
if (
|
|
4642
|
-
|
|
6373
|
+
(e2) => {
|
|
6374
|
+
if (e2.key === "Enter" || e2.key === " ") {
|
|
6375
|
+
e2.preventDefault();
|
|
4643
6376
|
cancelLongPress();
|
|
4644
6377
|
}
|
|
4645
6378
|
},
|
|
@@ -4652,17 +6385,17 @@ function SwipeToConfirmTokens({
|
|
|
4652
6385
|
cancelAnimationFrame(longPressAnimationRef.current);
|
|
4653
6386
|
};
|
|
4654
6387
|
}, []);
|
|
4655
|
-
const handleMouseDown = (
|
|
4656
|
-
|
|
6388
|
+
const handleMouseDown = (e2) => {
|
|
6389
|
+
e2.preventDefault();
|
|
4657
6390
|
handleDragStart();
|
|
4658
6391
|
};
|
|
4659
6392
|
const handleMouseMove = useCallback6(
|
|
4660
|
-
(
|
|
6393
|
+
(e2) => handleDragMove(e2.clientX),
|
|
4661
6394
|
[handleDragMove]
|
|
4662
6395
|
);
|
|
4663
6396
|
const handleMouseUp = useCallback6(() => handleDragEnd(), [handleDragEnd]);
|
|
4664
6397
|
const handleTouchStart = () => handleDragStart();
|
|
4665
|
-
const handleTouchMove = (
|
|
6398
|
+
const handleTouchMove = (e2) => handleDragMove(e2.touches[0].clientX);
|
|
4666
6399
|
const handleTouchEnd = () => handleDragEnd();
|
|
4667
6400
|
useEffect12(() => {
|
|
4668
6401
|
if (isDragging) {
|
|
@@ -5419,7 +7152,13 @@ function TokenSwipePill({
|
|
|
5419
7152
|
const startXRef = useRef7(0);
|
|
5420
7153
|
const containerRef = useRef7(null);
|
|
5421
7154
|
const currentIndex = tokens.findIndex(
|
|
5422
|
-
(t) =>
|
|
7155
|
+
(t) => normalizeAddress2(
|
|
7156
|
+
t.address,
|
|
7157
|
+
t.chainData?.type ?? t.chainData?.chainType
|
|
7158
|
+
) === normalizeAddress2(
|
|
7159
|
+
selectedToken.address,
|
|
7160
|
+
selectedToken.chainData?.type ?? selectedToken.chainData?.chainType
|
|
7161
|
+
) && t.symbol === selectedToken.symbol
|
|
5423
7162
|
);
|
|
5424
7163
|
const swipeThreshold = 30;
|
|
5425
7164
|
const hasMultipleTokens = tokens.length > 1;
|
|
@@ -5457,27 +7196,27 @@ function TokenSwipePill({
|
|
|
5457
7196
|
}
|
|
5458
7197
|
setDragOffset(0);
|
|
5459
7198
|
}, [isDragging, dragOffset, currentIndex, tokens, onTokenChange]);
|
|
5460
|
-
const handleMouseDown = (
|
|
7199
|
+
const handleMouseDown = (e2) => {
|
|
5461
7200
|
if (!hasMultipleTokens) return;
|
|
5462
|
-
|
|
5463
|
-
handleDragStart(
|
|
7201
|
+
e2.preventDefault();
|
|
7202
|
+
handleDragStart(e2.clientX);
|
|
5464
7203
|
};
|
|
5465
7204
|
const handleMouseMove = useCallback8(
|
|
5466
|
-
(
|
|
5467
|
-
handleDragMove(
|
|
7205
|
+
(e2) => {
|
|
7206
|
+
handleDragMove(e2.clientX);
|
|
5468
7207
|
},
|
|
5469
7208
|
[handleDragMove]
|
|
5470
7209
|
);
|
|
5471
7210
|
const handleMouseUp = useCallback8(() => {
|
|
5472
7211
|
handleDragEnd();
|
|
5473
7212
|
}, [handleDragEnd]);
|
|
5474
|
-
const handleTouchStart = (
|
|
7213
|
+
const handleTouchStart = (e2) => {
|
|
5475
7214
|
if (!hasMultipleTokens) return;
|
|
5476
|
-
handleDragStart(
|
|
7215
|
+
handleDragStart(e2.touches[0].clientX);
|
|
5477
7216
|
};
|
|
5478
|
-
const handleTouchMove = (
|
|
7217
|
+
const handleTouchMove = (e2) => {
|
|
5479
7218
|
if (!hasMultipleTokens) return;
|
|
5480
|
-
handleDragMove(
|
|
7219
|
+
handleDragMove(e2.touches[0].clientX);
|
|
5481
7220
|
};
|
|
5482
7221
|
const handleTouchEnd = () => {
|
|
5483
7222
|
handleDragEnd();
|
|
@@ -5724,8 +7463,8 @@ function TokenSwipePill({
|
|
|
5724
7463
|
return tokens.map((token, index) => /* @__PURE__ */ jsx11(
|
|
5725
7464
|
"div",
|
|
5726
7465
|
{
|
|
5727
|
-
onClick: (
|
|
5728
|
-
|
|
7466
|
+
onClick: (e2) => {
|
|
7467
|
+
e2.stopPropagation();
|
|
5729
7468
|
onTokenChange(token);
|
|
5730
7469
|
},
|
|
5731
7470
|
style: {
|
|
@@ -5779,8 +7518,8 @@ function TokenSwipePill({
|
|
|
5779
7518
|
/* @__PURE__ */ jsx11(
|
|
5780
7519
|
"div",
|
|
5781
7520
|
{
|
|
5782
|
-
onClick: (
|
|
5783
|
-
|
|
7521
|
+
onClick: (e2) => {
|
|
7522
|
+
e2.stopPropagation();
|
|
5784
7523
|
onTokenChange(token);
|
|
5785
7524
|
},
|
|
5786
7525
|
style: {
|
|
@@ -5883,8 +7622,8 @@ function TokenSwipePill({
|
|
|
5883
7622
|
cursor: "pointer",
|
|
5884
7623
|
backgroundColor: "transparent"
|
|
5885
7624
|
},
|
|
5886
|
-
onClick: (
|
|
5887
|
-
|
|
7625
|
+
onClick: (e2) => {
|
|
7626
|
+
e2.stopPropagation();
|
|
5888
7627
|
onExpandClick?.();
|
|
5889
7628
|
},
|
|
5890
7629
|
children: [
|
|
@@ -6166,8 +7905,8 @@ function WidgetContainer({
|
|
|
6166
7905
|
if (theme === "system") {
|
|
6167
7906
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
6168
7907
|
setResolvedTheme(mediaQuery.matches ? "dark" : "light");
|
|
6169
|
-
const handler = (
|
|
6170
|
-
setResolvedTheme(
|
|
7908
|
+
const handler = (e2) => {
|
|
7909
|
+
setResolvedTheme(e2.matches ? "dark" : "light");
|
|
6171
7910
|
};
|
|
6172
7911
|
mediaQuery.addEventListener("change", handler);
|
|
6173
7912
|
return () => mediaQuery.removeEventListener("change", handler);
|
|
@@ -6451,7 +8190,6 @@ function Home({ style: _style }) {
|
|
|
6451
8190
|
amount,
|
|
6452
8191
|
setAmount,
|
|
6453
8192
|
setCurrentStep,
|
|
6454
|
-
walletAddress,
|
|
6455
8193
|
connectWallet,
|
|
6456
8194
|
amountInputMode,
|
|
6457
8195
|
setAmountInputMode,
|
|
@@ -6511,10 +8249,6 @@ function Home({ style: _style }) {
|
|
|
6511
8249
|
})();
|
|
6512
8250
|
const handleWalletSelect = async (wallet) => {
|
|
6513
8251
|
setIsCryptoDropdownOpen(false);
|
|
6514
|
-
if (walletAddress) {
|
|
6515
|
-
setCurrentStep("crypto-pay");
|
|
6516
|
-
return;
|
|
6517
|
-
}
|
|
6518
8252
|
try {
|
|
6519
8253
|
await connectWallet(wallet);
|
|
6520
8254
|
setCurrentStep("crypto-pay");
|
|
@@ -7513,6 +9247,7 @@ function SelectToken({ style }) {
|
|
|
7513
9247
|
const handleChainSelect = (chain) => {
|
|
7514
9248
|
const chainId = Number(chain.chainId ?? chain.id);
|
|
7515
9249
|
setSelectedChain({
|
|
9250
|
+
...chain,
|
|
7516
9251
|
chainId,
|
|
7517
9252
|
name: resolveChainLabel(chain),
|
|
7518
9253
|
shortName: chain.nativeCurrency?.symbol ?? resolveChainLabel(chain).slice(0, 3).toUpperCase(),
|
|
@@ -7528,8 +9263,9 @@ function SelectToken({ style }) {
|
|
|
7528
9263
|
selectedChain?.chainId,
|
|
7529
9264
|
walletAddress
|
|
7530
9265
|
);
|
|
9266
|
+
const chainType = normalizeChainType2(selectedChain);
|
|
7531
9267
|
const match = balance.find(
|
|
7532
|
-
(b) => b.contract
|
|
9268
|
+
(b) => normalizeAddress2(b.contract ?? b.address ?? "", chainType) === normalizeAddress2(token.address, chainType)
|
|
7533
9269
|
);
|
|
7534
9270
|
const tokenWithBalance = {
|
|
7535
9271
|
...token,
|
|
@@ -8102,7 +9838,7 @@ function SelectToken({ style }) {
|
|
|
8102
9838
|
type: "text",
|
|
8103
9839
|
placeholder: "Search tokens...",
|
|
8104
9840
|
value: searchQuery,
|
|
8105
|
-
onChange: (
|
|
9841
|
+
onChange: (e2) => setSearchQuery(e2.target.value),
|
|
8106
9842
|
style: {
|
|
8107
9843
|
width: "100%",
|
|
8108
9844
|
paddingLeft: spacing[8],
|
|
@@ -8695,8 +10431,8 @@ function SelectToken({ style }) {
|
|
|
8695
10431
|
objectFit: "cover",
|
|
8696
10432
|
flexShrink: 0
|
|
8697
10433
|
},
|
|
8698
|
-
onError: (
|
|
8699
|
-
const target =
|
|
10434
|
+
onError: (e2) => {
|
|
10435
|
+
const target = e2.target;
|
|
8700
10436
|
target.style.display = "none";
|
|
8701
10437
|
if (target.nextElementSibling) {
|
|
8702
10438
|
target.nextElementSibling.style.display = "flex";
|
|
@@ -9112,18 +10848,18 @@ function CryptoPay({ style }) {
|
|
|
9112
10848
|
const amountWei = amountValidationError ? 0n : amountComputation.fromAmountWei ?? 0n;
|
|
9113
10849
|
const routeConfig = useMemo12(() => {
|
|
9114
10850
|
const toChainId = config.routes.toChain;
|
|
9115
|
-
const toChainKey =
|
|
10851
|
+
const toChainKey = normalizeChainKey2(toChainId);
|
|
9116
10852
|
const toChain = toChainKey ? chains.find(
|
|
9117
|
-
(chain) =>
|
|
10853
|
+
(chain) => normalizeChainKey2(chain.chainId ?? chain.id) === toChainKey
|
|
9118
10854
|
) ?? null : null;
|
|
9119
10855
|
const object = {
|
|
9120
10856
|
fromChain: selectedChain?.chainId ?? selectedChain?.id ?? "",
|
|
9121
10857
|
fromChainId: selectedChain?.chainId ?? selectedChain?.id,
|
|
9122
|
-
toChain,
|
|
10858
|
+
toChain: toChain ?? toChainId,
|
|
9123
10859
|
toChainId,
|
|
9124
10860
|
toToken: config.routes.toToken,
|
|
9125
10861
|
toAddress: config.routes.toAddress || walletAddress || void 0,
|
|
9126
|
-
fromToken: selectedToken?.address ??
|
|
10862
|
+
fromToken: selectedToken?.address ?? getNativeTokenAddress2(selectedChain?.type ?? selectedChain?.chainType),
|
|
9127
10863
|
fromAmountWei: amountWei ?? 0n,
|
|
9128
10864
|
fromAmountUsd: amountComputation.usdAmount || void 0,
|
|
9129
10865
|
fromAddress: walletAddress || void 0,
|
|
@@ -9178,7 +10914,7 @@ function CryptoPay({ style }) {
|
|
|
9178
10914
|
selectedToken,
|
|
9179
10915
|
walletAddress
|
|
9180
10916
|
]);
|
|
9181
|
-
const routeError = routeBuilderError
|
|
10917
|
+
const routeError = routeBuilderError ?? null;
|
|
9182
10918
|
const actionErrorMessage = routePrerequisiteError || routeError || null;
|
|
9183
10919
|
const { emitError } = useTrustware();
|
|
9184
10920
|
useEffect17(() => {
|
|
@@ -9243,7 +10979,7 @@ function CryptoPay({ style }) {
|
|
|
9243
10979
|
const address = selectedToken?.address;
|
|
9244
10980
|
return isNativeTokenAddress(address, chainType) || isZeroAddrLike(address, chainType) || normalizeTokenAddressForCompare(selectedChain, address) === normalizeTokenAddressForCompare(
|
|
9245
10981
|
selectedChain,
|
|
9246
|
-
|
|
10982
|
+
getNativeTokenAddress2(chainType)
|
|
9247
10983
|
);
|
|
9248
10984
|
}, [chainType, selectedChain, selectedToken?.address]);
|
|
9249
10985
|
const spender = useMemo12(() => {
|
|
@@ -9290,7 +11026,7 @@ function CryptoPay({ style }) {
|
|
|
9290
11026
|
return;
|
|
9291
11027
|
}
|
|
9292
11028
|
const wallet = Trustware.getWallet();
|
|
9293
|
-
if (!wallet) {
|
|
11029
|
+
if (!wallet || wallet.ecosystem !== "evm") {
|
|
9294
11030
|
return;
|
|
9295
11031
|
}
|
|
9296
11032
|
setIsApproving(true);
|
|
@@ -9509,8 +11245,12 @@ function CryptoPay({ style }) {
|
|
|
9509
11245
|
await handleConfirm();
|
|
9510
11246
|
}, [handleApproveExact, handleConfirm, needsApproval]);
|
|
9511
11247
|
const orderedTokens = useMemo12(() => {
|
|
11248
|
+
const selectedTokenChainType = selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType;
|
|
9512
11249
|
const index = yourWalletTokens.findIndex(
|
|
9513
|
-
(t) =>
|
|
11250
|
+
(t) => normalizeAddress2(
|
|
11251
|
+
t.address,
|
|
11252
|
+
t.chainData?.type ?? t.chainData?.chainType
|
|
11253
|
+
) === normalizeAddress2(selectedToken?.address ?? "", selectedTokenChainType)
|
|
9514
11254
|
);
|
|
9515
11255
|
let _tok = [];
|
|
9516
11256
|
if (index === -1) {
|
|
@@ -9570,7 +11310,10 @@ function CryptoPay({ style }) {
|
|
|
9570
11310
|
const isWalletConnected = walletStatus === "connected";
|
|
9571
11311
|
const canSwipe = parsedAmount > 0 && selectedToken && isWalletConnected && !isLoadingRoute && !isSubmitting && !!routeResult && !actionErrorMessage && !isApproving && !isReadingAllowance;
|
|
9572
11312
|
const swipeResetKey = useMemo12(() => {
|
|
9573
|
-
const tokenAddress = selectedToken
|
|
11313
|
+
const tokenAddress = selectedToken ? normalizeAddress2(
|
|
11314
|
+
selectedToken.address,
|
|
11315
|
+
selectedToken?.chainData?.type ?? selectedToken?.chainData?.chainType
|
|
11316
|
+
) : "no-token";
|
|
9574
11317
|
const chainId = selectedToken?.chainData?.chainId ?? selectedChain?.chainId ?? "no-chain";
|
|
9575
11318
|
return [
|
|
9576
11319
|
tokenAddress,
|
|
@@ -11922,6 +13665,7 @@ export {
|
|
|
11922
13665
|
DEFAULT_RETRY_CONFIG,
|
|
11923
13666
|
DEFAULT_SLIPPAGE2 as DEFAULT_SLIPPAGE,
|
|
11924
13667
|
DEFAULT_THEME2 as DEFAULT_THEME,
|
|
13668
|
+
IdentityStore,
|
|
11925
13669
|
RateLimitError,
|
|
11926
13670
|
SDK_NAME,
|
|
11927
13671
|
SDK_VERSION,
|
|
@@ -11930,12 +13674,22 @@ export {
|
|
|
11930
13674
|
TrustwareProvider,
|
|
11931
13675
|
TrustwareWidgetV2 as TrustwareWidget,
|
|
11932
13676
|
WALLETCONNECT_PROJECT_ID,
|
|
13677
|
+
buildWalletIdentityAddress,
|
|
11933
13678
|
connectDetectedWallet,
|
|
13679
|
+
createWalletIdentity,
|
|
13680
|
+
resolveWalletAddressForChain,
|
|
11934
13681
|
toWalletInterfaceFromDetected,
|
|
13682
|
+
upsertWalletIdentityAddress,
|
|
11935
13683
|
useEIP1193,
|
|
11936
13684
|
useTrustware,
|
|
11937
13685
|
useWagmi,
|
|
11938
13686
|
useWalletDetection,
|
|
11939
|
-
useWireDetectionIntoManager
|
|
13687
|
+
useWireDetectionIntoManager,
|
|
13688
|
+
validateAddressForChain,
|
|
13689
|
+
validateBtcAddress,
|
|
13690
|
+
validateEvmAddress,
|
|
13691
|
+
validateRouteAddresses,
|
|
13692
|
+
validateSeiAddress,
|
|
13693
|
+
validateSolanaAddress
|
|
11940
13694
|
};
|
|
11941
13695
|
//# sourceMappingURL=index.mjs.map
|