@talken/talkenkit 2.8.5 → 2.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{abcWallet-EOHU5AIB.js → abcWallet-WTHSP3A6.js} +22 -25
- package/dist/{chunk-WGSS57V6.js → chunk-S3KOGN7P.js} +2540 -715
- package/dist/gasless/api/ChainConfigApi.d.ts +2 -2
- package/dist/gasless/index.d.ts +1 -1
- package/dist/gasless/services/GaslessTransferService.d.ts +4 -3
- package/dist/gasless/signer/AbcWaasSigner.d.ts +9 -0
- package/dist/gasless/signer/GaslessSigner.d.ts +10 -0
- package/dist/gasless/signer/WagmiSigner.d.ts +40 -0
- package/dist/gasless/signer/index.d.ts +1 -1
- package/dist/gasless/utils/delegationGuard.d.ts +11 -11
- package/dist/gasless/utils/revokeDelegation.d.ts +22 -23
- package/dist/hooks/useMultiChainBalances.d.ts +2 -0
- package/dist/index.css +5 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1279 -584
- package/dist/services/AbcAuthService.d.ts +12 -1
- package/dist/solana/clusterIdentity.d.ts +5 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.d.ts +0 -1
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.d.ts +11 -0
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.js +5 -2
- package/dist/wallets/walletConnectors/abcWallet/StorageService.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.d.ts +2 -0
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +7 -5
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +10 -9
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +23 -21
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +12 -11
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +26 -24
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +183 -62
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +10 -9
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +24 -22
- package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcXrplProvider.js +10 -9
- package/dist/wallets/walletConnectors/abcWallet/api/AccessKeySessionBinding.d.ts +10 -0
- package/dist/wallets/walletConnectors/abcWallet/api/AccessKeySessionBinding.js +13 -0
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +5 -2
- package/dist/wallets/walletConnectors/abcWallet/api/GasApi.js +5 -1
- package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.js +5 -1
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +34 -12
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +19 -16
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.d.ts +6 -0
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.js +10 -1
- package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +5 -2
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +13 -3
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +26 -23
- package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.d.ts +20 -10
- package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/modules/bitcoin.js +11 -9
- package/dist/wallets/walletConnectors/abcWallet/api/modules/evm.d.ts +1 -1
- package/dist/wallets/walletConnectors/abcWallet/api/modules/evm.js +10 -8
- package/dist/wallets/walletConnectors/abcWallet/api/modules/executeBodies.js +4 -3
- package/dist/wallets/walletConnectors/abcWallet/api/modules/signBodies.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/signingRefresh.js +6 -5
- package/dist/wallets/walletConnectors/abcWallet/api/modules/solana.js +6 -5
- package/dist/wallets/walletConnectors/abcWallet/api/modules/tron.js +10 -8
- package/dist/wallets/walletConnectors/abcWallet/api/modules/wallet.d.ts +2 -1
- package/dist/wallets/walletConnectors/abcWallet/api/modules/wallet.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/walletscan.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/modules/xrp.js +10 -8
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +18 -6
- package/dist/wallets/walletConnectors/abcWallet/constants.js +13 -3
- package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/index.js +40 -38
- package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +11 -3
- package/dist/wallets/walletConnectors/abcWallet/types/auth.types.d.ts +75 -0
- package/dist/wallets/walletConnectors/abcWallet/types/error.types.d.ts +2 -0
- package/dist/wallets/walletConnectors/abcWallet/types/error.types.js +5 -3
- package/dist/wallets/walletConnectors/abcWallet/types.js +5 -3
- package/dist/wallets/walletConnectors/abcWallet/utils.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +6 -5
- package/dist/wallets/walletConnectors/chunk-2YCHXOLC.js +53 -0
- package/dist/wallets/walletConnectors/{chunk-6MZWQBNQ.js → chunk-3RUQ4ARU.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-MNGSJBPX.js → chunk-3XZJNLAA.js} +128 -77
- package/dist/wallets/walletConnectors/chunk-4UMY2AY7.js +414 -0
- package/dist/wallets/walletConnectors/chunk-5GTFKQGQ.js +739 -0
- package/dist/wallets/walletConnectors/{chunk-XGQUYXTL.js → chunk-5KPLYJOO.js} +12 -407
- package/dist/wallets/walletConnectors/{chunk-EGLT3GPM.js → chunk-5V5TLGH6.js} +58 -7
- package/dist/wallets/walletConnectors/{chunk-SUPFF4EQ.js → chunk-5ZTGAJ4K.js} +538 -191
- package/dist/wallets/walletConnectors/{chunk-PL56SINL.js → chunk-6GE2YBW5.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-M4SNNQU2.js → chunk-AROBVCG2.js} +29 -6
- package/dist/wallets/walletConnectors/{chunk-OTLZVWY7.js → chunk-BAKRM7LQ.js} +3 -1
- package/dist/wallets/walletConnectors/{chunk-6X2XITQP.js → chunk-BGDDDPVU.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-365TL36N.js → chunk-C3MTWYLE.js} +106 -53
- package/dist/wallets/walletConnectors/{chunk-UHVJ6AF6.js → chunk-CBXCYWLB.js} +6 -5
- package/dist/wallets/walletConnectors/{chunk-5SRSGEZR.js → chunk-DT2L5ADS.js} +35 -10
- package/dist/wallets/walletConnectors/{chunk-DKMR2ML5.js → chunk-DUEQONAP.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-ZBI7MSWF.js → chunk-EJB7HH6N.js} +7 -5
- package/dist/wallets/walletConnectors/{chunk-OTLPTGHO.js → chunk-EMFKD777.js} +4 -2
- package/dist/wallets/walletConnectors/{chunk-743DKBGG.js → chunk-F2TFFXON.js} +72 -20
- package/dist/wallets/walletConnectors/chunk-GM6AIRNT.js +71 -0
- package/dist/wallets/walletConnectors/chunk-H63QJV3U.js +84 -0
- package/dist/wallets/walletConnectors/chunk-HEZOSHLH.js +446 -0
- package/dist/wallets/walletConnectors/{chunk-GO6HUJTP.js → chunk-HJAUM3KX.js} +6 -6
- package/dist/wallets/walletConnectors/chunk-ICSPFTBY.js +246 -0
- package/dist/wallets/walletConnectors/{chunk-OMZSFUVN.js → chunk-LGFHSL7G.js} +7 -3
- package/dist/wallets/walletConnectors/{chunk-V6R6WDOQ.js → chunk-MRUBFVXX.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-MZFLUT3E.js +243 -0
- package/dist/wallets/walletConnectors/chunk-N7ACKYTK.js +291 -0
- package/dist/wallets/walletConnectors/{chunk-RSR35XOZ.js → chunk-NNLRIZSK.js} +11 -7
- package/dist/wallets/walletConnectors/chunk-NWHJRPZL.js +158 -0
- package/dist/wallets/walletConnectors/{chunk-P64PMEPU.js → chunk-O77UF634.js} +66 -12
- package/dist/wallets/walletConnectors/{chunk-4CKIGJZD.js → chunk-PK5XVWRF.js} +81 -32
- package/dist/wallets/walletConnectors/{chunk-DFG3BSSC.js → chunk-PS66FDPT.js} +79 -30
- package/dist/wallets/walletConnectors/chunk-PWJLUT4Z.js +2629 -0
- package/dist/wallets/walletConnectors/chunk-QCVDHC6P.js +210 -0
- package/dist/wallets/walletConnectors/{chunk-HMIFFMGK.js → chunk-QNZQZ7IH.js} +26 -16
- package/dist/wallets/walletConnectors/chunk-RTECHRPH.js +154 -0
- package/dist/wallets/walletConnectors/{chunk-F4JUKZBB.js → chunk-RU6FIXMD.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-ZWIAZOVB.js → chunk-RUYSIXR3.js} +6 -4
- package/dist/wallets/walletConnectors/{chunk-TRFREYPH.js → chunk-S75DVWSP.js} +39 -9
- package/dist/wallets/walletConnectors/chunk-SN2BNZTO.js +739 -0
- package/dist/wallets/walletConnectors/{chunk-YPMD3ZHF.js → chunk-SRXI2XF5.js} +80 -44
- package/dist/wallets/walletConnectors/chunk-TOX35ET4.js +307 -0
- package/dist/wallets/walletConnectors/{chunk-XPZCOEQL.js → chunk-TPLIG5I7.js} +35 -7
- package/dist/wallets/walletConnectors/{chunk-TP4BDK7W.js → chunk-UVPRZEPJ.js} +5 -1
- package/dist/wallets/walletConnectors/{chunk-SORKIBWX.js → chunk-WUNGUZIQ.js} +4 -5
- package/dist/wallets/walletConnectors/{chunk-2OHHFQQ7.js → chunk-WZMAZENY.js} +3 -1
- package/dist/wallets/walletConnectors/chunk-XPOLIWQQ.js +200 -0
- package/dist/wallets/walletConnectors/{chunk-DRL2CDHT.js → chunk-YFYJ2CFB.js} +80 -44
- package/dist/wallets/walletConnectors/chunk-ZPICFPYN.js +79 -0
- package/dist/wallets/walletConnectors/index.js +67 -65
- package/package.json +1 -1
- package/dist/AbcCredentialManager-WZBF3GHF.js +0 -7
- package/dist/TalkenApiSingleton-TECFDCT4.js +0 -9
- package/dist/chunk-CUPPBGFC.js +0 -460
- package/dist/chunk-R6ZE7JAZ.js +0 -15
- package/dist/wallets/walletConnectors/chunk-2M6E3YXU.js +0 -382
- package/dist/wallets/walletConnectors/chunk-3DHUDD4U.js +0 -132
- package/dist/wallets/walletConnectors/chunk-GAJ4FJTW.js +0 -382
- package/dist/wallets/walletConnectors/chunk-R6ZE7JAZ.js +0 -15
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
badRequest,
|
|
4
|
-
compact
|
|
5
|
-
} from "./chunk-DKMR2ML5.js";
|
|
6
|
-
import {
|
|
7
|
-
TalkenApiError
|
|
8
|
-
} from "./chunk-TP4BDK7W.js";
|
|
9
2
|
|
|
10
3
|
// src/config/networks.ts
|
|
11
4
|
var NETWORK_CONFIGS = {
|
|
@@ -782,6 +775,14 @@ function getChainKey(chainId) {
|
|
|
782
775
|
}
|
|
783
776
|
return key;
|
|
784
777
|
}
|
|
778
|
+
function networkNameToChainKey(network) {
|
|
779
|
+
if (NON_EVM_CHAIN_KEY[network])
|
|
780
|
+
return NON_EVM_CHAIN_KEY[network];
|
|
781
|
+
const chainId = NETWORK_BY_PARAM[network]?.chainId;
|
|
782
|
+
if (chainId == null)
|
|
783
|
+
return network;
|
|
784
|
+
return CHAIN_ID_TO_KEY[chainId] ?? network;
|
|
785
|
+
}
|
|
785
786
|
function getNetworkType(network) {
|
|
786
787
|
const byParam = NETWORK_BY_PARAM[network];
|
|
787
788
|
if (byParam)
|
|
@@ -809,407 +810,11 @@ function getExplorerTxUrl(chainIdOrNetwork, txHash) {
|
|
|
809
810
|
return `${config.explorer}/tx/${txHash}`;
|
|
810
811
|
}
|
|
811
812
|
|
|
812
|
-
// src/utils/amount.ts
|
|
813
|
-
var MAX_DECIMALS = 255;
|
|
814
|
-
var U64_MAX = BigInt("18446744073709551615");
|
|
815
|
-
var ZERO = BigInt(0);
|
|
816
|
-
var TEN = BigInt(10);
|
|
817
|
-
var CANONICAL_DECIMAL = /^(0|[1-9]\d*)(\.\d+)?$/;
|
|
818
|
-
var BASE_UNIT_INTEGER = /^(0|[1-9]\d*)$/;
|
|
819
|
-
function validateAmount(amount) {
|
|
820
|
-
if (typeof amount === "string") {
|
|
821
|
-
if (!CANONICAL_DECIMAL.test(amount))
|
|
822
|
-
throw new Error(
|
|
823
|
-
"Token amount must be a plain decimal string (no sign, exponent or separators)"
|
|
824
|
-
);
|
|
825
|
-
if (!/[1-9]/.test(amount))
|
|
826
|
-
throw new Error("Token amount must be finite and positive");
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0)
|
|
830
|
-
throw new Error("Token amount must be finite and positive");
|
|
831
|
-
}
|
|
832
|
-
function isValidDecimals(decimals) {
|
|
833
|
-
return decimals !== void 0 && Number.isInteger(decimals) && decimals >= 0 && decimals <= MAX_DECIMALS;
|
|
834
|
-
}
|
|
835
|
-
function assertDecimals(decimals) {
|
|
836
|
-
if (!isValidDecimals(decimals))
|
|
837
|
-
throw new Error("Token decimals are missing or invalid");
|
|
838
|
-
}
|
|
839
|
-
function splitAmount(amount) {
|
|
840
|
-
const [coefficient, exponent = "0"] = String(amount).toLowerCase().split("e");
|
|
841
|
-
const [whole, fraction = ""] = coefficient.split(".");
|
|
842
|
-
return {
|
|
843
|
-
digits: BigInt(`${whole}${fraction}`),
|
|
844
|
-
fractionLength: fraction.length,
|
|
845
|
-
exponent: Number(exponent)
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
function toBaseUnits(amount, decimals) {
|
|
849
|
-
validateAmount(amount);
|
|
850
|
-
assertDecimals(decimals);
|
|
851
|
-
const { digits, fractionLength, exponent } = splitAmount(amount);
|
|
852
|
-
if (typeof amount === "string" && fractionLength > decimals)
|
|
853
|
-
throw new Error(
|
|
854
|
-
`Token amount exceeds decimal precision (${decimals} decimals)`
|
|
855
|
-
);
|
|
856
|
-
const scale = decimals + exponent - fractionLength;
|
|
857
|
-
if (scale >= 0)
|
|
858
|
-
return digits * TEN ** BigInt(scale);
|
|
859
|
-
const divisor = TEN ** BigInt(-scale);
|
|
860
|
-
if (digits % divisor !== ZERO)
|
|
861
|
-
throw new Error(
|
|
862
|
-
`Token amount exceeds decimal precision (${decimals} decimals)`
|
|
863
|
-
);
|
|
864
|
-
return digits / divisor;
|
|
865
|
-
}
|
|
866
|
-
function toDecimalAmount(baseUnits, decimals) {
|
|
867
|
-
assertDecimals(decimals);
|
|
868
|
-
if (typeof baseUnits === "string" && !BASE_UNIT_INTEGER.test(baseUnits))
|
|
869
|
-
throw new Error("Base-unit amount must be a non-negative integer string");
|
|
870
|
-
const value = BigInt(baseUnits);
|
|
871
|
-
if (value <= ZERO)
|
|
872
|
-
throw new Error("Token amount must be finite and positive");
|
|
873
|
-
const unit = TEN ** BigInt(decimals);
|
|
874
|
-
const whole = value / unit;
|
|
875
|
-
const fraction = (value % unit).toString().padStart(decimals, "0").replace(/0+$/, "");
|
|
876
|
-
return fraction ? `${whole}.${fraction}` : whole.toString();
|
|
877
|
-
}
|
|
878
|
-
function toSplRawAmount(amount, decimals) {
|
|
879
|
-
validateAmount(amount);
|
|
880
|
-
if (!isValidDecimals(decimals))
|
|
881
|
-
throw new Error("SPL token decimals are missing or invalid");
|
|
882
|
-
const raw = toBaseUnits(amount, decimals);
|
|
883
|
-
if (raw > U64_MAX)
|
|
884
|
-
throw new Error("Token amount is outside the SPL u64 range");
|
|
885
|
-
return raw;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
// src/wallets/walletConnectors/abcWallet/api/modules/executeBodies.ts
|
|
889
|
-
var NATIVE_DECIMALS = {
|
|
890
|
-
solana: 9,
|
|
891
|
-
tron: 6,
|
|
892
|
-
xrpl: 6,
|
|
893
|
-
bitcoin: 8
|
|
894
|
-
};
|
|
895
|
-
var MAX_IDEMPOTENCY_KEY_LENGTH = 200;
|
|
896
|
-
var IDEMPOTENCY_KEY_BYTES = 16;
|
|
897
|
-
var BTC_FEE_RATE_PATTERN = /^[1-9][0-9]{0,3}$/;
|
|
898
|
-
var BTC_FEE_RATE_MAX = 1e3;
|
|
899
|
-
var XRP_FEE_PATTERN = /^[1-9][0-9]{0,6}$/;
|
|
900
|
-
var XRP_FEE_MAX_DROPS = 1e6;
|
|
901
|
-
var TRC20_FEE_LIMIT_MAX_SUN = 1e9;
|
|
902
|
-
var XRP_DESTINATION_TAG_MAX = 4294967295;
|
|
903
|
-
var SOLANA_CHAIN_KEYS = { solana: "solana", solana_devnet: "solanaDevnet" };
|
|
904
|
-
var TRON_CHAIN_KEYS = { tron: "tron", tron_nile: "tronNile" };
|
|
905
|
-
var XRPL_CHAIN_KEYS = { xrpl: "xrpl", xrpl_testnet: "xrplTestnet" };
|
|
906
|
-
var BITCOIN_CHAIN_KEYS = {
|
|
907
|
-
bitcoin: "bitcoin",
|
|
908
|
-
bitcoin_testnet: "bitcoinTestnet"
|
|
909
|
-
};
|
|
910
|
-
function newIdempotencyKey() {
|
|
911
|
-
const bytes = crypto.getRandomValues(new Uint8Array(IDEMPOTENCY_KEY_BYTES));
|
|
912
|
-
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
913
|
-
""
|
|
914
|
-
);
|
|
915
|
-
}
|
|
916
|
-
function acceptIdempotencyKey(key) {
|
|
917
|
-
if (key === void 0)
|
|
918
|
-
return newIdempotencyKey();
|
|
919
|
-
if (typeof key !== "string" || key === "" || key.length > MAX_IDEMPOTENCY_KEY_LENGTH) {
|
|
920
|
-
throw badRequest(
|
|
921
|
-
`idempotencyKey must be a string of 1 to ${MAX_IDEMPOTENCY_KEY_LENGTH} characters`
|
|
922
|
-
);
|
|
923
|
-
}
|
|
924
|
-
return key;
|
|
925
|
-
}
|
|
926
|
-
function chainKeyFor(label, table, network) {
|
|
927
|
-
if (typeof network === "string" && Object.prototype.hasOwnProperty.call(table, network)) {
|
|
928
|
-
return table[network];
|
|
929
|
-
}
|
|
930
|
-
throw badRequest(
|
|
931
|
-
`${label} network must be one of: ${Object.keys(table).join(", ")}`
|
|
932
|
-
);
|
|
933
|
-
}
|
|
934
|
-
function required(value, field) {
|
|
935
|
-
if (typeof value !== "string" || value === "") {
|
|
936
|
-
throw badRequest(`${field} is required`);
|
|
937
|
-
}
|
|
938
|
-
return value;
|
|
939
|
-
}
|
|
940
|
-
function refuseDefined(params, fields, context) {
|
|
941
|
-
for (const field of fields) {
|
|
942
|
-
if (params[field] != null) {
|
|
943
|
-
throw badRequest(`${field} is not supported ${context}`);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
function humanAmount(baseUnits, decimals, field) {
|
|
948
|
-
try {
|
|
949
|
-
return toDecimalAmount(required(baseUnits, field), decimals);
|
|
950
|
-
} catch (error) {
|
|
951
|
-
if (error instanceof TalkenApiError)
|
|
952
|
-
throw error;
|
|
953
|
-
throw badRequest(
|
|
954
|
-
`${field}: ${error instanceof Error ? error.message : String(error)}`
|
|
955
|
-
);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
function toExecuteTxBody(params) {
|
|
959
|
-
return compact({
|
|
960
|
-
chainKey: params.chainKey,
|
|
961
|
-
to: params.to,
|
|
962
|
-
amountWei: params.amountWei,
|
|
963
|
-
data: params.data,
|
|
964
|
-
gasLimit: params.gasLimit,
|
|
965
|
-
gasPrice: params.gasPrice,
|
|
966
|
-
maxFeePerGas: params.maxFeePerGas,
|
|
967
|
-
maxPriorityFeePerGas: params.maxPriorityFeePerGas,
|
|
968
|
-
pin: params.pin,
|
|
969
|
-
email: params.email,
|
|
970
|
-
waitForReceipt: params.waitForReceipt,
|
|
971
|
-
idempotencyKey: acceptIdempotencyKey(params.idempotencyKey)
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
function toSolanaSendBody(params) {
|
|
975
|
-
const chainKey = chainKeyFor("Solana", SOLANA_CHAIN_KEYS, params.network);
|
|
976
|
-
const to = required(params.toAddress, "toAddress");
|
|
977
|
-
const kind = params.kind ?? (params.mintAddress ? "spl" : "native");
|
|
978
|
-
if (kind !== "native" && kind !== "spl") {
|
|
979
|
-
throw badRequest("kind must be native or spl");
|
|
980
|
-
}
|
|
981
|
-
const common = {
|
|
982
|
-
pin: params.pin,
|
|
983
|
-
email: params.email,
|
|
984
|
-
waitForReceipt: params.waitForConfirmation,
|
|
985
|
-
idempotencyKey: acceptIdempotencyKey(params.idempotencyKey)
|
|
986
|
-
};
|
|
987
|
-
if (kind === "native") {
|
|
988
|
-
refuseDefined(
|
|
989
|
-
params,
|
|
990
|
-
["mintAddress", "amount", "decimals"],
|
|
991
|
-
"for a native SOL transfer"
|
|
992
|
-
);
|
|
993
|
-
return compact({
|
|
994
|
-
to,
|
|
995
|
-
chainKey,
|
|
996
|
-
amount: humanAmount(
|
|
997
|
-
params.amountLamports,
|
|
998
|
-
NATIVE_DECIMALS.solana,
|
|
999
|
-
"amountLamports"
|
|
1000
|
-
),
|
|
1001
|
-
...common
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
refuseDefined(params, ["amountLamports"], "for an SPL transfer");
|
|
1005
|
-
return compact({
|
|
1006
|
-
to,
|
|
1007
|
-
chainKey,
|
|
1008
|
-
amount: humanAmount(params.amount, params.decimals, "amount"),
|
|
1009
|
-
token: required(params.mintAddress, "mintAddress"),
|
|
1010
|
-
decimals: params.decimals,
|
|
1011
|
-
...common
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
function toTronSendBody(params) {
|
|
1015
|
-
const chainKey = chainKeyFor("TRON", TRON_CHAIN_KEYS, params.network);
|
|
1016
|
-
const to = required(params.toAddress, "toAddress");
|
|
1017
|
-
const kind = params.kind ?? "native";
|
|
1018
|
-
refuseDefined(
|
|
1019
|
-
params,
|
|
1020
|
-
["data", "callValue", "confirmPollMs", "confirmMaxAttempts"],
|
|
1021
|
-
"by /execute/send"
|
|
1022
|
-
);
|
|
1023
|
-
const common = {
|
|
1024
|
-
pin: params.pin,
|
|
1025
|
-
email: params.email,
|
|
1026
|
-
waitForReceipt: params.waitForConfirmation,
|
|
1027
|
-
idempotencyKey: acceptIdempotencyKey(params.idempotencyKey)
|
|
1028
|
-
};
|
|
1029
|
-
if (kind === "native") {
|
|
1030
|
-
refuseDefined(
|
|
1031
|
-
params,
|
|
1032
|
-
["contractAddress", "amount", "decimals", "feeLimit"],
|
|
1033
|
-
"for a native TRX transfer"
|
|
1034
|
-
);
|
|
1035
|
-
return compact({
|
|
1036
|
-
to,
|
|
1037
|
-
chainKey,
|
|
1038
|
-
amount: humanAmount(params.amountSun, NATIVE_DECIMALS.tron, "amountSun"),
|
|
1039
|
-
...common
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
if (kind !== "trc20") {
|
|
1043
|
-
throw badRequest("kind must be native or trc20");
|
|
1044
|
-
}
|
|
1045
|
-
refuseDefined(params, ["amountSun"], "for a TRC-20 transfer");
|
|
1046
|
-
if (params.feeLimit != null && !(Number.isSafeInteger(params.feeLimit) && params.feeLimit >= 1 && params.feeLimit <= TRC20_FEE_LIMIT_MAX_SUN)) {
|
|
1047
|
-
throw badRequest(
|
|
1048
|
-
`feeLimit must be an integer number of sun from 1 to ${TRC20_FEE_LIMIT_MAX_SUN}`
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
|
-
return compact({
|
|
1052
|
-
to,
|
|
1053
|
-
chainKey,
|
|
1054
|
-
amount: humanAmount(params.amount, params.decimals, "amount"),
|
|
1055
|
-
token: required(params.contractAddress, "contractAddress"),
|
|
1056
|
-
decimals: params.decimals,
|
|
1057
|
-
feeLimit: params.feeLimit,
|
|
1058
|
-
...common
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
function toXrpSendBody(params) {
|
|
1062
|
-
const chainKey = chainKeyFor("XRPL", XRPL_CHAIN_KEYS, params.network);
|
|
1063
|
-
const to = required(params.destination, "destination");
|
|
1064
|
-
if (params.destinationTag != null && !(Number.isInteger(params.destinationTag) && params.destinationTag >= 0 && params.destinationTag <= XRP_DESTINATION_TAG_MAX)) {
|
|
1065
|
-
throw badRequest(
|
|
1066
|
-
`destinationTag must be an integer from 0 to ${XRP_DESTINATION_TAG_MAX}`
|
|
1067
|
-
);
|
|
1068
|
-
}
|
|
1069
|
-
if (params.fee != null && !(typeof params.fee === "string" && XRP_FEE_PATTERN.test(params.fee) && Number(params.fee) <= XRP_FEE_MAX_DROPS)) {
|
|
1070
|
-
throw badRequest(
|
|
1071
|
-
`fee must be a decimal string of whole drops from 1 to ${XRP_FEE_MAX_DROPS}`
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
const common = {
|
|
1075
|
-
destinationTag: params.destinationTag,
|
|
1076
|
-
fee: params.fee,
|
|
1077
|
-
pin: params.pin,
|
|
1078
|
-
email: params.email,
|
|
1079
|
-
waitForReceipt: params.waitForConfirmation,
|
|
1080
|
-
idempotencyKey: acceptIdempotencyKey(params.idempotencyKey)
|
|
1081
|
-
};
|
|
1082
|
-
if (params.kind === "native") {
|
|
1083
|
-
refuseDefined(params, ["currency", "issuer"], "for a native XRP transfer");
|
|
1084
|
-
return compact({
|
|
1085
|
-
to,
|
|
1086
|
-
chainKey,
|
|
1087
|
-
amount: humanAmount(params.amount, NATIVE_DECIMALS.xrpl, "amount"),
|
|
1088
|
-
...common
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
if (params.kind !== "fungible") {
|
|
1092
|
-
throw badRequest("kind must be native or fungible");
|
|
1093
|
-
}
|
|
1094
|
-
try {
|
|
1095
|
-
validateAmount(required(params.amount, "amount"));
|
|
1096
|
-
} catch (error) {
|
|
1097
|
-
if (error instanceof TalkenApiError)
|
|
1098
|
-
throw error;
|
|
1099
|
-
throw badRequest(
|
|
1100
|
-
`amount: ${error instanceof Error ? error.message : String(error)}`
|
|
1101
|
-
);
|
|
1102
|
-
}
|
|
1103
|
-
return compact({
|
|
1104
|
-
to,
|
|
1105
|
-
chainKey,
|
|
1106
|
-
amount: params.amount,
|
|
1107
|
-
token: required(params.currency, "currency"),
|
|
1108
|
-
issuer: required(params.issuer, "issuer"),
|
|
1109
|
-
...common
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
function toBitcoinSendBody(params) {
|
|
1113
|
-
if (params.action !== void 0 && params.action !== "transfer") {
|
|
1114
|
-
throw badRequest("only action=transfer is sent through /execute/send");
|
|
1115
|
-
}
|
|
1116
|
-
refuseDefined(
|
|
1117
|
-
params,
|
|
1118
|
-
[
|
|
1119
|
-
"blocks",
|
|
1120
|
-
"hash",
|
|
1121
|
-
"signatureHex",
|
|
1122
|
-
"confirmPollMs",
|
|
1123
|
-
"confirmMaxAttempts",
|
|
1124
|
-
"minConfirmations"
|
|
1125
|
-
],
|
|
1126
|
-
"by /execute/send"
|
|
1127
|
-
);
|
|
1128
|
-
const chainKey = chainKeyFor("Bitcoin", BITCOIN_CHAIN_KEYS, params.network);
|
|
1129
|
-
let feeRate;
|
|
1130
|
-
if (params.feeRate != null) {
|
|
1131
|
-
feeRate = String(params.feeRate);
|
|
1132
|
-
if (!BTC_FEE_RATE_PATTERN.test(feeRate) || Number(feeRate) > BTC_FEE_RATE_MAX) {
|
|
1133
|
-
throw badRequest(
|
|
1134
|
-
`feeRate must be a whole sat/vB from 1 to ${BTC_FEE_RATE_MAX}`
|
|
1135
|
-
);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return compact({
|
|
1139
|
-
to: required(params.toAddress, "toAddress"),
|
|
1140
|
-
chainKey,
|
|
1141
|
-
amount: humanAmount(
|
|
1142
|
-
params.amountSats,
|
|
1143
|
-
NATIVE_DECIMALS.bitcoin,
|
|
1144
|
-
"amountSats"
|
|
1145
|
-
),
|
|
1146
|
-
feeRate,
|
|
1147
|
-
pin: params.pin,
|
|
1148
|
-
email: params.email,
|
|
1149
|
-
idempotencyKey: acceptIdempotencyKey(params.idempotencyKey)
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1152
|
-
function toBroadcastBody(chainKey, transaction) {
|
|
1153
|
-
return {
|
|
1154
|
-
chainKey: required(chainKey, "chainKey"),
|
|
1155
|
-
transaction: required(transaction, "transaction")
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
function routeRawTransaction(params) {
|
|
1159
|
-
const { chain } = params;
|
|
1160
|
-
if (chain === "tvm" && params.network == null)
|
|
1161
|
-
return "legacy";
|
|
1162
|
-
const network = required(params.network, "network");
|
|
1163
|
-
const family = getNetworkType(network);
|
|
1164
|
-
const contradiction = () => badRequest(`chain=${chain} contradicts network=${network}`);
|
|
1165
|
-
if (chain === "tvm" || family === "TRX" /* TRON */) {
|
|
1166
|
-
if (chain !== void 0 && chain !== "tvm" || family !== "TRX" /* TRON */) {
|
|
1167
|
-
throw family === void 0 && chain === "tvm" ? badRequest(`network ${network} is not a TRON network`) : contradiction();
|
|
1168
|
-
}
|
|
1169
|
-
return "legacy";
|
|
1170
|
-
}
|
|
1171
|
-
if (chain === "svm") {
|
|
1172
|
-
throw badRequest(
|
|
1173
|
-
"sendRawTransaction broadcasts signed EVM transactions only; send a Solana transfer with solana.transfer, or sign a Solana message or transaction with solana.sign"
|
|
1174
|
-
);
|
|
1175
|
-
}
|
|
1176
|
-
if (family !== "EVM" /* EVM */) {
|
|
1177
|
-
throw badRequest(
|
|
1178
|
-
`network ${network} is not an EVM network; /execute/broadcast takes signed EVM transactions only`
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
if (chain !== void 0 && chain !== "evm")
|
|
1182
|
-
throw contradiction();
|
|
1183
|
-
return getEvmChainKey(network) === void 0 ? "legacy" : "broadcast";
|
|
1184
|
-
}
|
|
1185
|
-
function toExecuteBroadcastBody(params) {
|
|
1186
|
-
const chainKey = routeRawTransaction(params) === "broadcast" ? getEvmChainKey(required(params.network, "network")) : void 0;
|
|
1187
|
-
if (chainKey === void 0) {
|
|
1188
|
-
throw badRequest(
|
|
1189
|
-
"Only a signed EVM transaction on a network with a chain key is broadcast through /execute/broadcast"
|
|
1190
|
-
);
|
|
1191
|
-
}
|
|
1192
|
-
return toBroadcastBody(
|
|
1193
|
-
chainKey,
|
|
1194
|
-
required(params.signedSerializeTx, "signedSerializeTx")
|
|
1195
|
-
);
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
813
|
export {
|
|
1199
814
|
getNetworkName,
|
|
1200
815
|
getChainKey,
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
NATIVE_DECIMALS,
|
|
1206
|
-
newIdempotencyKey,
|
|
1207
|
-
toExecuteTxBody,
|
|
1208
|
-
toSolanaSendBody,
|
|
1209
|
-
toTronSendBody,
|
|
1210
|
-
toXrpSendBody,
|
|
1211
|
-
toBitcoinSendBody,
|
|
1212
|
-
toBroadcastBody,
|
|
1213
|
-
routeRawTransaction,
|
|
1214
|
-
toExecuteBroadcastBody
|
|
816
|
+
networkNameToChainKey,
|
|
817
|
+
getNetworkType,
|
|
818
|
+
getEvmChainKey,
|
|
819
|
+
getExplorerTxUrl
|
|
1215
820
|
};
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
TokenApi
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CBXCYWLB.js";
|
|
5
|
+
import {
|
|
6
|
+
networkNameToChainKey
|
|
7
|
+
} from "./chunk-5KPLYJOO.js";
|
|
5
8
|
import {
|
|
6
9
|
createLogger
|
|
7
10
|
} from "./chunk-2DFJ6LEN.js";
|
|
11
|
+
import {
|
|
12
|
+
TalkenApiError,
|
|
13
|
+
isWalletCredentialError
|
|
14
|
+
} from "./chunk-UVPRZEPJ.js";
|
|
15
|
+
import {
|
|
16
|
+
getTalkenApiClient
|
|
17
|
+
} from "./chunk-2YCHXOLC.js";
|
|
8
18
|
|
|
9
19
|
// src/wallets/walletConnectors/abcWallet/api/WalletscanApi.ts
|
|
10
|
-
import { getTalkenApiClient, networkNameToChainKey } from "@talken/talkenkit";
|
|
11
20
|
var logger = createLogger("WalletscanApi");
|
|
12
21
|
var WalletscanApi = class {
|
|
13
22
|
constructor() {
|
|
@@ -20,12 +29,20 @@ var WalletscanApi = class {
|
|
|
20
29
|
const api = getTalkenApiClient();
|
|
21
30
|
if (!api)
|
|
22
31
|
throw new Error("TalkenApiClient not initialized");
|
|
32
|
+
if (!api.hasCredentials())
|
|
33
|
+
throw new TalkenApiError(
|
|
34
|
+
"AUTH_REQUIRED",
|
|
35
|
+
"Wallet lookup requires a user credential.",
|
|
36
|
+
401
|
|
37
|
+
);
|
|
23
38
|
try {
|
|
24
39
|
return await api.walletscan.getTokens({
|
|
25
40
|
walletAddress: params.walletAddress,
|
|
26
41
|
chainKeys: networkNameToChainKey(params.networks)
|
|
27
42
|
});
|
|
28
43
|
} catch (error) {
|
|
44
|
+
if (isWalletCredentialError(error))
|
|
45
|
+
throw error;
|
|
29
46
|
logger.warn("TalkenApi getTokens failed:", error);
|
|
30
47
|
return [];
|
|
31
48
|
}
|
|
@@ -41,7 +58,9 @@ var WalletscanApi = class {
|
|
|
41
58
|
(resolve) => setTimeout(() => resolve([]), timeoutMs)
|
|
42
59
|
)
|
|
43
60
|
]);
|
|
44
|
-
} catch (
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (isWalletCredentialError(error))
|
|
63
|
+
throw error;
|
|
45
64
|
logger.warn("Wallet token request timed out");
|
|
46
65
|
return [];
|
|
47
66
|
}
|
|
@@ -65,7 +84,9 @@ var WalletscanApi = class {
|
|
|
65
84
|
(resolve) => setTimeout(() => resolve(null), timeoutMs)
|
|
66
85
|
)
|
|
67
86
|
]);
|
|
68
|
-
} catch (
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (isWalletCredentialError(error))
|
|
89
|
+
throw error;
|
|
69
90
|
logger.warn("Wallet token balance request timed out");
|
|
70
91
|
return null;
|
|
71
92
|
}
|
|
@@ -80,6 +101,12 @@ var WalletscanApi = class {
|
|
|
80
101
|
const api = getTalkenApiClient();
|
|
81
102
|
if (!api)
|
|
82
103
|
throw new Error("TalkenApiClient not initialized");
|
|
104
|
+
if (!api.hasCredentials())
|
|
105
|
+
throw new TalkenApiError(
|
|
106
|
+
"AUTH_REQUIRED",
|
|
107
|
+
"Wallet lookup requires a user credential.",
|
|
108
|
+
401
|
|
109
|
+
);
|
|
83
110
|
try {
|
|
84
111
|
const tokens = await api.walletscan.getToken({
|
|
85
112
|
contractAddress: params.contractAddress,
|
|
@@ -87,6 +114,8 @@ var WalletscanApi = class {
|
|
|
87
114
|
});
|
|
88
115
|
return tokens.length > 0 ? tokens[0] : null;
|
|
89
116
|
} catch (error) {
|
|
117
|
+
if (isWalletCredentialError(error))
|
|
118
|
+
throw error;
|
|
90
119
|
logger.warn("TalkenApi getToken failed:", params.contractAddress, error);
|
|
91
120
|
return null;
|
|
92
121
|
}
|
|
@@ -107,7 +136,9 @@ var WalletscanApi = class {
|
|
|
107
136
|
)
|
|
108
137
|
]);
|
|
109
138
|
return result;
|
|
110
|
-
} catch (
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (isWalletCredentialError(error))
|
|
141
|
+
throw error;
|
|
111
142
|
logger.warn("Token metadata request timed out:", params.contractAddress);
|
|
112
143
|
return null;
|
|
113
144
|
}
|
|
@@ -122,6 +153,12 @@ var WalletscanApi = class {
|
|
|
122
153
|
const api = getTalkenApiClient();
|
|
123
154
|
if (!api)
|
|
124
155
|
throw new Error("TalkenApiClient not initialized");
|
|
156
|
+
if (!api.hasCredentials())
|
|
157
|
+
throw new TalkenApiError(
|
|
158
|
+
"AUTH_REQUIRED",
|
|
159
|
+
"Wallet lookup requires a user credential.",
|
|
160
|
+
401
|
|
161
|
+
);
|
|
125
162
|
const chainKey = networkNameToChainKey(params.networks);
|
|
126
163
|
try {
|
|
127
164
|
return await api.walletscan.getNativeTokens({
|
|
@@ -129,6 +166,8 @@ var WalletscanApi = class {
|
|
|
129
166
|
chainKeys: chainKey
|
|
130
167
|
});
|
|
131
168
|
} catch (error) {
|
|
169
|
+
if (isWalletCredentialError(error))
|
|
170
|
+
throw error;
|
|
132
171
|
logger.warn("TalkenApi getNativeTokens failed:", error);
|
|
133
172
|
const EVM_MAINNET_KEYS = /* @__PURE__ */ new Set([
|
|
134
173
|
"ethereum",
|
|
@@ -187,7 +226,9 @@ var WalletscanApi = class {
|
|
|
187
226
|
)
|
|
188
227
|
]);
|
|
189
228
|
return natives.length > 0 ? natives[0] : null;
|
|
190
|
-
} catch (
|
|
229
|
+
} catch (error) {
|
|
230
|
+
if (isWalletCredentialError(error))
|
|
231
|
+
throw error;
|
|
191
232
|
logger.warn("Native coin request timed out");
|
|
192
233
|
return null;
|
|
193
234
|
}
|
|
@@ -202,12 +243,20 @@ var WalletscanApi = class {
|
|
|
202
243
|
const api = getTalkenApiClient();
|
|
203
244
|
if (!api)
|
|
204
245
|
throw new Error("TalkenApiClient not initialized");
|
|
246
|
+
if (!api.hasCredentials())
|
|
247
|
+
throw new TalkenApiError(
|
|
248
|
+
"AUTH_REQUIRED",
|
|
249
|
+
"Wallet lookup requires a user credential.",
|
|
250
|
+
401
|
|
251
|
+
);
|
|
205
252
|
try {
|
|
206
253
|
return await api.walletscan.getNfts({
|
|
207
254
|
chainKeys: networkNameToChainKey(params.networks),
|
|
208
255
|
walletAddress: params.walletAddress
|
|
209
256
|
});
|
|
210
257
|
} catch (error) {
|
|
258
|
+
if (isWalletCredentialError(error))
|
|
259
|
+
throw error;
|
|
211
260
|
logger.warn("TalkenApi getNfts failed:", params.contractAddress, error);
|
|
212
261
|
return [];
|
|
213
262
|
}
|
|
@@ -228,7 +277,9 @@ var WalletscanApi = class {
|
|
|
228
277
|
)
|
|
229
278
|
]);
|
|
230
279
|
return nfts.length > 0 ? nfts[0] : null;
|
|
231
|
-
} catch (
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (isWalletCredentialError(error))
|
|
282
|
+
throw error;
|
|
232
283
|
logger.warn("NFT metadata request timed out:", params.contractAddress);
|
|
233
284
|
return null;
|
|
234
285
|
}
|