@xswap-link/sdk 0.11.0 → 0.11.2
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/.github/workflows/publish.yml +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.global.js +3845 -3559
- package/dist/index.js +62 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config/wagmiConfig.ts +34 -2
- package/src/contracts/addresses.ts +16 -0
- package/src/models/payloads/GetRoutePayload.ts +5 -8
- package/src/utils/parseWeb3Error.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chain } from "@src/models";
|
|
2
2
|
import { isServer } from "@src/utils";
|
|
3
|
-
import { Transport } from "viem";
|
|
3
|
+
import { defineChain, Transport } from "viem";
|
|
4
4
|
import * as WagmiChains from "viem/chains";
|
|
5
5
|
import { mainnet } from "viem/chains";
|
|
6
6
|
import { Config, createConfig, createStorage, http } from "@wagmi/core";
|
|
@@ -38,7 +38,39 @@ const mapChains = (
|
|
|
38
38
|
supportedChains.some(({ chainId }) => chainId === chain.id.toString()),
|
|
39
39
|
),
|
|
40
40
|
);
|
|
41
|
-
|
|
41
|
+
for (const s of supportedChains) {
|
|
42
|
+
if (s.ecosystem !== "evm") continue;
|
|
43
|
+
const id = Number(s.chainId);
|
|
44
|
+
const exists = result.some((c) => c.id === id);
|
|
45
|
+
if (!exists) {
|
|
46
|
+
const custom = defineChain({
|
|
47
|
+
id,
|
|
48
|
+
name: s.name,
|
|
49
|
+
nativeCurrency: {
|
|
50
|
+
name: s.tokenSymbol,
|
|
51
|
+
symbol: s.tokenSymbol,
|
|
52
|
+
decimals: 18,
|
|
53
|
+
},
|
|
54
|
+
rpcUrls: {
|
|
55
|
+
default: { http: s.publicRpcUrls },
|
|
56
|
+
},
|
|
57
|
+
blockExplorers: {
|
|
58
|
+
default: {
|
|
59
|
+
name: s.transactionExplorer.match(/\/\/([^.]*)\./)?.[1] || "",
|
|
60
|
+
url: s.transactionExplorer,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
result.push(custom);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const seen = new Set<number>();
|
|
68
|
+
const deduped = result.filter((c) => {
|
|
69
|
+
if (seen.has(c.id)) return false;
|
|
70
|
+
seen.add(c.id);
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
return deduped as [WagmiChains.Chain, ...WagmiChains.Chain[]];
|
|
42
74
|
};
|
|
43
75
|
|
|
44
76
|
const mapTransports = (
|
|
@@ -179,6 +179,22 @@ export const ADDRESSES: Addresses = {
|
|
|
179
179
|
[ContractName.XSwapRouterSingleChain]:
|
|
180
180
|
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
181
181
|
},
|
|
182
|
+
// 0G
|
|
183
|
+
"16661": {
|
|
184
|
+
[ContractName.BatchQuery]: "0x73d73d323452505518a898066529c01D4c3eF15b",
|
|
185
|
+
[ContractName.FeeCollector]: "0x01CF9356668e94B4efd16842851a7c805199b3F5",
|
|
186
|
+
[ContractName.XSwapRouter]: "0x543F4Ae34DB4d5d11B564b578a2E79221a48CcC2",
|
|
187
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
188
|
+
"0xf6ce7dbdd78A4589A4526278d3f88bd66E040d0d",
|
|
189
|
+
},
|
|
190
|
+
// plasma
|
|
191
|
+
"9745": {
|
|
192
|
+
[ContractName.BatchQuery]: "0x73d73d323452505518a898066529c01D4c3eF15b",
|
|
193
|
+
[ContractName.FeeCollector]: "0x01CF9356668e94B4efd16842851a7c805199b3F5",
|
|
194
|
+
[ContractName.XSwapRouter]: "0x543F4Ae34DB4d5d11B564b578a2E79221a48CcC2",
|
|
195
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
196
|
+
"0xf6ce7dbdd78A4589A4526278d3f88bd66E040d0d",
|
|
197
|
+
},
|
|
182
198
|
// solana
|
|
183
199
|
"mainnet-beta": {
|
|
184
200
|
[ContractName.FeeCollector]: "XSwapfFzSz84kkGk5PCYzLrntPfLubFRJGbJRQjC7th",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContractCall } from "@src/models";
|
|
2
2
|
|
|
3
3
|
export type GetRoutePayload = {
|
|
4
|
-
integratorId: string;
|
|
5
4
|
fromChain: string;
|
|
6
5
|
toChain: string;
|
|
7
6
|
fromToken: string;
|
|
@@ -10,17 +9,15 @@ export type GetRoutePayload = {
|
|
|
10
9
|
fromAddress: string;
|
|
11
10
|
toAddress: string;
|
|
12
11
|
paymentToken: string;
|
|
12
|
+
integratorId: string;
|
|
13
13
|
slippage: number;
|
|
14
14
|
expressDelivery: boolean;
|
|
15
|
-
|
|
16
|
-
enableExpress?: boolean;
|
|
15
|
+
infiniteApproval?: boolean;
|
|
17
16
|
customContractCalls?: ContractCall[];
|
|
18
17
|
sourceChainDexes?: string[];
|
|
19
18
|
destinationChainDexes?: string[];
|
|
20
|
-
receiveGasOnDestination?: boolean;
|
|
21
|
-
collectFees?: CollectFees;
|
|
22
|
-
fallbackAddresses?: CoinTypeAddress[];
|
|
23
|
-
infiniteApproval: boolean;
|
|
24
19
|
integratorFee?: number;
|
|
25
20
|
integratorFeeReceiverAddress?: string;
|
|
21
|
+
gasLimit?: number;
|
|
22
|
+
swapRouteProviders?: string[];
|
|
26
23
|
};
|
|
@@ -88,7 +88,7 @@ export function parseWeb3Error(error: any): string {
|
|
|
88
88
|
case ethers.errors.UNPREDICTABLE_GAS_LIMIT:
|
|
89
89
|
return "Unable to estimate gas limit. The transaction might fail.";
|
|
90
90
|
default:
|
|
91
|
-
return "An error occurred
|
|
91
|
+
return "An unexpected error occurred.";
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|