@dzapio/sdk 2.0.17 → 2.0.19
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -32
- package/dist/index.mjs +19 -33
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -135,6 +135,7 @@ var PermitToDZapPermitMode = {
|
|
|
135
135
|
[PermitTypes.PermitWitnessTransferFrom]: 2 /* PERMIT2_WITNESS_TRANSFER */,
|
|
136
136
|
[PermitTypes.PermitBatchWitnessTransferFrom]: 3 /* BATCH_PERMIT2_WITNESS_TRANSFER */
|
|
137
137
|
};
|
|
138
|
+
var EIP2612_PERMIT_TYPEHASH = viem.keccak256(viem.stringToHex("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"));
|
|
138
139
|
|
|
139
140
|
// src/constants/approval.ts
|
|
140
141
|
var { EIP2612Permit, ...permitModeWithoutKey } = PermitTypes;
|
|
@@ -145,6 +146,7 @@ var ApprovalModes = {
|
|
|
145
146
|
|
|
146
147
|
// src/constants/erc20.ts
|
|
147
148
|
var erc20PermitFunctions = {
|
|
149
|
+
PERMIT_TYPEHASH: "PERMIT_TYPEHASH",
|
|
148
150
|
allowance: "allowance"
|
|
149
151
|
};
|
|
150
152
|
var erc20Functions = {
|
|
@@ -10733,33 +10735,9 @@ var pushTestnet = /* @__PURE__ */ viem.defineChain({
|
|
|
10733
10735
|
}
|
|
10734
10736
|
}
|
|
10735
10737
|
});
|
|
10736
|
-
var astralisTestnet = /* @__PURE__ */ viem.defineChain({
|
|
10737
|
-
id: 71261,
|
|
10738
|
-
name: "Astralis Chain",
|
|
10739
|
-
nativeCurrency: {
|
|
10740
|
-
decimals: 18,
|
|
10741
|
-
name: "ASTCH",
|
|
10742
|
-
symbol: "ASTCH"
|
|
10743
|
-
},
|
|
10744
|
-
rpcUrls: {
|
|
10745
|
-
default: { http: ["https://test-rpc.astralischain.com"] }
|
|
10746
|
-
},
|
|
10747
|
-
blockExplorers: {
|
|
10748
|
-
default: {
|
|
10749
|
-
name: "Astralis Testnet Explorer",
|
|
10750
|
-
url: "https://test-explorer.astralischain.com"
|
|
10751
|
-
}
|
|
10752
|
-
},
|
|
10753
|
-
contracts: {
|
|
10754
|
-
multicall3: {
|
|
10755
|
-
address: "0xd74bAE15b413e0a90A7B2C1723F4A9c15cb49f73",
|
|
10756
|
-
blockCreated: 260214
|
|
10757
|
-
}
|
|
10758
|
-
}
|
|
10759
|
-
});
|
|
10760
10738
|
|
|
10761
10739
|
// src/chains/index.ts
|
|
10762
|
-
var customViemChains = [fiveIre, arthera, hyperEvm, hyperliquid, stableChain, pushTestnet
|
|
10740
|
+
var customViemChains = [fiveIre, arthera, hyperEvm, hyperliquid, stableChain, pushTestnet];
|
|
10763
10741
|
var viemChainsById = [...Object.values(viemChains__namespace), ...customViemChains].reduce((acc, chainData) => {
|
|
10764
10742
|
return chainData.id ? {
|
|
10765
10743
|
...acc,
|
|
@@ -12703,6 +12681,11 @@ var checkEIP2612PermitSupport = async ({
|
|
|
12703
12681
|
address,
|
|
12704
12682
|
abi: erc20PermitAbi,
|
|
12705
12683
|
functionName: erc20Functions.name
|
|
12684
|
+
},
|
|
12685
|
+
{
|
|
12686
|
+
address,
|
|
12687
|
+
abi: erc20PermitAbi,
|
|
12688
|
+
functionName: erc20PermitFunctions.PERMIT_TYPEHASH
|
|
12706
12689
|
}
|
|
12707
12690
|
];
|
|
12708
12691
|
const multicallResult = await multicall({
|
|
@@ -12715,13 +12698,17 @@ var checkEIP2612PermitSupport = async ({
|
|
|
12715
12698
|
return { supportsPermit: false };
|
|
12716
12699
|
}
|
|
12717
12700
|
const results = multicallResult.data;
|
|
12718
|
-
const [domainSeparatorResult, nonceResult, versionResult, nameResult] = results;
|
|
12719
|
-
if (domainSeparatorResult.status !== "success" /* success */ || nonceResult.status !== "success" /* success */ || nameResult.status !== "success" /* success */) {
|
|
12701
|
+
const [domainSeparatorResult, nonceResult, versionResult, nameResult, permitTypeHashResult] = results;
|
|
12702
|
+
if (domainSeparatorResult.status !== "success" /* success */ || nonceResult.status !== "success" /* success */ || nameResult.status !== "success" /* success */ || permitTypeHashResult.status !== "success" /* success */) {
|
|
12720
12703
|
return { supportsPermit: false };
|
|
12721
12704
|
}
|
|
12722
12705
|
const name = nameResult.result;
|
|
12723
12706
|
const nonce = nonceResult.result;
|
|
12724
12707
|
const version = versionResult.status === "success" /* success */ ? versionResult.result : DEFAULT_PERMIT_VERSION;
|
|
12708
|
+
const permitTypeHash = permitTypeHashResult.result;
|
|
12709
|
+
if (permitTypeHash.toLowerCase() !== EIP2612_PERMIT_TYPEHASH.toLowerCase()) {
|
|
12710
|
+
return { supportsPermit: false };
|
|
12711
|
+
}
|
|
12725
12712
|
return {
|
|
12726
12713
|
supportsPermit: true,
|
|
12727
12714
|
data: {
|
|
@@ -12809,8 +12796,7 @@ var exclusiveChainIds = {
|
|
|
12809
12796
|
lens: 232,
|
|
12810
12797
|
citreaTestnet: 5115,
|
|
12811
12798
|
hyperLiquid: 998,
|
|
12812
|
-
pushTestnet: 42101
|
|
12813
|
-
astralisTestnet: 71261
|
|
12799
|
+
pushTestnet: 42101
|
|
12814
12800
|
};
|
|
12815
12801
|
|
|
12816
12802
|
// src/constants/contract.ts
|
|
@@ -12826,8 +12812,7 @@ var exclusivePermit2Addresses = {
|
|
|
12826
12812
|
[exclusiveChainIds.bahamut]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5",
|
|
12827
12813
|
[exclusiveChainIds.pushTestnet]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5",
|
|
12828
12814
|
[exclusiveChainIds.abstract]: "0x0000000000225e31D15943971F47aD3022F714Fa",
|
|
12829
|
-
[exclusiveChainIds.lens]: "0x0000000000225e31D15943971F47aD3022F714Fa"
|
|
12830
|
-
[exclusiveChainIds.astralisTestnet]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5"
|
|
12815
|
+
[exclusiveChainIds.lens]: "0x0000000000225e31D15943971F47aD3022F714Fa"
|
|
12831
12816
|
};
|
|
12832
12817
|
var DEFAULT_PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
12833
12818
|
|
|
@@ -14522,11 +14507,12 @@ var getAllowance = async ({ chainId, sender, tokens, rpcUrls, multicallAddress,
|
|
|
14522
14507
|
token: address,
|
|
14523
14508
|
spender,
|
|
14524
14509
|
amount,
|
|
14510
|
+
isEIP2612PermitSupported: false,
|
|
14525
14511
|
isDefaultApprovalMode: true
|
|
14526
14512
|
};
|
|
14527
14513
|
} else {
|
|
14528
14514
|
const permit2Address = getPermit2Address(chainId);
|
|
14529
|
-
return { token: address, spender: permit2Address, amount, isDefaultApprovalMode: false };
|
|
14515
|
+
return { token: address, spender: permit2Address, amount, isEIP2612PermitSupported: false, isDefaultApprovalMode: false };
|
|
14530
14516
|
}
|
|
14531
14517
|
})
|
|
14532
14518
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeAbiParameters, parseAbiParameters, keccak256, encodePacked, defineChain, zeroAddress as zeroAddress$1, isAddress, getAddress, formatUnits, http, createPublicClient, fallback, parseEventLogs, maxUint256, encodeFunctionData, maxUint48, getContract, decodeAbiParameters } from 'viem';
|
|
1
|
+
import { encodeAbiParameters, parseAbiParameters, keccak256, encodePacked, stringToHex, defineChain, zeroAddress as zeroAddress$1, isAddress, getAddress, formatUnits, http, createPublicClient, fallback, parseEventLogs, maxUint256, encodeFunctionData, maxUint48, getContract, decodeAbiParameters } from 'viem';
|
|
2
2
|
import Axios from 'axios';
|
|
3
3
|
import { Signer, ethers } from 'ethers';
|
|
4
4
|
import * as viemChains from 'viem/chains';
|
|
@@ -109,6 +109,7 @@ var PermitToDZapPermitMode = {
|
|
|
109
109
|
[PermitTypes.PermitWitnessTransferFrom]: 2 /* PERMIT2_WITNESS_TRANSFER */,
|
|
110
110
|
[PermitTypes.PermitBatchWitnessTransferFrom]: 3 /* BATCH_PERMIT2_WITNESS_TRANSFER */
|
|
111
111
|
};
|
|
112
|
+
var EIP2612_PERMIT_TYPEHASH = keccak256(stringToHex("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"));
|
|
112
113
|
|
|
113
114
|
// src/constants/approval.ts
|
|
114
115
|
var { EIP2612Permit, ...permitModeWithoutKey } = PermitTypes;
|
|
@@ -119,6 +120,7 @@ var ApprovalModes = {
|
|
|
119
120
|
|
|
120
121
|
// src/constants/erc20.ts
|
|
121
122
|
var erc20PermitFunctions = {
|
|
123
|
+
PERMIT_TYPEHASH: "PERMIT_TYPEHASH",
|
|
122
124
|
allowance: "allowance"
|
|
123
125
|
};
|
|
124
126
|
var erc20Functions = {
|
|
@@ -10707,33 +10709,9 @@ var pushTestnet = /* @__PURE__ */ defineChain({
|
|
|
10707
10709
|
}
|
|
10708
10710
|
}
|
|
10709
10711
|
});
|
|
10710
|
-
var astralisTestnet = /* @__PURE__ */ defineChain({
|
|
10711
|
-
id: 71261,
|
|
10712
|
-
name: "Astralis Chain",
|
|
10713
|
-
nativeCurrency: {
|
|
10714
|
-
decimals: 18,
|
|
10715
|
-
name: "ASTCH",
|
|
10716
|
-
symbol: "ASTCH"
|
|
10717
|
-
},
|
|
10718
|
-
rpcUrls: {
|
|
10719
|
-
default: { http: ["https://test-rpc.astralischain.com"] }
|
|
10720
|
-
},
|
|
10721
|
-
blockExplorers: {
|
|
10722
|
-
default: {
|
|
10723
|
-
name: "Astralis Testnet Explorer",
|
|
10724
|
-
url: "https://test-explorer.astralischain.com"
|
|
10725
|
-
}
|
|
10726
|
-
},
|
|
10727
|
-
contracts: {
|
|
10728
|
-
multicall3: {
|
|
10729
|
-
address: "0xd74bAE15b413e0a90A7B2C1723F4A9c15cb49f73",
|
|
10730
|
-
blockCreated: 260214
|
|
10731
|
-
}
|
|
10732
|
-
}
|
|
10733
|
-
});
|
|
10734
10712
|
|
|
10735
10713
|
// src/chains/index.ts
|
|
10736
|
-
var customViemChains = [fiveIre, arthera, hyperEvm, hyperliquid, stableChain, pushTestnet
|
|
10714
|
+
var customViemChains = [fiveIre, arthera, hyperEvm, hyperliquid, stableChain, pushTestnet];
|
|
10737
10715
|
var viemChainsById = [...Object.values(viemChains), ...customViemChains].reduce((acc, chainData) => {
|
|
10738
10716
|
return chainData.id ? {
|
|
10739
10717
|
...acc,
|
|
@@ -12677,6 +12655,11 @@ var checkEIP2612PermitSupport = async ({
|
|
|
12677
12655
|
address,
|
|
12678
12656
|
abi: erc20PermitAbi,
|
|
12679
12657
|
functionName: erc20Functions.name
|
|
12658
|
+
},
|
|
12659
|
+
{
|
|
12660
|
+
address,
|
|
12661
|
+
abi: erc20PermitAbi,
|
|
12662
|
+
functionName: erc20PermitFunctions.PERMIT_TYPEHASH
|
|
12680
12663
|
}
|
|
12681
12664
|
];
|
|
12682
12665
|
const multicallResult = await multicall({
|
|
@@ -12689,13 +12672,17 @@ var checkEIP2612PermitSupport = async ({
|
|
|
12689
12672
|
return { supportsPermit: false };
|
|
12690
12673
|
}
|
|
12691
12674
|
const results = multicallResult.data;
|
|
12692
|
-
const [domainSeparatorResult, nonceResult, versionResult, nameResult] = results;
|
|
12693
|
-
if (domainSeparatorResult.status !== "success" /* success */ || nonceResult.status !== "success" /* success */ || nameResult.status !== "success" /* success */) {
|
|
12675
|
+
const [domainSeparatorResult, nonceResult, versionResult, nameResult, permitTypeHashResult] = results;
|
|
12676
|
+
if (domainSeparatorResult.status !== "success" /* success */ || nonceResult.status !== "success" /* success */ || nameResult.status !== "success" /* success */ || permitTypeHashResult.status !== "success" /* success */) {
|
|
12694
12677
|
return { supportsPermit: false };
|
|
12695
12678
|
}
|
|
12696
12679
|
const name = nameResult.result;
|
|
12697
12680
|
const nonce = nonceResult.result;
|
|
12698
12681
|
const version = versionResult.status === "success" /* success */ ? versionResult.result : DEFAULT_PERMIT_VERSION;
|
|
12682
|
+
const permitTypeHash = permitTypeHashResult.result;
|
|
12683
|
+
if (permitTypeHash.toLowerCase() !== EIP2612_PERMIT_TYPEHASH.toLowerCase()) {
|
|
12684
|
+
return { supportsPermit: false };
|
|
12685
|
+
}
|
|
12699
12686
|
return {
|
|
12700
12687
|
supportsPermit: true,
|
|
12701
12688
|
data: {
|
|
@@ -12783,8 +12770,7 @@ var exclusiveChainIds = {
|
|
|
12783
12770
|
lens: 232,
|
|
12784
12771
|
citreaTestnet: 5115,
|
|
12785
12772
|
hyperLiquid: 998,
|
|
12786
|
-
pushTestnet: 42101
|
|
12787
|
-
astralisTestnet: 71261
|
|
12773
|
+
pushTestnet: 42101
|
|
12788
12774
|
};
|
|
12789
12775
|
|
|
12790
12776
|
// src/constants/contract.ts
|
|
@@ -12800,8 +12786,7 @@ var exclusivePermit2Addresses = {
|
|
|
12800
12786
|
[exclusiveChainIds.bahamut]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5",
|
|
12801
12787
|
[exclusiveChainIds.pushTestnet]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5",
|
|
12802
12788
|
[exclusiveChainIds.abstract]: "0x0000000000225e31D15943971F47aD3022F714Fa",
|
|
12803
|
-
[exclusiveChainIds.lens]: "0x0000000000225e31D15943971F47aD3022F714Fa"
|
|
12804
|
-
[exclusiveChainIds.astralisTestnet]: "0x08208a5f56696E7AA3eAF7a307fa63B37bd8e8A5"
|
|
12789
|
+
[exclusiveChainIds.lens]: "0x0000000000225e31D15943971F47aD3022F714Fa"
|
|
12805
12790
|
};
|
|
12806
12791
|
var DEFAULT_PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
12807
12792
|
|
|
@@ -14496,11 +14481,12 @@ var getAllowance = async ({ chainId, sender, tokens, rpcUrls, multicallAddress,
|
|
|
14496
14481
|
token: address,
|
|
14497
14482
|
spender,
|
|
14498
14483
|
amount,
|
|
14484
|
+
isEIP2612PermitSupported: false,
|
|
14499
14485
|
isDefaultApprovalMode: true
|
|
14500
14486
|
};
|
|
14501
14487
|
} else {
|
|
14502
14488
|
const permit2Address = getPermit2Address(chainId);
|
|
14503
|
-
return { token: address, spender: permit2Address, amount, isDefaultApprovalMode: false };
|
|
14489
|
+
return { token: address, spender: permit2Address, amount, isEIP2612PermitSupported: false, isDefaultApprovalMode: false };
|
|
14504
14490
|
}
|
|
14505
14491
|
})
|
|
14506
14492
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dzapio/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.19",
|
|
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",
|