@dzapio/sdk 2.0.34 → 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 +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +556 -7
- package/dist/index.mjs +555 -8
- package/package.json +6 -3
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,9 @@ import { tempo as tempo$1, hemi as hemi$1, citrea as citrea$1 } from 'viem/chain
|
|
|
6
6
|
import { decodeFunctionData, getAction } from 'viem/utils';
|
|
7
7
|
import { waitForCallsStatus, sendCalls } from 'viem/actions';
|
|
8
8
|
import Decimal from 'decimal.js';
|
|
9
|
+
import { validate, Network } from 'bitcoin-address-validation';
|
|
10
|
+
import { Connection, clusterApiUrl, PublicKey } from '@solana/web3.js';
|
|
11
|
+
import TonWeb from 'tonweb';
|
|
9
12
|
|
|
10
13
|
var __defProp = Object.defineProperty;
|
|
11
14
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -12838,6 +12841,8 @@ var getEIP2612PermitSignature = async (params) => {
|
|
|
12838
12841
|
|
|
12839
12842
|
// src/constants/chains.ts
|
|
12840
12843
|
var exclusiveChainIds = {
|
|
12844
|
+
aptos: 116201519,
|
|
12845
|
+
ethereum: 1,
|
|
12841
12846
|
zkSync: 324,
|
|
12842
12847
|
arthera: 10242,
|
|
12843
12848
|
gnosis: 100,
|
|
@@ -12857,7 +12862,21 @@ var exclusiveChainIds = {
|
|
|
12857
12862
|
citrea: 4114,
|
|
12858
12863
|
pushTestnet: 42101,
|
|
12859
12864
|
astralisTestnet: 71261,
|
|
12860
|
-
|
|
12865
|
+
btc: 1e3,
|
|
12866
|
+
btcln: 1002,
|
|
12867
|
+
solana: 7565164,
|
|
12868
|
+
tron: 728126428,
|
|
12869
|
+
sui: 19219,
|
|
12870
|
+
ton: 607
|
|
12871
|
+
};
|
|
12872
|
+
var chainTypes = {
|
|
12873
|
+
evm: "evm",
|
|
12874
|
+
bvm: "bvm",
|
|
12875
|
+
svm: "svm",
|
|
12876
|
+
aptosvm: "aptosvm",
|
|
12877
|
+
suivm: "suivm",
|
|
12878
|
+
tonvm: "tonvm",
|
|
12879
|
+
tronvm: "tronvm"
|
|
12861
12880
|
};
|
|
12862
12881
|
|
|
12863
12882
|
// src/constants/contract.ts
|
|
@@ -15403,7 +15422,8 @@ var _DZapClient = class _DZapClient {
|
|
|
15403
15422
|
*
|
|
15404
15423
|
* @param params - Configuration object for status checking
|
|
15405
15424
|
* @param params.txHash - Transaction hash for single transaction status (requires chainId)
|
|
15406
|
-
* @param params.chainId - Chain ID for single transaction status (
|
|
15425
|
+
* @param params.chainId - Chain ID for single transaction status (required with txHash or txId)
|
|
15426
|
+
* @param params.txId - Transaction ID for single transaction status (requires chainId)
|
|
15407
15427
|
* @returns Promise resolving to status response(s) with transaction state and details
|
|
15408
15428
|
*
|
|
15409
15429
|
* @example
|
|
@@ -15424,15 +15444,16 @@ var _DZapClient = class _DZapClient {
|
|
|
15424
15444
|
* For cross-chain transactions, this tracks the complete bridge process across both chains.
|
|
15425
15445
|
*
|
|
15426
15446
|
* @param params - Configuration object for status checking
|
|
15427
|
-
* @param params.txHashes -
|
|
15428
|
-
* @param params.chainIds -
|
|
15447
|
+
* @param params.txHashes - Comma-separated transaction hashes (requires chainIds)
|
|
15448
|
+
* @param params.chainIds - Comma-separated chain IDs aligned to txHashes or txIds
|
|
15449
|
+
* @param params.txIds - Comma-separated transaction IDs (requires chainIds)
|
|
15429
15450
|
* @returns Promise resolving to status response(s) with transaction state and details
|
|
15430
15451
|
*
|
|
15431
15452
|
* @example
|
|
15432
15453
|
* ```typescript
|
|
15433
15454
|
*
|
|
15434
15455
|
* // Multiple transactions status
|
|
15435
|
-
* const multiStatus = await client.
|
|
15456
|
+
* const multiStatus = await client.getTradeMultiTxnStatus({
|
|
15436
15457
|
* txHashes: '0x123...,0x456...',
|
|
15437
15458
|
* chainIds: '1,42161'
|
|
15438
15459
|
* });
|
|
@@ -16139,16 +16160,22 @@ var _DZapClient = class _DZapClient {
|
|
|
16139
16160
|
* Zap transactions involve multiple steps and this method provides detailed progress information
|
|
16140
16161
|
* including which steps have completed and any potential issues encountered.
|
|
16141
16162
|
*
|
|
16142
|
-
* @param request -
|
|
16163
|
+
* @param request - `chainId` with either `txnHash` or `txnId` to identify the zap transaction
|
|
16143
16164
|
* @returns Promise resolving to detailed zap transaction status information
|
|
16144
16165
|
*
|
|
16145
16166
|
* @example
|
|
16146
16167
|
* ```typescript
|
|
16147
16168
|
* const zapStatus = await client.getZapTxnStatus({
|
|
16148
|
-
* chainId:
|
|
16169
|
+
* chainId: 1,
|
|
16149
16170
|
* txnHash: '0x...'
|
|
16150
16171
|
* });
|
|
16151
16172
|
*
|
|
16173
|
+
* // Or by internal transaction id:
|
|
16174
|
+
* const zapStatusByTxnId = await client.getZapTxnStatus({
|
|
16175
|
+
* chainId: 1,
|
|
16176
|
+
* txnId: '0x...'
|
|
16177
|
+
* });
|
|
16178
|
+
*
|
|
16152
16179
|
* console.log('Zap status:', zapStatus.status);
|
|
16153
16180
|
* console.log('Completed steps:', zapStatus.completedSteps);
|
|
16154
16181
|
* console.log('Current step:', zapStatus.currentStep);
|
|
@@ -16381,6 +16408,526 @@ var contractErrorActions = {
|
|
|
16381
16408
|
INCREASE_SLIPPAGE: "INCREASE_SLIPPAGE",
|
|
16382
16409
|
INCREASE_ALLOWANCE: "INCREASE_ALLOWANCE"
|
|
16383
16410
|
};
|
|
16411
|
+
var APTOS_DEFAULT_RPC = "https://fullnode.mainnet.aptoslabs.com";
|
|
16412
|
+
var aptosAccountRegex = /^0x[a-fA-F0-9]{1,64}$/;
|
|
16413
|
+
var moveCoinTypeRegex = /^0x[a-fA-F0-9]{1,64}::[A-Za-z_][A-Za-z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;
|
|
16414
|
+
async function classifyAptosvmAddress(params) {
|
|
16415
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16416
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16417
|
+
return {
|
|
16418
|
+
valid: true,
|
|
16419
|
+
kind: "native" /* NATIVE */,
|
|
16420
|
+
isNative: true,
|
|
16421
|
+
isToken: true,
|
|
16422
|
+
isContract: false,
|
|
16423
|
+
address
|
|
16424
|
+
};
|
|
16425
|
+
}
|
|
16426
|
+
if (moveCoinTypeRegex.test(address)) {
|
|
16427
|
+
return {
|
|
16428
|
+
valid: true,
|
|
16429
|
+
kind: "token" /* TOKEN */,
|
|
16430
|
+
isNative: false,
|
|
16431
|
+
isToken: true,
|
|
16432
|
+
isContract: false,
|
|
16433
|
+
address
|
|
16434
|
+
};
|
|
16435
|
+
}
|
|
16436
|
+
if (!aptosAccountRegex.test(address)) {
|
|
16437
|
+
return {
|
|
16438
|
+
valid: false,
|
|
16439
|
+
kind: "invalid" /* INVALID */,
|
|
16440
|
+
isNative: false,
|
|
16441
|
+
isToken: false,
|
|
16442
|
+
isContract: false,
|
|
16443
|
+
address
|
|
16444
|
+
};
|
|
16445
|
+
}
|
|
16446
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? APTOS_DEFAULT_RPC).replace(/\/$/, "");
|
|
16447
|
+
try {
|
|
16448
|
+
const response = await Axios.get(`${baseUrl}/v1/accounts/${address}/modules`, {
|
|
16449
|
+
params: { limit: 1 },
|
|
16450
|
+
validateStatus: (status) => status < 500
|
|
16451
|
+
});
|
|
16452
|
+
if (response.status === 200) {
|
|
16453
|
+
const modules = response.data;
|
|
16454
|
+
if (Array.isArray(modules) && modules.length > 0) {
|
|
16455
|
+
return {
|
|
16456
|
+
valid: true,
|
|
16457
|
+
kind: "contract" /* CONTRACT */,
|
|
16458
|
+
isNative: false,
|
|
16459
|
+
isToken: false,
|
|
16460
|
+
isContract: true,
|
|
16461
|
+
address
|
|
16462
|
+
};
|
|
16463
|
+
}
|
|
16464
|
+
return {
|
|
16465
|
+
valid: true,
|
|
16466
|
+
kind: "wallet" /* WALLET */,
|
|
16467
|
+
isNative: false,
|
|
16468
|
+
isToken: false,
|
|
16469
|
+
isContract: false,
|
|
16470
|
+
address
|
|
16471
|
+
};
|
|
16472
|
+
}
|
|
16473
|
+
if (response.status === 404) {
|
|
16474
|
+
return {
|
|
16475
|
+
valid: true,
|
|
16476
|
+
kind: "wallet" /* WALLET */,
|
|
16477
|
+
isNative: false,
|
|
16478
|
+
isToken: false,
|
|
16479
|
+
isContract: false,
|
|
16480
|
+
address
|
|
16481
|
+
};
|
|
16482
|
+
}
|
|
16483
|
+
return null;
|
|
16484
|
+
} catch (e) {
|
|
16485
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16486
|
+
console.error(`RPC error (Aptos getModules): ${message}`);
|
|
16487
|
+
return null;
|
|
16488
|
+
}
|
|
16489
|
+
}
|
|
16490
|
+
async function classifyBvmAddress(params) {
|
|
16491
|
+
const { address, chainId, chainConfig } = params;
|
|
16492
|
+
const chain = chainConfig[chainId];
|
|
16493
|
+
const isMainnet = (chain == null ? void 0 : chain.mainnet) ?? true;
|
|
16494
|
+
const isValidBtc = validate(address, isMainnet ? Network.mainnet : Network.testnet);
|
|
16495
|
+
if (!isValidBtc) {
|
|
16496
|
+
return {
|
|
16497
|
+
valid: false,
|
|
16498
|
+
kind: "invalid" /* INVALID */,
|
|
16499
|
+
isNative: false,
|
|
16500
|
+
isToken: false,
|
|
16501
|
+
isContract: false,
|
|
16502
|
+
address
|
|
16503
|
+
};
|
|
16504
|
+
}
|
|
16505
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16506
|
+
return {
|
|
16507
|
+
valid: true,
|
|
16508
|
+
kind: "native" /* NATIVE */,
|
|
16509
|
+
isNative: true,
|
|
16510
|
+
isToken: true,
|
|
16511
|
+
isContract: false,
|
|
16512
|
+
address
|
|
16513
|
+
};
|
|
16514
|
+
}
|
|
16515
|
+
return {
|
|
16516
|
+
valid: true,
|
|
16517
|
+
kind: "wallet" /* WALLET */,
|
|
16518
|
+
isNative: false,
|
|
16519
|
+
isToken: false,
|
|
16520
|
+
isContract: false,
|
|
16521
|
+
address
|
|
16522
|
+
};
|
|
16523
|
+
}
|
|
16524
|
+
async function classifyEvmAddress(params) {
|
|
16525
|
+
const { chainId, rpcUrls, chainConfig } = params;
|
|
16526
|
+
const address = formatToken(params.address);
|
|
16527
|
+
if (!isAddress(address)) {
|
|
16528
|
+
return {
|
|
16529
|
+
valid: false,
|
|
16530
|
+
kind: "invalid" /* INVALID */,
|
|
16531
|
+
isNative: false,
|
|
16532
|
+
isToken: false,
|
|
16533
|
+
isContract: false,
|
|
16534
|
+
address
|
|
16535
|
+
};
|
|
16536
|
+
}
|
|
16537
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16538
|
+
return {
|
|
16539
|
+
valid: true,
|
|
16540
|
+
kind: "native" /* NATIVE */,
|
|
16541
|
+
isNative: true,
|
|
16542
|
+
isToken: true,
|
|
16543
|
+
isContract: false,
|
|
16544
|
+
address
|
|
16545
|
+
};
|
|
16546
|
+
}
|
|
16547
|
+
const publicClient = getPublicClient({ rpcUrls, chainId });
|
|
16548
|
+
let bytecode;
|
|
16549
|
+
try {
|
|
16550
|
+
bytecode = await publicClient.getCode({ address });
|
|
16551
|
+
} catch (e) {
|
|
16552
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16553
|
+
console.error(`RPC error (getCode): ${message}`);
|
|
16554
|
+
return null;
|
|
16555
|
+
}
|
|
16556
|
+
if (!bytecode || bytecode === "0x") {
|
|
16557
|
+
return {
|
|
16558
|
+
valid: true,
|
|
16559
|
+
kind: "wallet" /* WALLET */,
|
|
16560
|
+
isNative: false,
|
|
16561
|
+
isToken: false,
|
|
16562
|
+
isContract: false,
|
|
16563
|
+
address
|
|
16564
|
+
};
|
|
16565
|
+
}
|
|
16566
|
+
try {
|
|
16567
|
+
await publicClient.readContract({
|
|
16568
|
+
address,
|
|
16569
|
+
abi: abi5,
|
|
16570
|
+
functionName: erc20Functions.decimals
|
|
16571
|
+
});
|
|
16572
|
+
return {
|
|
16573
|
+
valid: true,
|
|
16574
|
+
kind: "token" /* TOKEN */,
|
|
16575
|
+
isNative: false,
|
|
16576
|
+
isToken: true,
|
|
16577
|
+
isContract: true,
|
|
16578
|
+
address
|
|
16579
|
+
};
|
|
16580
|
+
} catch {
|
|
16581
|
+
return {
|
|
16582
|
+
valid: true,
|
|
16583
|
+
kind: "contract" /* CONTRACT */,
|
|
16584
|
+
isNative: false,
|
|
16585
|
+
isToken: false,
|
|
16586
|
+
isContract: true,
|
|
16587
|
+
address
|
|
16588
|
+
};
|
|
16589
|
+
}
|
|
16590
|
+
}
|
|
16591
|
+
var SUI_DEFAULT_RPC = "https://fullnode.mainnet.sui.io";
|
|
16592
|
+
var suiAccountRegex = /^0x[a-fA-F0-9]{1,64}$/;
|
|
16593
|
+
var moveCoinTypeRegex2 = /^0x[a-fA-F0-9]{1,64}::[A-Za-z_][A-Za-z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;
|
|
16594
|
+
async function classifySuivmAddress(params) {
|
|
16595
|
+
var _a, _b, _c, _d;
|
|
16596
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16597
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16598
|
+
return {
|
|
16599
|
+
valid: true,
|
|
16600
|
+
kind: "native" /* NATIVE */,
|
|
16601
|
+
isNative: true,
|
|
16602
|
+
isToken: true,
|
|
16603
|
+
isContract: false,
|
|
16604
|
+
address
|
|
16605
|
+
};
|
|
16606
|
+
}
|
|
16607
|
+
if (moveCoinTypeRegex2.test(address)) {
|
|
16608
|
+
return {
|
|
16609
|
+
valid: true,
|
|
16610
|
+
kind: "token" /* TOKEN */,
|
|
16611
|
+
isNative: false,
|
|
16612
|
+
isToken: true,
|
|
16613
|
+
isContract: true,
|
|
16614
|
+
address
|
|
16615
|
+
};
|
|
16616
|
+
}
|
|
16617
|
+
if (!suiAccountRegex.test(address)) {
|
|
16618
|
+
return {
|
|
16619
|
+
valid: false,
|
|
16620
|
+
kind: "invalid" /* INVALID */,
|
|
16621
|
+
isNative: false,
|
|
16622
|
+
isToken: false,
|
|
16623
|
+
isContract: false,
|
|
16624
|
+
address
|
|
16625
|
+
};
|
|
16626
|
+
}
|
|
16627
|
+
const rpcUrl = (rpcUrls == null ? void 0 : rpcUrls[0]) ?? SUI_DEFAULT_RPC;
|
|
16628
|
+
try {
|
|
16629
|
+
const response = await Axios.post(rpcUrl, {
|
|
16630
|
+
jsonrpc: "2.0",
|
|
16631
|
+
id: 1,
|
|
16632
|
+
method: "sui_getObject",
|
|
16633
|
+
params: [address, { showType: true }]
|
|
16634
|
+
});
|
|
16635
|
+
if (response.status !== 200 || ((_a = response.data) == null ? void 0 : _a.error)) {
|
|
16636
|
+
return null;
|
|
16637
|
+
}
|
|
16638
|
+
const result = (_b = response.data) == null ? void 0 : _b.result;
|
|
16639
|
+
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") {
|
|
16640
|
+
return {
|
|
16641
|
+
valid: true,
|
|
16642
|
+
kind: "contract" /* CONTRACT */,
|
|
16643
|
+
isNative: false,
|
|
16644
|
+
isToken: false,
|
|
16645
|
+
isContract: true,
|
|
16646
|
+
address
|
|
16647
|
+
};
|
|
16648
|
+
}
|
|
16649
|
+
return {
|
|
16650
|
+
valid: true,
|
|
16651
|
+
kind: "wallet" /* WALLET */,
|
|
16652
|
+
isNative: false,
|
|
16653
|
+
isToken: false,
|
|
16654
|
+
isContract: false,
|
|
16655
|
+
address
|
|
16656
|
+
};
|
|
16657
|
+
} catch (e) {
|
|
16658
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16659
|
+
console.error(`RPC error (Sui sui_getObject): ${message}`);
|
|
16660
|
+
return null;
|
|
16661
|
+
}
|
|
16662
|
+
}
|
|
16663
|
+
var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
16664
|
+
var TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
16665
|
+
function parseSvmAddress(address) {
|
|
16666
|
+
try {
|
|
16667
|
+
return new PublicKey(address);
|
|
16668
|
+
} catch {
|
|
16669
|
+
return null;
|
|
16670
|
+
}
|
|
16671
|
+
}
|
|
16672
|
+
function svmTokenProgramOwner(owner) {
|
|
16673
|
+
return owner === TOKEN_PROGRAM_ID || owner === TOKEN_2022_PROGRAM_ID;
|
|
16674
|
+
}
|
|
16675
|
+
async function classifySvmAddress(params) {
|
|
16676
|
+
const { address, rpcUrls, chainConfig } = params;
|
|
16677
|
+
const pubkey = parseSvmAddress(address);
|
|
16678
|
+
if (!pubkey) {
|
|
16679
|
+
return {
|
|
16680
|
+
valid: false,
|
|
16681
|
+
kind: "invalid" /* INVALID */,
|
|
16682
|
+
isNative: false,
|
|
16683
|
+
isToken: false,
|
|
16684
|
+
isContract: false,
|
|
16685
|
+
address
|
|
16686
|
+
};
|
|
16687
|
+
}
|
|
16688
|
+
const normalized = pubkey.toBase58();
|
|
16689
|
+
if (isNativeCurrency(normalized, chainConfig)) {
|
|
16690
|
+
return {
|
|
16691
|
+
valid: true,
|
|
16692
|
+
kind: "native" /* NATIVE */,
|
|
16693
|
+
isNative: true,
|
|
16694
|
+
isToken: true,
|
|
16695
|
+
isContract: false,
|
|
16696
|
+
address: normalized
|
|
16697
|
+
};
|
|
16698
|
+
}
|
|
16699
|
+
const connection = new Connection((rpcUrls == null ? void 0 : rpcUrls[0]) || clusterApiUrl("mainnet-beta"));
|
|
16700
|
+
let parsed;
|
|
16701
|
+
try {
|
|
16702
|
+
parsed = await connection.getParsedAccountInfo(pubkey);
|
|
16703
|
+
} catch (e) {
|
|
16704
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16705
|
+
console.error(`RPC error (getParsedAccountInfo): ${message}`);
|
|
16706
|
+
return null;
|
|
16707
|
+
}
|
|
16708
|
+
const value = parsed.value;
|
|
16709
|
+
if (!value) {
|
|
16710
|
+
return {
|
|
16711
|
+
valid: true,
|
|
16712
|
+
kind: "wallet" /* WALLET */,
|
|
16713
|
+
isNative: false,
|
|
16714
|
+
isToken: false,
|
|
16715
|
+
isContract: false,
|
|
16716
|
+
address: normalized
|
|
16717
|
+
};
|
|
16718
|
+
}
|
|
16719
|
+
if (value.executable) {
|
|
16720
|
+
return {
|
|
16721
|
+
valid: true,
|
|
16722
|
+
kind: "contract" /* CONTRACT */,
|
|
16723
|
+
isNative: false,
|
|
16724
|
+
isToken: false,
|
|
16725
|
+
isContract: true,
|
|
16726
|
+
address: normalized
|
|
16727
|
+
};
|
|
16728
|
+
}
|
|
16729
|
+
const owner = value.owner.toBase58();
|
|
16730
|
+
const data = value.data;
|
|
16731
|
+
if (typeof data === "object" && data !== null && "parsed" in data) {
|
|
16732
|
+
const rawParsed = data.parsed;
|
|
16733
|
+
const innerType = rawParsed && typeof rawParsed === "object" && rawParsed !== null && "type" in rawParsed ? String(rawParsed.type) : void 0;
|
|
16734
|
+
if (svmTokenProgramOwner(owner) && innerType === "mint") {
|
|
16735
|
+
return {
|
|
16736
|
+
valid: true,
|
|
16737
|
+
kind: "token" /* TOKEN */,
|
|
16738
|
+
isNative: false,
|
|
16739
|
+
isToken: true,
|
|
16740
|
+
isContract: true,
|
|
16741
|
+
address: normalized
|
|
16742
|
+
};
|
|
16743
|
+
}
|
|
16744
|
+
if (svmTokenProgramOwner(owner) && innerType === "account") {
|
|
16745
|
+
return {
|
|
16746
|
+
valid: true,
|
|
16747
|
+
kind: "contract" /* CONTRACT */,
|
|
16748
|
+
isNative: false,
|
|
16749
|
+
isToken: false,
|
|
16750
|
+
isContract: true,
|
|
16751
|
+
address: normalized
|
|
16752
|
+
};
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
return {
|
|
16756
|
+
valid: true,
|
|
16757
|
+
kind: "wallet" /* WALLET */,
|
|
16758
|
+
isNative: false,
|
|
16759
|
+
isToken: false,
|
|
16760
|
+
isContract: false,
|
|
16761
|
+
address: normalized
|
|
16762
|
+
};
|
|
16763
|
+
}
|
|
16764
|
+
var TON_DEFAULT_RPC = "https://toncenter.com/api/v2";
|
|
16765
|
+
async function classifyTonvmAddress(params) {
|
|
16766
|
+
var _a, _b, _c, _d, _e;
|
|
16767
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16768
|
+
if (!TonWeb.utils.Address.isValid(address)) {
|
|
16769
|
+
return {
|
|
16770
|
+
valid: false,
|
|
16771
|
+
kind: "invalid" /* INVALID */,
|
|
16772
|
+
isNative: false,
|
|
16773
|
+
isToken: false,
|
|
16774
|
+
isContract: false,
|
|
16775
|
+
address
|
|
16776
|
+
};
|
|
16777
|
+
}
|
|
16778
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16779
|
+
return {
|
|
16780
|
+
valid: true,
|
|
16781
|
+
kind: "native" /* NATIVE */,
|
|
16782
|
+
isNative: true,
|
|
16783
|
+
isToken: true,
|
|
16784
|
+
isContract: false,
|
|
16785
|
+
address
|
|
16786
|
+
};
|
|
16787
|
+
}
|
|
16788
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? TON_DEFAULT_RPC).replace(/\/$/, "");
|
|
16789
|
+
try {
|
|
16790
|
+
const infoResponse = await Axios.get(`${baseUrl}/getAddressInformation`, {
|
|
16791
|
+
params: { address }
|
|
16792
|
+
});
|
|
16793
|
+
if (infoResponse.status !== 200 || ((_a = infoResponse.data) == null ? void 0 : _a.error) || ((_b = infoResponse.data) == null ? void 0 : _b.ok) === false) {
|
|
16794
|
+
return null;
|
|
16795
|
+
}
|
|
16796
|
+
const result = (_c = infoResponse.data) == null ? void 0 : _c.result;
|
|
16797
|
+
if (!(result == null ? void 0 : result.code)) {
|
|
16798
|
+
return {
|
|
16799
|
+
valid: true,
|
|
16800
|
+
kind: "wallet" /* WALLET */,
|
|
16801
|
+
isNative: false,
|
|
16802
|
+
isToken: false,
|
|
16803
|
+
isContract: false,
|
|
16804
|
+
address
|
|
16805
|
+
};
|
|
16806
|
+
}
|
|
16807
|
+
try {
|
|
16808
|
+
const jettonResponse = await Axios.post(
|
|
16809
|
+
`${baseUrl}/runGetMethod`,
|
|
16810
|
+
{ address, method: "get_jetton_data", stack: [] },
|
|
16811
|
+
{ validateStatus: (status) => status < 500 }
|
|
16812
|
+
);
|
|
16813
|
+
if (((_e = (_d = jettonResponse.data) == null ? void 0 : _d.result) == null ? void 0 : _e.exit_code) === 0) {
|
|
16814
|
+
return {
|
|
16815
|
+
valid: true,
|
|
16816
|
+
kind: "token" /* TOKEN */,
|
|
16817
|
+
isNative: false,
|
|
16818
|
+
isToken: true,
|
|
16819
|
+
isContract: true,
|
|
16820
|
+
address
|
|
16821
|
+
};
|
|
16822
|
+
}
|
|
16823
|
+
} catch {
|
|
16824
|
+
}
|
|
16825
|
+
return {
|
|
16826
|
+
valid: true,
|
|
16827
|
+
kind: "contract" /* CONTRACT */,
|
|
16828
|
+
isNative: false,
|
|
16829
|
+
isToken: false,
|
|
16830
|
+
isContract: true,
|
|
16831
|
+
address
|
|
16832
|
+
};
|
|
16833
|
+
} catch (e) {
|
|
16834
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16835
|
+
console.error(`RPC error (TON getAddressInformation): ${message}`);
|
|
16836
|
+
return null;
|
|
16837
|
+
}
|
|
16838
|
+
}
|
|
16839
|
+
var TRON_DEFAULT_RPC = "https://api.trongrid.io";
|
|
16840
|
+
var tronAddressRegex = /^T[1-9A-HJ-NP-Za-km-z]{33}$/;
|
|
16841
|
+
async function classifyTronvmAddress(params) {
|
|
16842
|
+
var _a, _b;
|
|
16843
|
+
const { address, chainConfig, rpcUrls } = params;
|
|
16844
|
+
if (!tronAddressRegex.test(address)) {
|
|
16845
|
+
return {
|
|
16846
|
+
valid: false,
|
|
16847
|
+
kind: "invalid" /* INVALID */,
|
|
16848
|
+
isNative: false,
|
|
16849
|
+
isToken: false,
|
|
16850
|
+
isContract: false,
|
|
16851
|
+
address
|
|
16852
|
+
};
|
|
16853
|
+
}
|
|
16854
|
+
if (isNativeCurrency(address, chainConfig)) {
|
|
16855
|
+
return {
|
|
16856
|
+
valid: true,
|
|
16857
|
+
kind: "native" /* NATIVE */,
|
|
16858
|
+
isNative: true,
|
|
16859
|
+
isToken: true,
|
|
16860
|
+
isContract: false,
|
|
16861
|
+
address
|
|
16862
|
+
};
|
|
16863
|
+
}
|
|
16864
|
+
const baseUrl = ((rpcUrls == null ? void 0 : rpcUrls[0]) ?? TRON_DEFAULT_RPC).replace(/\/$/, "");
|
|
16865
|
+
try {
|
|
16866
|
+
const response = await Axios.post(`${baseUrl}/wallet/getcontract`, { value: address, visible: true });
|
|
16867
|
+
if (response.status !== 200 || ((_a = response.data) == null ? void 0 : _a.error)) {
|
|
16868
|
+
return null;
|
|
16869
|
+
}
|
|
16870
|
+
const contract = response.data;
|
|
16871
|
+
const hasBytecode = (contract == null ? void 0 : contract.bytecode) && String(contract.bytecode).length > 0;
|
|
16872
|
+
if (!hasBytecode) {
|
|
16873
|
+
return {
|
|
16874
|
+
valid: true,
|
|
16875
|
+
kind: "wallet" /* WALLET */,
|
|
16876
|
+
isNative: false,
|
|
16877
|
+
isToken: false,
|
|
16878
|
+
isContract: false,
|
|
16879
|
+
address
|
|
16880
|
+
};
|
|
16881
|
+
}
|
|
16882
|
+
const abiEntries = ((_b = contract == null ? void 0 : contract.abi) == null ? void 0 : _b.entrys) ?? [];
|
|
16883
|
+
const isToken = abiEntries.some((entry) => entry.name === "decimals");
|
|
16884
|
+
return {
|
|
16885
|
+
valid: true,
|
|
16886
|
+
kind: isToken ? "token" /* TOKEN */ : "contract" /* CONTRACT */,
|
|
16887
|
+
isNative: false,
|
|
16888
|
+
isToken,
|
|
16889
|
+
isContract: true,
|
|
16890
|
+
address
|
|
16891
|
+
};
|
|
16892
|
+
} catch (e) {
|
|
16893
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
16894
|
+
console.error(`RPC error (Tron getcontract): ${message}`);
|
|
16895
|
+
return null;
|
|
16896
|
+
}
|
|
16897
|
+
}
|
|
16898
|
+
|
|
16899
|
+
// src/utils/address/index.ts
|
|
16900
|
+
var classifiers = {
|
|
16901
|
+
[chainTypes.evm]: classifyEvmAddress,
|
|
16902
|
+
[chainTypes.svm]: classifySvmAddress,
|
|
16903
|
+
[chainTypes.bvm]: classifyBvmAddress,
|
|
16904
|
+
[chainTypes.suivm]: classifySuivmAddress,
|
|
16905
|
+
[chainTypes.aptosvm]: classifyAptosvmAddress,
|
|
16906
|
+
[chainTypes.tonvm]: classifyTonvmAddress,
|
|
16907
|
+
[chainTypes.tronvm]: classifyTronvmAddress
|
|
16908
|
+
};
|
|
16909
|
+
var getChainType = (chainId, chainConfig) => {
|
|
16910
|
+
var _a;
|
|
16911
|
+
const type = (_a = chainConfig[chainId]) == null ? void 0 : _a.chainType;
|
|
16912
|
+
return type;
|
|
16913
|
+
};
|
|
16914
|
+
var classifyAddress = async (params) => {
|
|
16915
|
+
const chainConfig = await dZapClient_default.getChainConfig();
|
|
16916
|
+
const chainType = getChainType(params.chainId, chainConfig);
|
|
16917
|
+
if (!chainType) {
|
|
16918
|
+
throw new Error(`Chain type not found for chainId ${params.chainId}`);
|
|
16919
|
+
}
|
|
16920
|
+
const resolver = classifiers[chainType];
|
|
16921
|
+
if (!resolver) {
|
|
16922
|
+
throw new Error(`Resolver not found for chainType ${chainType}`);
|
|
16923
|
+
}
|
|
16924
|
+
return resolver({
|
|
16925
|
+
address: params.address,
|
|
16926
|
+
chainId: params.chainId,
|
|
16927
|
+
chainConfig,
|
|
16928
|
+
rpcUrls: params.rpcUrls
|
|
16929
|
+
});
|
|
16930
|
+
};
|
|
16384
16931
|
|
|
16385
16932
|
// src/zap/constants/path.ts
|
|
16386
16933
|
var zapPathAction = {
|
|
@@ -16394,4 +16941,4 @@ var zapPathAction = {
|
|
|
16394
16941
|
harvest: "harvest"
|
|
16395
16942
|
};
|
|
16396
16943
|
|
|
16397
|
-
export { AllowanceTypes, ApprovalModes, dZapClient_default as DZapClient, DZapPermitMode, OtherAbis, PermitTypes, QuoteFilters, STATUS, Services, SignatureExpiryInSecs, StatusCodes, SwapInputDataDecoder, TxnStatus, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
|
16944
|
+
export { AllowanceTypes, ApprovalModes, dZapClient_default as DZapClient, DZapPermitMode, OtherAbis, PermitTypes, QuoteFilters, STATUS, Services, SignatureExpiryInSecs, StatusCodes, SwapInputDataDecoder, TxnStatus, arthera, astralisTestnet, checkEIP2612PermitSupport, citrea, classifyAddress, contractErrorActions, customViemChains, erc20Functions, extendViemChain, fiveIre, formatToken, getTokensPairKey, hemi, hyperEvm, hyperliquid, pushTestnet, stableChain, tempo, viemChainsById, zapPathAction, zapStepAction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dzapio/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.35",
|
|
4
4
|
"description": "A TypeScript/JavaScript SDK for interacting with the DZap protocol, providing utilities for DeFi operations including Swaps, Bridges, and Zaps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -97,17 +97,20 @@
|
|
|
97
97
|
"husky": "^9.0.10",
|
|
98
98
|
"jest": "^29.7.0",
|
|
99
99
|
"lint-staged": "^15.2.2",
|
|
100
|
-
"tsup": "^8.3.5",
|
|
101
100
|
"nodemon": "^2.0.16",
|
|
102
101
|
"prettier": "^3.1.0",
|
|
103
102
|
"ts-jest": "^29.4.0",
|
|
103
|
+
"tsup": "^8.3.5",
|
|
104
104
|
"typescript": "^5.5.4"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
+
"@solana/web3.js": "1.95.8",
|
|
107
108
|
"axios": "^1.2.1",
|
|
109
|
+
"bitcoin-address-validation": "^2.2.3",
|
|
108
110
|
"decimal.js": "^10.4.3",
|
|
109
|
-
"node-cache": "^5.1.2",
|
|
110
111
|
"ethers": "5.7.2",
|
|
112
|
+
"node-cache": "^5.1.2",
|
|
113
|
+
"tonweb": "^0.0.66",
|
|
111
114
|
"viem": "2.48.4"
|
|
112
115
|
},
|
|
113
116
|
"repository": {
|