@shapeshiftoss/contracts 1.0.6 → 1.0.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/LICENSE.md +21 -0
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/abis/index.d.ts +0 -5
- package/dist/cjs/abis/index.js +0 -5
- package/dist/cjs/constants.d.ts +0 -1
- package/dist/cjs/constants.js +1 -5
- package/dist/cjs/ethersProviderSingleton.js +41 -32
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/publicRpcUrls.d.ts +37 -0
- package/dist/cjs/publicRpcUrls.js +101 -0
- package/dist/cjs/viemClient.d.ts +20973 -4
- package/dist/cjs/viemClient.js +70 -47
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/abis/index.d.ts +0 -5
- package/dist/esm/abis/index.js +0 -5
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -4
- package/dist/esm/ethersProviderSingleton.js +41 -32
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/publicRpcUrls.d.ts +37 -0
- package/dist/esm/publicRpcUrls.js +98 -0
- package/dist/esm/viemClient.d.ts +20973 -4
- package/dist/esm/viemClient.js +70 -47
- package/package.json +13 -14
- package/dist/cjs/abis/foxy.d.ts +0 -519
- package/dist/cjs/abis/foxy.js +0 -678
- package/dist/cjs/abis/liquidityReserve.d.ts +0 -421
- package/dist/cjs/abis/liquidityReserve.js +0 -550
- package/dist/cjs/abis/tokeManager.d.ts +0 -774
- package/dist/cjs/abis/tokeManager.js +0 -511
- package/dist/cjs/abis/tokePool.d.ts +0 -502
- package/dist/cjs/abis/tokePool.js +0 -311
- package/dist/cjs/abis/tokeRewardHash.d.ts +0 -112
- package/dist/cjs/abis/tokeRewardHash.js +0 -74
- package/dist/esm/abis/foxy.d.ts +0 -519
- package/dist/esm/abis/foxy.js +0 -675
- package/dist/esm/abis/liquidityReserve.d.ts +0 -421
- package/dist/esm/abis/liquidityReserve.js +0 -547
- package/dist/esm/abis/tokeManager.d.ts +0 -774
- package/dist/esm/abis/tokeManager.js +0 -508
- package/dist/esm/abis/tokePool.d.ts +0 -502
- package/dist/esm/abis/tokePool.js +0 -308
- package/dist/esm/abis/tokeRewardHash.d.ts +0 -112
- package/dist/esm/abis/tokeRewardHash.js +0 -71
package/dist/esm/viemClient.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import { createPublicClient, defineChain, fallback, http } from 'viem';
|
|
4
|
-
import { arbitrum, avalanche, base, berachain, blast, bob, bsc, celo, cronos, flowMainnet, gnosis, hemi, hyperEvm, ink, katana, linea, mainnet, mantle, mode, monad, optimism, plasma, plumeMainnet, polygon, scroll, soneium, sonic, story, unichain, worldchain, zksync, } from 'viem/chains';
|
|
4
|
+
import { abstract, arbitrum, avalanche, base, berachain, blast, bob, bsc, celo, cronos, flowMainnet, gnosis, hemi, hyperEvm, ink, katana, linea, mainnet, mantle, mode, monad, optimism, plasma, plumeMainnet, polygon, scroll, sei, soneium, sonic, story, unichain, worldchain, zksync, } from 'viem/chains';
|
|
5
|
+
import { PUBLIC_RPC_URLS } from './publicRpcUrls.js';
|
|
5
6
|
const megaeth = defineChain({
|
|
6
7
|
id: 4326,
|
|
7
8
|
name: 'MegaETH',
|
|
@@ -23,147 +24,160 @@ const megaeth = defineChain({
|
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
export const flowEvmChain = flowMainnet;
|
|
27
|
+
// Builds a viem fallback transport. `privateUrl` is the preferred source (e.g. ShapeShift proxy)
|
|
28
|
+
// and is tried first; `publicUrls` are public endpoints used as backups. Pass `undefined` for
|
|
29
|
+
// `privateUrl` when the chain has no private RPC (second-class chains).
|
|
30
|
+
const createRpcTransport = (privateUrl, publicUrls) => fallback([privateUrl, ...publicUrls].filter(Boolean).map(url => http(url)));
|
|
31
|
+
// First-class EVM chains
|
|
26
32
|
export const viemEthMainnetClient = createPublicClient({
|
|
27
33
|
chain: mainnet,
|
|
28
|
-
transport:
|
|
29
|
-
.filter(Boolean)
|
|
30
|
-
.map(url => http(url))),
|
|
34
|
+
transport: createRpcTransport(process.env.VITE_ETHEREUM_NODE_URL, PUBLIC_RPC_URLS.ethereum),
|
|
31
35
|
});
|
|
32
36
|
export const viemBscClient = createPublicClient({
|
|
33
37
|
chain: bsc,
|
|
34
|
-
transport:
|
|
35
|
-
// https://github.com/DefiLlama/chainlist/blob/83b8cc32ee79c10e0281e1799ebe4cd1696082b7/constants/llamaNodesRpcs.js#L30
|
|
36
|
-
[process.env.VITE_BNBSMARTCHAIN_NODE_URL, 'https://binance.llamarpc.com']
|
|
37
|
-
.filter(Boolean)
|
|
38
|
-
.map(url => http(url))),
|
|
38
|
+
transport: createRpcTransport(process.env.VITE_BNBSMARTCHAIN_NODE_URL, PUBLIC_RPC_URLS.bsc),
|
|
39
39
|
});
|
|
40
40
|
export const viemAvalancheClient = createPublicClient({
|
|
41
41
|
chain: avalanche,
|
|
42
|
-
transport:
|
|
42
|
+
transport: createRpcTransport(process.env.VITE_AVALANCHE_NODE_URL, PUBLIC_RPC_URLS.avalanche),
|
|
43
43
|
});
|
|
44
44
|
export const viemArbitrumClient = createPublicClient({
|
|
45
45
|
chain: arbitrum,
|
|
46
|
-
transport:
|
|
46
|
+
transport: createRpcTransport(process.env.VITE_ARBITRUM_NODE_URL, PUBLIC_RPC_URLS.arbitrum),
|
|
47
47
|
});
|
|
48
48
|
export const viemOptimismClient = createPublicClient({
|
|
49
49
|
chain: optimism,
|
|
50
|
-
transport:
|
|
50
|
+
transport: createRpcTransport(process.env.VITE_OPTIMISM_NODE_URL, PUBLIC_RPC_URLS.optimism),
|
|
51
51
|
});
|
|
52
52
|
export const viemGnosisClient = createPublicClient({
|
|
53
53
|
chain: gnosis,
|
|
54
|
-
transport:
|
|
54
|
+
transport: createRpcTransport(process.env.VITE_GNOSIS_NODE_URL, PUBLIC_RPC_URLS.gnosis),
|
|
55
55
|
});
|
|
56
56
|
export const viemPolygonClient = createPublicClient({
|
|
57
57
|
chain: polygon,
|
|
58
|
-
transport:
|
|
58
|
+
transport: createRpcTransport(process.env.VITE_POLYGON_NODE_URL, PUBLIC_RPC_URLS.polygon),
|
|
59
59
|
});
|
|
60
60
|
export const viemBaseClient = createPublicClient({
|
|
61
61
|
chain: base,
|
|
62
|
-
transport:
|
|
63
|
-
http('https://mainnet.base.org'),
|
|
64
|
-
http('https://base.llamarpc.com'),
|
|
65
|
-
http('https://base.blockpi.network/v1/rpc/public'),
|
|
66
|
-
]),
|
|
62
|
+
transport: createRpcTransport(process.env.VITE_BASE_NODE_URL, PUBLIC_RPC_URLS.base),
|
|
67
63
|
});
|
|
64
|
+
// Second-class EVM chains (public RPCs only)
|
|
68
65
|
export const viemMonadClient = createPublicClient({
|
|
69
66
|
chain: monad,
|
|
70
|
-
transport:
|
|
67
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.monad),
|
|
71
68
|
});
|
|
72
69
|
export const viemHyperEvmClient = createPublicClient({
|
|
73
70
|
chain: hyperEvm,
|
|
74
|
-
transport:
|
|
71
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.hyperEvm),
|
|
75
72
|
});
|
|
76
73
|
export const viemPlasmaClient = createPublicClient({
|
|
77
74
|
chain: plasma,
|
|
78
|
-
transport:
|
|
75
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.plasma),
|
|
79
76
|
});
|
|
80
77
|
export const viemPlumeClient = createPublicClient({
|
|
81
78
|
chain: plumeMainnet,
|
|
82
|
-
transport:
|
|
79
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.plume),
|
|
83
80
|
});
|
|
84
81
|
export const viemMantleClient = createPublicClient({
|
|
85
82
|
chain: mantle,
|
|
86
|
-
transport:
|
|
83
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.mantle),
|
|
87
84
|
});
|
|
88
85
|
export const viemInkClient = createPublicClient({
|
|
89
86
|
chain: ink,
|
|
90
|
-
transport:
|
|
87
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.ink),
|
|
91
88
|
});
|
|
92
89
|
export const viemMegaEthClient = createPublicClient({
|
|
93
90
|
chain: megaeth,
|
|
94
|
-
transport:
|
|
91
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.megaEth),
|
|
95
92
|
});
|
|
96
93
|
export const viemBerachainClient = createPublicClient({
|
|
97
94
|
chain: berachain,
|
|
98
|
-
transport:
|
|
95
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.berachain),
|
|
99
96
|
});
|
|
100
97
|
export const viemScrollClient = createPublicClient({
|
|
101
98
|
chain: scroll,
|
|
102
|
-
transport:
|
|
99
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.scroll),
|
|
103
100
|
});
|
|
104
101
|
export const viemCronosClient = createPublicClient({
|
|
105
102
|
chain: cronos,
|
|
106
|
-
transport:
|
|
103
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.cronos),
|
|
107
104
|
});
|
|
108
105
|
export const viemFlowEvmClient = createPublicClient({
|
|
109
106
|
chain: flowMainnet,
|
|
110
|
-
transport:
|
|
111
|
-
.filter(Boolean)
|
|
112
|
-
.map(url => http(url))),
|
|
107
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.flowEvm),
|
|
113
108
|
});
|
|
114
109
|
export const viemCeloClient = createPublicClient({
|
|
115
110
|
chain: celo,
|
|
116
|
-
transport:
|
|
117
|
-
.filter(Boolean)
|
|
118
|
-
.map(url => http(url))),
|
|
111
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.celo),
|
|
119
112
|
});
|
|
120
113
|
export const viemKatanaClient = createPublicClient({
|
|
121
114
|
chain: katana,
|
|
122
|
-
transport:
|
|
115
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.katana),
|
|
116
|
+
});
|
|
117
|
+
export const ethereal = defineChain({
|
|
118
|
+
id: 5064014,
|
|
119
|
+
name: 'Ethereal',
|
|
120
|
+
nativeCurrency: { name: 'USDe', symbol: 'USDe', decimals: 18 },
|
|
121
|
+
rpcUrls: { default: { http: ['https://rpc.ethereal.trade'] } },
|
|
122
|
+
blockExplorers: {
|
|
123
|
+
default: { name: 'Ethereal Explorer', url: 'https://explorer.ethereal.global' },
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
export const viemEtherealClient = createPublicClient({
|
|
127
|
+
chain: ethereal,
|
|
128
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.ethereal),
|
|
123
129
|
});
|
|
124
130
|
export const viemStoryClient = createPublicClient({
|
|
125
131
|
chain: story,
|
|
126
|
-
transport:
|
|
132
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.story),
|
|
127
133
|
});
|
|
128
134
|
export const viemZkSyncEraClient = createPublicClient({
|
|
129
135
|
chain: zksync,
|
|
130
|
-
transport:
|
|
136
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.zkSyncEra),
|
|
131
137
|
});
|
|
132
138
|
export const viemBlastClient = createPublicClient({
|
|
133
139
|
chain: blast,
|
|
134
|
-
transport:
|
|
140
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.blast),
|
|
135
141
|
});
|
|
136
142
|
export const viemWorldChainClient = createPublicClient({
|
|
137
143
|
chain: worldchain,
|
|
138
|
-
transport:
|
|
144
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.worldChain),
|
|
139
145
|
});
|
|
140
146
|
export const viemHemiClient = createPublicClient({
|
|
141
147
|
chain: hemi,
|
|
142
|
-
transport:
|
|
148
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.hemi),
|
|
149
|
+
});
|
|
150
|
+
export const viemSeiClient = createPublicClient({
|
|
151
|
+
chain: sei,
|
|
152
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.sei),
|
|
153
|
+
});
|
|
154
|
+
export const viemAbstractClient = createPublicClient({
|
|
155
|
+
chain: abstract,
|
|
156
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.abstract),
|
|
143
157
|
});
|
|
144
158
|
export const viemLineaClient = createPublicClient({
|
|
145
159
|
chain: linea,
|
|
146
|
-
transport:
|
|
160
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.linea),
|
|
147
161
|
});
|
|
148
162
|
export const viemSonicClient = createPublicClient({
|
|
149
163
|
chain: sonic,
|
|
150
|
-
transport:
|
|
164
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.sonic),
|
|
151
165
|
});
|
|
152
166
|
export const viemUnichainClient = createPublicClient({
|
|
153
167
|
chain: unichain,
|
|
154
|
-
transport:
|
|
168
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.unichain),
|
|
155
169
|
});
|
|
156
170
|
export const viemBobClient = createPublicClient({
|
|
157
171
|
chain: bob,
|
|
158
|
-
transport:
|
|
172
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.bob),
|
|
159
173
|
});
|
|
160
174
|
export const viemModeClient = createPublicClient({
|
|
161
175
|
chain: mode,
|
|
162
|
-
transport:
|
|
176
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.mode),
|
|
163
177
|
});
|
|
164
178
|
export const viemSoneiumClient = createPublicClient({
|
|
165
179
|
chain: soneium,
|
|
166
|
-
transport:
|
|
180
|
+
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.soneium),
|
|
167
181
|
});
|
|
168
182
|
export const viemClientByChainId = {
|
|
169
183
|
[KnownChainIds.EthereumMainnet]: viemEthMainnetClient,
|
|
@@ -184,6 +198,7 @@ export const viemClientByChainId = {
|
|
|
184
198
|
[KnownChainIds.BerachainMainnet]: viemBerachainClient,
|
|
185
199
|
[KnownChainIds.CronosMainnet]: viemCronosClient,
|
|
186
200
|
[KnownChainIds.KatanaMainnet]: viemKatanaClient,
|
|
201
|
+
[KnownChainIds.EtherealMainnet]: viemEtherealClient,
|
|
187
202
|
[KnownChainIds.FlowEvmMainnet]: viemFlowEvmClient,
|
|
188
203
|
[KnownChainIds.CeloMainnet]: viemCeloClient,
|
|
189
204
|
[KnownChainIds.StoryMainnet]: viemStoryClient,
|
|
@@ -198,6 +213,8 @@ export const viemClientByChainId = {
|
|
|
198
213
|
[KnownChainIds.BobMainnet]: viemBobClient,
|
|
199
214
|
[KnownChainIds.ModeMainnet]: viemModeClient,
|
|
200
215
|
[KnownChainIds.SoneiumMainnet]: viemSoneiumClient,
|
|
216
|
+
[KnownChainIds.SeiMainnet]: viemSeiClient,
|
|
217
|
+
[KnownChainIds.AbstractMainnet]: viemAbstractClient,
|
|
201
218
|
};
|
|
202
219
|
export const viemNetworkIdByChainId = {
|
|
203
220
|
[KnownChainIds.EthereumMainnet]: mainnet.id,
|
|
@@ -218,6 +235,7 @@ export const viemNetworkIdByChainId = {
|
|
|
218
235
|
[KnownChainIds.BerachainMainnet]: berachain.id,
|
|
219
236
|
[KnownChainIds.CronosMainnet]: cronos.id,
|
|
220
237
|
[KnownChainIds.KatanaMainnet]: katana.id,
|
|
238
|
+
[KnownChainIds.EtherealMainnet]: ethereal.id,
|
|
221
239
|
[KnownChainIds.FlowEvmMainnet]: flowMainnet.id,
|
|
222
240
|
[KnownChainIds.CeloMainnet]: celo.id,
|
|
223
241
|
[KnownChainIds.StoryMainnet]: story.id,
|
|
@@ -232,6 +250,8 @@ export const viemNetworkIdByChainId = {
|
|
|
232
250
|
[KnownChainIds.BobMainnet]: bob.id,
|
|
233
251
|
[KnownChainIds.ModeMainnet]: mode.id,
|
|
234
252
|
[KnownChainIds.SoneiumMainnet]: soneium.id,
|
|
253
|
+
[KnownChainIds.SeiMainnet]: sei.id,
|
|
254
|
+
[KnownChainIds.AbstractMainnet]: abstract.id,
|
|
235
255
|
};
|
|
236
256
|
export const viemClientByNetworkId = {
|
|
237
257
|
[mainnet.id]: viemEthMainnetClient,
|
|
@@ -252,6 +272,7 @@ export const viemClientByNetworkId = {
|
|
|
252
272
|
[berachain.id]: viemBerachainClient,
|
|
253
273
|
[cronos.id]: viemCronosClient,
|
|
254
274
|
[katana.id]: viemKatanaClient,
|
|
275
|
+
[ethereal.id]: viemEtherealClient,
|
|
255
276
|
[flowMainnet.id]: viemFlowEvmClient,
|
|
256
277
|
[celo.id]: viemCeloClient,
|
|
257
278
|
[story.id]: viemStoryClient,
|
|
@@ -266,6 +287,8 @@ export const viemClientByNetworkId = {
|
|
|
266
287
|
[bob.id]: viemBobClient,
|
|
267
288
|
[mode.id]: viemModeClient,
|
|
268
289
|
[soneium.id]: viemSoneiumClient,
|
|
290
|
+
[sei.id]: viemSeiClient,
|
|
291
|
+
[abstract.id]: viemAbstractClient,
|
|
269
292
|
};
|
|
270
293
|
export const assertGetViemClient = (chainId) => {
|
|
271
294
|
const publicClient = viemClientByChainId[chainId];
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/contracts",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"packageManager": "yarn@3.5.0",
|
|
3
|
+
"version": "1.0.7",
|
|
5
4
|
"repository": "https://github.com/shapeshift/web",
|
|
6
5
|
"license": "MIT",
|
|
7
6
|
"type": "module",
|
|
@@ -21,25 +20,25 @@
|
|
|
21
20
|
"publishConfig": {
|
|
22
21
|
"access": "public"
|
|
23
22
|
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "yarn clean && yarn run -T tsc --build && yarn postbuild",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"dev": "yarn run -T tsc --build --watch",
|
|
28
|
-
"postbuild": "yarn postbuild:esm && yarn postbuild:cjs",
|
|
29
|
-
"postbuild:esm": "yarn run -T tsc-esm-fix --target=dist/esm --ext=.js",
|
|
30
|
-
"postbuild:cjs": "echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json"
|
|
31
|
-
},
|
|
32
23
|
"dependencies": {
|
|
33
|
-
"@shapeshiftoss/caip": "^8.16.8",
|
|
34
|
-
"@shapeshiftoss/types": "^8.6.7",
|
|
35
|
-
"@shapeshiftoss/utils": "^1.0.6",
|
|
36
24
|
"@uniswap/sdk": "^3.0.3",
|
|
37
25
|
"ethers": "6.11.1",
|
|
38
26
|
"ethers5": "npm:ethers@5.7.2",
|
|
39
27
|
"lodash": "^4.17.23",
|
|
40
|
-
"viem": "2.43.5"
|
|
28
|
+
"viem": "2.43.5",
|
|
29
|
+
"@shapeshiftoss/caip": "^8.16.9",
|
|
30
|
+
"@shapeshiftoss/utils": "^1.1.0",
|
|
31
|
+
"@shapeshiftoss/types": "^8.6.8"
|
|
41
32
|
},
|
|
42
33
|
"devDependencies": {
|
|
43
34
|
"@types/lodash": "^4.14.178"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "rm -rf dist && pnpm exec tsc --build && pnpm run postbuild",
|
|
38
|
+
"clean": "rm -rf dist node_modules",
|
|
39
|
+
"dev": "pnpm exec tsc --build --watch",
|
|
40
|
+
"postbuild": "pnpm run postbuild:esm && pnpm run postbuild:cjs",
|
|
41
|
+
"postbuild:esm": "pnpm exec tsc-esm-fix --target=dist/esm --ext=.js",
|
|
42
|
+
"postbuild:cjs": "echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json"
|
|
44
43
|
}
|
|
45
44
|
}
|