@dzapio/sdk 2.0.33 → 2.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +564 -21
- package/dist/index.mjs +563 -22
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ var viemChains = require('viem/chains');
|
|
|
7
7
|
var utils = require('viem/utils');
|
|
8
8
|
var actions = require('viem/actions');
|
|
9
9
|
var Decimal = require('decimal.js');
|
|
10
|
+
var bitcoinAddressValidation = require('bitcoin-address-validation');
|
|
11
|
+
var web3_js = require('@solana/web3.js');
|
|
12
|
+
var TonWeb = require('tonweb');
|
|
10
13
|
|
|
11
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
15
|
|
|
@@ -31,6 +34,7 @@ function _interopNamespace(e) {
|
|
|
31
34
|
var Axios__default = /*#__PURE__*/_interopDefault(Axios);
|
|
32
35
|
var viemChains__namespace = /*#__PURE__*/_interopNamespace(viemChains);
|
|
33
36
|
var Decimal__default = /*#__PURE__*/_interopDefault(Decimal);
|
|
37
|
+
var TonWeb__default = /*#__PURE__*/_interopDefault(TonWeb);
|
|
34
38
|
|
|
35
39
|
var __defProp = Object.defineProperty;
|
|
36
40
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -459,20 +463,14 @@ var fetchTokenPrice = (tokenAddresses, chainId) => invoke({
|
|
|
459
463
|
data: { tokenAddresses, chainId },
|
|
460
464
|
method: GET
|
|
461
465
|
});
|
|
462
|
-
var fetchStatus = (
|
|
466
|
+
var fetchStatus = (params) => invoke({
|
|
463
467
|
endpoint: GET_STATUS,
|
|
464
|
-
data:
|
|
465
|
-
txHash,
|
|
466
|
-
chainId
|
|
467
|
-
},
|
|
468
|
+
data: params,
|
|
468
469
|
method: GET
|
|
469
470
|
});
|
|
470
|
-
var fetchMultiTxStatus = (
|
|
471
|
+
var fetchMultiTxStatus = (params) => invoke({
|
|
471
472
|
endpoint: GET_MULTI_STATUS,
|
|
472
|
-
data:
|
|
473
|
-
txHashes,
|
|
474
|
-
chainIds
|
|
475
|
-
},
|
|
473
|
+
data: params,
|
|
476
474
|
method: GET
|
|
477
475
|
});
|
|
478
476
|
var fetchCalculatedPoints = (request) => invoke({
|
|
@@ -12869,6 +12867,8 @@ var getEIP2612PermitSignature = async (params) => {
|
|
|
12869
12867
|
|
|
12870
12868
|
// src/constants/chains.ts
|
|
12871
12869
|
var exclusiveChainIds = {
|
|
12870
|
+
aptos: 116201519,
|
|
12871
|
+
ethereum: 1,
|
|
12872
12872
|
zkSync: 324,
|
|
12873
12873
|
arthera: 10242,
|
|
12874
12874
|
gnosis: 100,
|
|
@@ -12888,7 +12888,21 @@ var exclusiveChainIds = {
|
|
|
12888
12888
|
citrea: 4114,
|
|
12889
12889
|
pushTestnet: 42101,
|
|
12890
12890
|
astralisTestnet: 71261,
|
|
12891
|
-
|
|
12891
|
+
btc: 1e3,
|
|
12892
|
+
btcln: 1002,
|
|
12893
|
+
solana: 7565164,
|
|
12894
|
+
tron: 728126428,
|
|
12895
|
+
sui: 19219,
|
|
12896
|
+
ton: 607
|
|
12897
|
+
};
|
|
12898
|
+
var chainTypes = {
|
|
12899
|
+
evm: "evm",
|
|
12900
|
+
bvm: "bvm",
|
|
12901
|
+
svm: "svm",
|
|
12902
|
+
aptosvm: "aptosvm",
|
|
12903
|
+
suivm: "suivm",
|
|
12904
|
+
tonvm: "tonvm",
|
|
12905
|
+
tronvm: "tronvm"
|
|
12892
12906
|
};
|
|
12893
12907
|
|
|
12894
12908
|
// src/constants/contract.ts
|
|
@@ -15434,7 +15448,8 @@ var _DZapClient = class _DZapClient {
|
|
|
15434
15448
|
*
|
|
15435
15449
|
* @param params - Configuration object for status checking
|
|
15436
15450
|
* @param params.txHash - Transaction hash for single transaction status (requires chainId)
|
|
15437
|
-
* @param params.chainId - Chain ID for single transaction status (
|
|
15451
|
+
* @param params.chainId - Chain ID for single transaction status (required with txHash or txId)
|
|
15452
|
+
* @param params.txId - Transaction ID for single transaction status (requires chainId)
|
|
15438
15453
|
* @returns Promise resolving to status response(s) with transaction state and details
|
|
15439
15454
|
*
|
|
15440
15455
|
* @example
|
|
@@ -15446,8 +15461,8 @@ var _DZapClient = class _DZapClient {
|
|
|
15446
15461
|
* });
|
|
15447
15462
|
* ```
|
|
15448
15463
|
*/
|
|
15449
|
-
getTradeTxnStatus(
|
|
15450
|
-
return fetchStatus(
|
|
15464
|
+
getTradeTxnStatus(params) {
|
|
15465
|
+
return fetchStatus(params);
|
|
15451
15466
|
}
|
|
15452
15467
|
/**
|
|
15453
15468
|
* Fetches the current status of trade transactions including swaps and bridges.
|
|
@@ -15455,22 +15470,23 @@ var _DZapClient = class _DZapClient {
|
|
|
15455
15470
|
* For cross-chain transactions, this tracks the complete bridge process across both chains.
|
|
15456
15471
|
*
|
|
15457
15472
|
* @param params - Configuration object for status checking
|
|
15458
|
-
* @param params.txHashes -
|
|
15459
|
-
* @param params.chainIds -
|
|
15473
|
+
* @param params.txHashes - Comma-separated transaction hashes (requires chainIds)
|
|
15474
|
+
* @param params.chainIds - Comma-separated chain IDs aligned to txHashes or txIds
|
|
15475
|
+
* @param params.txIds - Comma-separated transaction IDs (requires chainIds)
|
|
15460
15476
|
* @returns Promise resolving to status response(s) with transaction state and details
|
|
15461
15477
|
*
|
|
15462
15478
|
* @example
|
|
15463
15479
|
* ```typescript
|
|
15464
15480
|
*
|
|
15465
15481
|
* // Multiple transactions status
|
|
15466
|
-
* const multiStatus = await client.
|
|
15482
|
+
* const multiStatus = await client.getTradeMultiTxnStatus({
|
|
15467
15483
|
* txHashes: '0x123...,0x456...',
|
|
15468
15484
|
* chainIds: '1,42161'
|
|
15469
15485
|
* });
|
|
15470
15486
|
* ```
|
|
15471
15487
|
*/
|
|
15472
|
-
getTradeMultiTxnStatus(
|
|
15473
|
-
return fetchMultiTxStatus(
|
|
15488
|
+
getTradeMultiTxnStatus(params) {
|
|
15489
|
+
return fetchMultiTxStatus(params);
|
|
15474
15490
|
}
|
|
15475
15491
|
/**
|
|
15476
15492
|
* Fetches all blockchain networks supported by the DZap protocol.
|
|
@@ -16170,16 +16186,22 @@ var _DZapClient = class _DZapClient {
|
|
|
16170
16186
|
* Zap transactions involve multiple steps and this method provides detailed progress information
|
|
16171
16187
|
* including which steps have completed and any potential issues encountered.
|
|
16172
16188
|
*
|
|
16173
|
-
* @param request -
|
|
16189
|
+
* @param request - `chainId` with either `txnHash` or `txnId` to identify the zap transaction
|
|
16174
16190
|
* @returns Promise resolving to detailed zap transaction status information
|
|
16175
16191
|
*
|
|
16176
16192
|
* @example
|
|
16177
16193
|
* ```typescript
|
|
16178
16194
|
* const zapStatus = await client.getZapTxnStatus({
|
|
16179
|
-
* chainId:
|
|
16195
|
+
* chainId: 1,
|
|
16180
16196
|
* txnHash: '0x...'
|
|
16181
16197
|
* });
|
|
16182
16198
|
*
|
|
16199
|
+
* // Or by internal transaction id:
|
|
16200
|
+
* const zapStatusByTxnId = await client.getZapTxnStatus({
|
|
16201
|
+
* chainId: 1,
|
|
16202
|
+
* txnId: '0x...'
|
|
16203
|
+
* });
|
|
16204
|
+
*
|
|
16183
16205
|
* console.log('Zap status:', zapStatus.status);
|
|
16184
16206
|
* console.log('Completed steps:', zapStatus.completedSteps);
|
|
16185
16207
|
* console.log('Current step:', zapStatus.currentStep);
|
|
@@ -16412,6 +16434,526 @@ var contractErrorActions = {
|
|
|
16412
16434
|
INCREASE_SLIPPAGE: "INCREASE_SLIPPAGE",
|
|
16413
16435
|
INCREASE_ALLOWANCE: "INCREASE_ALLOWANCE"
|
|
16414
16436
|
};
|
|
16437
|
+
var APTOS_DEFAULT_RPC = "https://fullnode.mainnet.aptoslabs.com";
|
|
16438
|
+
var aptosAccountRegex = /^0x[a-fA-F0-9]{1,64}$/;
|
|
16439
|
+
var moveCoinTypeRegex = /^0x[a-fA-F0-9]{1,64}::[A-Za-z_][A-Za-z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;
|
|
16440
|
+
async function classifyAptosvmAddress(params) {
|
|
16441
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16442
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16443
|
+
return {
|
|
16444
|
+
valid: true,
|
|
16445
|
+
kind: "native" /* NATIVE */,
|
|
16446
|
+
isNative: true,
|
|
16447
|
+
isToken: true,
|
|
16448
|
+
isContract: false,
|
|
16449
|
+
address
|
|
16450
|
+
};
|
|
16451
|
+
}
|
|
16452
|
+
if (moveCoinTypeRegex.test(address)) {
|
|
16453
|
+
return {
|
|
16454
|
+
valid: true,
|
|
16455
|
+
kind: "token" /* TOKEN */,
|
|
16456
|
+
isNative: false,
|
|
16457
|
+
isToken: true,
|
|
16458
|
+
isContract: false,
|
|
16459
|
+
address
|
|
16460
|
+
};
|
|
16461
|
+
}
|
|
16462
|
+
if (!aptosAccountRegex.test(address)) {
|
|
16463
|
+
return {
|
|
16464
|
+
valid: false,
|
|
16465
|
+
kind: "invalid" /* INVALID */,
|
|
16466
|
+
isNative: false,
|
|
16467
|
+
isToken: false,
|
|
16468
|
+
isContract: false,
|
|
16469
|
+
address
|
|
16470
|
+
};
|
|
16471
|
+
}
|
|
16472
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? APTOS_DEFAULT_RPC).replace(/\/$/, "");
|
|
16473
|
+
try {
|
|
16474
|
+
const response = await Axios__default.default.get(`${baseUrl}/v1/accounts/${address}/modules`, {
|
|
16475
|
+
params: { limit: 1 },
|
|
16476
|
+
validateStatus: (status) => status < 500
|
|
16477
|
+
});
|
|
16478
|
+
if (response.status === 200) {
|
|
16479
|
+
const modules = response.data;
|
|
16480
|
+
if (Array.isArray(modules) && modules.length > 0) {
|
|
16481
|
+
return {
|
|
16482
|
+
valid: true,
|
|
16483
|
+
kind: "contract" /* CONTRACT */,
|
|
16484
|
+
isNative: false,
|
|
16485
|
+
isToken: false,
|
|
16486
|
+
isContract: true,
|
|
16487
|
+
address
|
|
16488
|
+
};
|
|
16489
|
+
}
|
|
16490
|
+
return {
|
|
16491
|
+
valid: true,
|
|
16492
|
+
kind: "wallet" /* WALLET */,
|
|
16493
|
+
isNative: false,
|
|
16494
|
+
isToken: false,
|
|
16495
|
+
isContract: false,
|
|
16496
|
+
address
|
|
16497
|
+
};
|
|
16498
|
+
}
|
|
16499
|
+
if (response.status === 404) {
|
|
16500
|
+
return {
|
|
16501
|
+
valid: true,
|
|
16502
|
+
kind: "wallet" /* WALLET */,
|
|
16503
|
+
isNative: false,
|
|
16504
|
+
isToken: false,
|
|
16505
|
+
isContract: false,
|
|
16506
|
+
address
|
|
16507
|
+
};
|
|
16508
|
+
}
|
|
16509
|
+
return null;
|
|
16510
|
+
} catch (e) {
|
|
16511
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16512
|
+
console.error(`RPC error (Aptos getModules): ${message}`);
|
|
16513
|
+
return null;
|
|
16514
|
+
}
|
|
16515
|
+
}
|
|
16516
|
+
async function classifyBvmAddress(params) {
|
|
16517
|
+
const { address, chainId, chainConfig } = params;
|
|
16518
|
+
const chain = chainConfig[chainId];
|
|
16519
|
+
const isMainnet = (chain == null ? void 0 : chain.mainnet) ?? true;
|
|
16520
|
+
const isValidBtc = bitcoinAddressValidation.validate(address, isMainnet ? bitcoinAddressValidation.Network.mainnet : bitcoinAddressValidation.Network.testnet);
|
|
16521
|
+
if (!isValidBtc) {
|
|
16522
|
+
return {
|
|
16523
|
+
valid: false,
|
|
16524
|
+
kind: "invalid" /* INVALID */,
|
|
16525
|
+
isNative: false,
|
|
16526
|
+
isToken: false,
|
|
16527
|
+
isContract: false,
|
|
16528
|
+
address
|
|
16529
|
+
};
|
|
16530
|
+
}
|
|
16531
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16532
|
+
return {
|
|
16533
|
+
valid: true,
|
|
16534
|
+
kind: "native" /* NATIVE */,
|
|
16535
|
+
isNative: true,
|
|
16536
|
+
isToken: true,
|
|
16537
|
+
isContract: false,
|
|
16538
|
+
address
|
|
16539
|
+
};
|
|
16540
|
+
}
|
|
16541
|
+
return {
|
|
16542
|
+
valid: true,
|
|
16543
|
+
kind: "wallet" /* WALLET */,
|
|
16544
|
+
isNative: false,
|
|
16545
|
+
isToken: false,
|
|
16546
|
+
isContract: false,
|
|
16547
|
+
address
|
|
16548
|
+
};
|
|
16549
|
+
}
|
|
16550
|
+
async function classifyEvmAddress(params) {
|
|
16551
|
+
const { chainId, rpcUrls, chainConfig } = params;
|
|
16552
|
+
const address = formatToken(params.address);
|
|
16553
|
+
if (!viem.isAddress(address)) {
|
|
16554
|
+
return {
|
|
16555
|
+
valid: false,
|
|
16556
|
+
kind: "invalid" /* INVALID */,
|
|
16557
|
+
isNative: false,
|
|
16558
|
+
isToken: false,
|
|
16559
|
+
isContract: false,
|
|
16560
|
+
address
|
|
16561
|
+
};
|
|
16562
|
+
}
|
|
16563
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16564
|
+
return {
|
|
16565
|
+
valid: true,
|
|
16566
|
+
kind: "native" /* NATIVE */,
|
|
16567
|
+
isNative: true,
|
|
16568
|
+
isToken: true,
|
|
16569
|
+
isContract: false,
|
|
16570
|
+
address
|
|
16571
|
+
};
|
|
16572
|
+
}
|
|
16573
|
+
const publicClient = getPublicClient({ rpcUrls, chainId });
|
|
16574
|
+
let bytecode;
|
|
16575
|
+
try {
|
|
16576
|
+
bytecode = await publicClient.getCode({ address });
|
|
16577
|
+
} catch (e) {
|
|
16578
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16579
|
+
console.error(`RPC error (getCode): ${message}`);
|
|
16580
|
+
return null;
|
|
16581
|
+
}
|
|
16582
|
+
if (!bytecode || bytecode === "0x") {
|
|
16583
|
+
return {
|
|
16584
|
+
valid: true,
|
|
16585
|
+
kind: "wallet" /* WALLET */,
|
|
16586
|
+
isNative: false,
|
|
16587
|
+
isToken: false,
|
|
16588
|
+
isContract: false,
|
|
16589
|
+
address
|
|
16590
|
+
};
|
|
16591
|
+
}
|
|
16592
|
+
try {
|
|
16593
|
+
await publicClient.readContract({
|
|
16594
|
+
address,
|
|
16595
|
+
abi: abi5,
|
|
16596
|
+
functionName: erc20Functions.decimals
|
|
16597
|
+
});
|
|
16598
|
+
return {
|
|
16599
|
+
valid: true,
|
|
16600
|
+
kind: "token" /* TOKEN */,
|
|
16601
|
+
isNative: false,
|
|
16602
|
+
isToken: true,
|
|
16603
|
+
isContract: true,
|
|
16604
|
+
address
|
|
16605
|
+
};
|
|
16606
|
+
} catch {
|
|
16607
|
+
return {
|
|
16608
|
+
valid: true,
|
|
16609
|
+
kind: "contract" /* CONTRACT */,
|
|
16610
|
+
isNative: false,
|
|
16611
|
+
isToken: false,
|
|
16612
|
+
isContract: true,
|
|
16613
|
+
address
|
|
16614
|
+
};
|
|
16615
|
+
}
|
|
16616
|
+
}
|
|
16617
|
+
var SUI_DEFAULT_RPC = "https://fullnode.mainnet.sui.io";
|
|
16618
|
+
var suiAccountRegex = /^0x[a-fA-F0-9]{1,64}$/;
|
|
16619
|
+
var moveCoinTypeRegex2 = /^0x[a-fA-F0-9]{1,64}::[A-Za-z_][A-Za-z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;
|
|
16620
|
+
async function classifySuivmAddress(params) {
|
|
16621
|
+
var _a, _b, _c, _d;
|
|
16622
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16623
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16624
|
+
return {
|
|
16625
|
+
valid: true,
|
|
16626
|
+
kind: "native" /* NATIVE */,
|
|
16627
|
+
isNative: true,
|
|
16628
|
+
isToken: true,
|
|
16629
|
+
isContract: false,
|
|
16630
|
+
address
|
|
16631
|
+
};
|
|
16632
|
+
}
|
|
16633
|
+
if (moveCoinTypeRegex2.test(address)) {
|
|
16634
|
+
return {
|
|
16635
|
+
valid: true,
|
|
16636
|
+
kind: "token" /* TOKEN */,
|
|
16637
|
+
isNative: false,
|
|
16638
|
+
isToken: true,
|
|
16639
|
+
isContract: true,
|
|
16640
|
+
address
|
|
16641
|
+
};
|
|
16642
|
+
}
|
|
16643
|
+
if (!suiAccountRegex.test(address)) {
|
|
16644
|
+
return {
|
|
16645
|
+
valid: false,
|
|
16646
|
+
kind: "invalid" /* INVALID */,
|
|
16647
|
+
isNative: false,
|
|
16648
|
+
isToken: false,
|
|
16649
|
+
isContract: false,
|
|
16650
|
+
address
|
|
16651
|
+
};
|
|
16652
|
+
}
|
|
16653
|
+
const rpcUrl = (rpcUrls == null ? void 0 : rpcUrls[0]) ?? SUI_DEFAULT_RPC;
|
|
16654
|
+
try {
|
|
16655
|
+
const response = await Axios__default.default.post(rpcUrl, {
|
|
16656
|
+
jsonrpc: "2.0",
|
|
16657
|
+
id: 1,
|
|
16658
|
+
method: "sui_getObject",
|
|
16659
|
+
params: [address, { showType: true }]
|
|
16660
|
+
});
|
|
16661
|
+
if (response.status !== 200 || ((_a = response.data) == null ? void 0 : _a.error)) {
|
|
16662
|
+
return null;
|
|
16663
|
+
}
|
|
16664
|
+
const result = (_b = response.data) == null ? void 0 : _b.result;
|
|
16665
|
+
if (((_c = result == null ? void 0 : result.data) == null ? void 0 : _c.type) === "package" || ((_d = result == null ? void 0 : result.data) == null ? void 0 : _d.dataType) === "package") {
|
|
16666
|
+
return {
|
|
16667
|
+
valid: true,
|
|
16668
|
+
kind: "contract" /* CONTRACT */,
|
|
16669
|
+
isNative: false,
|
|
16670
|
+
isToken: false,
|
|
16671
|
+
isContract: true,
|
|
16672
|
+
address
|
|
16673
|
+
};
|
|
16674
|
+
}
|
|
16675
|
+
return {
|
|
16676
|
+
valid: true,
|
|
16677
|
+
kind: "wallet" /* WALLET */,
|
|
16678
|
+
isNative: false,
|
|
16679
|
+
isToken: false,
|
|
16680
|
+
isContract: false,
|
|
16681
|
+
address
|
|
16682
|
+
};
|
|
16683
|
+
} catch (e) {
|
|
16684
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16685
|
+
console.error(`RPC error (Sui sui_getObject): ${message}`);
|
|
16686
|
+
return null;
|
|
16687
|
+
}
|
|
16688
|
+
}
|
|
16689
|
+
var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
16690
|
+
var TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
16691
|
+
function parseSvmAddress(address) {
|
|
16692
|
+
try {
|
|
16693
|
+
return new web3_js.PublicKey(address);
|
|
16694
|
+
} catch {
|
|
16695
|
+
return null;
|
|
16696
|
+
}
|
|
16697
|
+
}
|
|
16698
|
+
function svmTokenProgramOwner(owner) {
|
|
16699
|
+
return owner === TOKEN_PROGRAM_ID || owner === TOKEN_2022_PROGRAM_ID;
|
|
16700
|
+
}
|
|
16701
|
+
async function classifySvmAddress(params) {
|
|
16702
|
+
const { address, rpcUrls, chainConfig } = params;
|
|
16703
|
+
const pubkey = parseSvmAddress(address);
|
|
16704
|
+
if (!pubkey) {
|
|
16705
|
+
return {
|
|
16706
|
+
valid: false,
|
|
16707
|
+
kind: "invalid" /* INVALID */,
|
|
16708
|
+
isNative: false,
|
|
16709
|
+
isToken: false,
|
|
16710
|
+
isContract: false,
|
|
16711
|
+
address
|
|
16712
|
+
};
|
|
16713
|
+
}
|
|
16714
|
+
const normalized = pubkey.toBase58();
|
|
16715
|
+
if (isNativeCurrency(normalized, chainConfig)) {
|
|
16716
|
+
return {
|
|
16717
|
+
valid: true,
|
|
16718
|
+
kind: "native" /* NATIVE */,
|
|
16719
|
+
isNative: true,
|
|
16720
|
+
isToken: true,
|
|
16721
|
+
isContract: false,
|
|
16722
|
+
address: normalized
|
|
16723
|
+
};
|
|
16724
|
+
}
|
|
16725
|
+
const connection = new web3_js.Connection((rpcUrls == null ? void 0 : rpcUrls[0]) || web3_js.clusterApiUrl("mainnet-beta"));
|
|
16726
|
+
let parsed;
|
|
16727
|
+
try {
|
|
16728
|
+
parsed = await connection.getParsedAccountInfo(pubkey);
|
|
16729
|
+
} catch (e) {
|
|
16730
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16731
|
+
console.error(`RPC error (getParsedAccountInfo): ${message}`);
|
|
16732
|
+
return null;
|
|
16733
|
+
}
|
|
16734
|
+
const value = parsed.value;
|
|
16735
|
+
if (!value) {
|
|
16736
|
+
return {
|
|
16737
|
+
valid: true,
|
|
16738
|
+
kind: "wallet" /* WALLET */,
|
|
16739
|
+
isNative: false,
|
|
16740
|
+
isToken: false,
|
|
16741
|
+
isContract: false,
|
|
16742
|
+
address: normalized
|
|
16743
|
+
};
|
|
16744
|
+
}
|
|
16745
|
+
if (value.executable) {
|
|
16746
|
+
return {
|
|
16747
|
+
valid: true,
|
|
16748
|
+
kind: "contract" /* CONTRACT */,
|
|
16749
|
+
isNative: false,
|
|
16750
|
+
isToken: false,
|
|
16751
|
+
isContract: true,
|
|
16752
|
+
address: normalized
|
|
16753
|
+
};
|
|
16754
|
+
}
|
|
16755
|
+
const owner = value.owner.toBase58();
|
|
16756
|
+
const data = value.data;
|
|
16757
|
+
if (typeof data === "object" && data !== null && "parsed" in data) {
|
|
16758
|
+
const rawParsed = data.parsed;
|
|
16759
|
+
const innerType = rawParsed && typeof rawParsed === "object" && rawParsed !== null && "type" in rawParsed ? String(rawParsed.type) : void 0;
|
|
16760
|
+
if (svmTokenProgramOwner(owner) && innerType === "mint") {
|
|
16761
|
+
return {
|
|
16762
|
+
valid: true,
|
|
16763
|
+
kind: "token" /* TOKEN */,
|
|
16764
|
+
isNative: false,
|
|
16765
|
+
isToken: true,
|
|
16766
|
+
isContract: true,
|
|
16767
|
+
address: normalized
|
|
16768
|
+
};
|
|
16769
|
+
}
|
|
16770
|
+
if (svmTokenProgramOwner(owner) && innerType === "account") {
|
|
16771
|
+
return {
|
|
16772
|
+
valid: true,
|
|
16773
|
+
kind: "contract" /* CONTRACT */,
|
|
16774
|
+
isNative: false,
|
|
16775
|
+
isToken: false,
|
|
16776
|
+
isContract: true,
|
|
16777
|
+
address: normalized
|
|
16778
|
+
};
|
|
16779
|
+
}
|
|
16780
|
+
}
|
|
16781
|
+
return {
|
|
16782
|
+
valid: true,
|
|
16783
|
+
kind: "wallet" /* WALLET */,
|
|
16784
|
+
isNative: false,
|
|
16785
|
+
isToken: false,
|
|
16786
|
+
isContract: false,
|
|
16787
|
+
address: normalized
|
|
16788
|
+
};
|
|
16789
|
+
}
|
|
16790
|
+
var TON_DEFAULT_RPC = "https://toncenter.com/api/v2";
|
|
16791
|
+
async function classifyTonvmAddress(params) {
|
|
16792
|
+
var _a, _b, _c, _d, _e;
|
|
16793
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16794
|
+
if (!TonWeb__default.default.utils.Address.isValid(address)) {
|
|
16795
|
+
return {
|
|
16796
|
+
valid: false,
|
|
16797
|
+
kind: "invalid" /* INVALID */,
|
|
16798
|
+
isNative: false,
|
|
16799
|
+
isToken: false,
|
|
16800
|
+
isContract: false,
|
|
16801
|
+
address
|
|
16802
|
+
};
|
|
16803
|
+
}
|
|
16804
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16805
|
+
return {
|
|
16806
|
+
valid: true,
|
|
16807
|
+
kind: "native" /* NATIVE */,
|
|
16808
|
+
isNative: true,
|
|
16809
|
+
isToken: true,
|
|
16810
|
+
isContract: false,
|
|
16811
|
+
address
|
|
16812
|
+
};
|
|
16813
|
+
}
|
|
16814
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? TON_DEFAULT_RPC).replace(/\/$/, "");
|
|
16815
|
+
try {
|
|
16816
|
+
const infoResponse = await Axios__default.default.get(`${baseUrl}/getAddressInformation`, {
|
|
16817
|
+
params: { address }
|
|
16818
|
+
});
|
|
16819
|
+
if (infoResponse.status !== 200 || ((_a = infoResponse.data) == null ? void 0 : _a.error) || ((_b = infoResponse.data) == null ? void 0 : _b.ok) === false) {
|
|
16820
|
+
return null;
|
|
16821
|
+
}
|
|
16822
|
+
const result = (_c = infoResponse.data) == null ? void 0 : _c.result;
|
|
16823
|
+
if (!(result == null ? void 0 : result.code)) {
|
|
16824
|
+
return {
|
|
16825
|
+
valid: true,
|
|
16826
|
+
kind: "wallet" /* WALLET */,
|
|
16827
|
+
isNative: false,
|
|
16828
|
+
isToken: false,
|
|
16829
|
+
isContract: false,
|
|
16830
|
+
address
|
|
16831
|
+
};
|
|
16832
|
+
}
|
|
16833
|
+
try {
|
|
16834
|
+
const jettonResponse = await Axios__default.default.post(
|
|
16835
|
+
`${baseUrl}/runGetMethod`,
|
|
16836
|
+
{ address, method: "get_jetton_data", stack: [] },
|
|
16837
|
+
{ validateStatus: (status) => status < 500 }
|
|
16838
|
+
);
|
|
16839
|
+
if (((_e = (_d = jettonResponse.data) == null ? void 0 : _d.result) == null ? void 0 : _e.exit_code) === 0) {
|
|
16840
|
+
return {
|
|
16841
|
+
valid: true,
|
|
16842
|
+
kind: "token" /* TOKEN */,
|
|
16843
|
+
isNative: false,
|
|
16844
|
+
isToken: true,
|
|
16845
|
+
isContract: true,
|
|
16846
|
+
address
|
|
16847
|
+
};
|
|
16848
|
+
}
|
|
16849
|
+
} catch {
|
|
16850
|
+
}
|
|
16851
|
+
return {
|
|
16852
|
+
valid: true,
|
|
16853
|
+
kind: "contract" /* CONTRACT */,
|
|
16854
|
+
isNative: false,
|
|
16855
|
+
isToken: false,
|
|
16856
|
+
isContract: true,
|
|
16857
|
+
address
|
|
16858
|
+
};
|
|
16859
|
+
} catch (e) {
|
|
16860
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16861
|
+
console.error(`RPC error (TON getAddressInformation): ${message}`);
|
|
16862
|
+
return null;
|
|
16863
|
+
}
|
|
16864
|
+
}
|
|
16865
|
+
var TRON_DEFAULT_RPC = "https://api.trongrid.io";
|
|
16866
|
+
var tronAddressRegex = /^T[1-9A-HJ-NP-Za-km-z]{33}$/;
|
|
16867
|
+
async function classifyTronvmAddress(params) {
|
|
16868
|
+
var _a, _b;
|
|
16869
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16870
|
+
if (!tronAddressRegex.test(address)) {
|
|
16871
|
+
return {
|
|
16872
|
+
valid: false,
|
|
16873
|
+
kind: "invalid" /* INVALID */,
|
|
16874
|
+
isNative: false,
|
|
16875
|
+
isToken: false,
|
|
16876
|
+
isContract: false,
|
|
16877
|
+
address
|
|
16878
|
+
};
|
|
16879
|
+
}
|
|
16880
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16881
|
+
return {
|
|
16882
|
+
valid: true,
|
|
16883
|
+
kind: "native" /* NATIVE */,
|
|
16884
|
+
isNative: true,
|
|
16885
|
+
isToken: true,
|
|
16886
|
+
isContract: false,
|
|
16887
|
+
address
|
|
16888
|
+
};
|
|
16889
|
+
}
|
|
16890
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? TRON_DEFAULT_RPC).replace(/\/$/, "");
|
|
16891
|
+
try {
|
|
16892
|
+
const response = await Axios__default.default.post(`${baseUrl}/wallet/getcontract`, { value: address, visible: true });
|
|
16893
|
+
if (response.status !== 200 || ((_a = response.data) == null ? void 0 : _a.error)) {
|
|
16894
|
+
return null;
|
|
16895
|
+
}
|
|
16896
|
+
const contract = response.data;
|
|
16897
|
+
const hasBytecode = (contract == null ? void 0 : contract.bytecode) && String(contract.bytecode).length > 0;
|
|
16898
|
+
if (!hasBytecode) {
|
|
16899
|
+
return {
|
|
16900
|
+
valid: true,
|
|
16901
|
+
kind: "wallet" /* WALLET */,
|
|
16902
|
+
isNative: false,
|
|
16903
|
+
isToken: false,
|
|
16904
|
+
isContract: false,
|
|
16905
|
+
address
|
|
16906
|
+
};
|
|
16907
|
+
}
|
|
16908
|
+
const abiEntries = ((_b = contract == null ? void 0 : contract.abi) == null ? void 0 : _b.entrys) ?? [];
|
|
16909
|
+
const isToken = abiEntries.some((entry) => entry.name === "decimals");
|
|
16910
|
+
return {
|
|
16911
|
+
valid: true,
|
|
16912
|
+
kind: isToken ? "token" /* TOKEN */ : "contract" /* CONTRACT */,
|
|
16913
|
+
isNative: false,
|
|
16914
|
+
isToken,
|
|
16915
|
+
isContract: true,
|
|
16916
|
+
address
|
|
16917
|
+
};
|
|
16918
|
+
} catch (e) {
|
|
16919
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16920
|
+
console.error(`RPC error (Tron getcontract): ${message}`);
|
|
16921
|
+
return null;
|
|
16922
|
+
}
|
|
16923
|
+
}
|
|
16924
|
+
|
|
16925
|
+
// src/utils/address/index.ts
|
|
16926
|
+
var classifiers = {
|
|
16927
|
+
[chainTypes.evm]: classifyEvmAddress,
|
|
16928
|
+
[chainTypes.svm]: classifySvmAddress,
|
|
16929
|
+
[chainTypes.bvm]: classifyBvmAddress,
|
|
16930
|
+
[chainTypes.suivm]: classifySuivmAddress,
|
|
16931
|
+
[chainTypes.aptosvm]: classifyAptosvmAddress,
|
|
16932
|
+
[chainTypes.tonvm]: classifyTonvmAddress,
|
|
16933
|
+
[chainTypes.tronvm]: classifyTronvmAddress
|
|
16934
|
+
};
|
|
16935
|
+
var getChainType = (chainId, chainConfig) => {
|
|
16936
|
+
var _a;
|
|
16937
|
+
const type = (_a = chainConfig[chainId]) == null ? void 0 : _a.chainType;
|
|
16938
|
+
return type;
|
|
16939
|
+
};
|
|
16940
|
+
var classifyAddress = async (params) => {
|
|
16941
|
+
const chainConfig = await dZapClient_default.getChainConfig();
|
|
16942
|
+
const chainType = getChainType(params.chainId, chainConfig);
|
|
16943
|
+
if (!chainType) {
|
|
16944
|
+
throw new Error(`Chain type not found for chainId ${params.chainId}`);
|
|
16945
|
+
}
|
|
16946
|
+
const resolver = classifiers[chainType];
|
|
16947
|
+
if (!resolver) {
|
|
16948
|
+
throw new Error(`Resolver not found for chainType ${chainType}`);
|
|
16949
|
+
}
|
|
16950
|
+
return resolver({
|
|
16951
|
+
address: params.address,
|
|
16952
|
+
chainId: params.chainId,
|
|
16953
|
+
chainConfig,
|
|
16954
|
+
rpcUrls: params.rpcUrls
|
|
16955
|
+
});
|
|
16956
|
+
};
|
|
16415
16957
|
|
|
16416
16958
|
// src/zap/constants/path.ts
|
|
16417
16959
|
var zapPathAction = {
|
|
@@ -16442,6 +16984,7 @@ exports.arthera = arthera;
|
|
|
16442
16984
|
exports.astralisTestnet = astralisTestnet;
|
|
16443
16985
|
exports.checkEIP2612PermitSupport = checkEIP2612PermitSupport;
|
|
16444
16986
|
exports.citrea = citrea;
|
|
16987
|
+
exports.classifyAddress = classifyAddress;
|
|
16445
16988
|
exports.contractErrorActions = contractErrorActions;
|
|
16446
16989
|
exports.customViemChains = customViemChains;
|
|
16447
16990
|
exports.erc20Functions = erc20Functions;
|