@shapeshiftoss/contracts 1.1.0 → 2.0.0
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/constants.d.ts +0 -6596
- package/dist/cjs/constants.js +1 -31
- package/dist/cjs/contractManager.d.ts +8 -11
- package/dist/cjs/contractManager.js +38 -63
- package/dist/cjs/ethersProviderSingleton.d.ts +0 -3
- package/dist/cjs/ethersProviderSingleton.js +2 -23
- package/dist/cjs/types.d.ts +1 -18
- package/dist/cjs/types.js +0 -7
- package/dist/cjs/viemClient.d.ts +6414 -6418
- package/dist/cjs/viemClient.js +48 -147
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/constants.d.ts +0 -6596
- package/dist/esm/constants.js +0 -30
- package/dist/esm/contractManager.d.ts +8 -11
- package/dist/esm/contractManager.js +39 -65
- package/dist/esm/ethersProviderSingleton.d.ts +0 -3
- package/dist/esm/ethersProviderSingleton.js +1 -20
- package/dist/esm/types.d.ts +1 -18
- package/dist/esm/types.js +1 -6
- package/dist/esm/viemClient.d.ts +6414 -6418
- package/dist/esm/viemClient.js +47 -146
- package/package.json +4 -5
package/dist/esm/viemClient.js
CHANGED
|
@@ -1,98 +1,42 @@
|
|
|
1
1
|
import { KnownChainIds } from '@shapeshiftoss/types';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import { createPublicClient, defineChain, fallback, http } from 'viem';
|
|
4
|
-
import { abstract, arbitrum, avalanche, base, berachain, blast, bob, bsc, celo, cronos, flowMainnet, gnosis, hemi, hyperEvm, ink, katana, linea, mainnet, mantle, megaeth, mode, monad, optimism, plasma, plumeMainnet, polygon, robinhood, scroll, sei, soneium, sonic, story, unichain, worldchain, zksync, } from 'viem/chains';
|
|
4
|
+
import { abstract, arbitrum, avalanche, base, berachain, blast, bob, bsc, celo, cronos, flowMainnet, gnosis, hemi as viemHemi, hyperEvm, ink, katana, linea, mainnet, mantle, megaeth, mode, monad, optimism, plasma, plumeMainnet, polygon, robinhood, scroll, sei, soneium, sonic, story, unichain, worldchain, zksync, } from 'viem/chains';
|
|
5
5
|
import { PUBLIC_RPC_URLS } from './publicRpcUrls.js';
|
|
6
6
|
// Builds a viem fallback transport. `privateUrl` is the preferred source (e.g. ShapeShift proxy)
|
|
7
7
|
// and is tried first; `publicUrls` are public endpoints used as backups. Pass `undefined` for
|
|
8
8
|
// `privateUrl` when the chain has no private RPC (second-class chains).
|
|
9
9
|
const createRpcTransport = (privateUrl, publicUrls) => fallback([privateUrl, ...publicUrls].filter(Boolean).map(url => http(url)));
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
chain
|
|
13
|
-
transport: createRpcTransport(
|
|
14
|
-
}
|
|
15
|
-
export const viemBscClient = createPublicClient({
|
|
16
|
-
chain: bsc,
|
|
17
|
-
transport: createRpcTransport(process.env.VITE_BNBSMARTCHAIN_NODE_URL, PUBLIC_RPC_URLS.bsc),
|
|
18
|
-
});
|
|
19
|
-
export const viemAvalancheClient = createPublicClient({
|
|
20
|
-
chain: avalanche,
|
|
21
|
-
transport: createRpcTransport(process.env.VITE_AVALANCHE_NODE_URL, PUBLIC_RPC_URLS.avalanche),
|
|
22
|
-
});
|
|
23
|
-
export const viemArbitrumClient = createPublicClient({
|
|
24
|
-
chain: arbitrum,
|
|
25
|
-
transport: createRpcTransport(process.env.VITE_ARBITRUM_NODE_URL, PUBLIC_RPC_URLS.arbitrum),
|
|
26
|
-
});
|
|
27
|
-
export const viemOptimismClient = createPublicClient({
|
|
28
|
-
chain: optimism,
|
|
29
|
-
transport: createRpcTransport(process.env.VITE_OPTIMISM_NODE_URL, PUBLIC_RPC_URLS.optimism),
|
|
30
|
-
});
|
|
31
|
-
export const viemGnosisClient = createPublicClient({
|
|
32
|
-
chain: gnosis,
|
|
33
|
-
transport: createRpcTransport(process.env.VITE_GNOSIS_NODE_URL, PUBLIC_RPC_URLS.gnosis),
|
|
34
|
-
});
|
|
35
|
-
export const viemPolygonClient = createPublicClient({
|
|
36
|
-
chain: polygon,
|
|
37
|
-
transport: createRpcTransport(process.env.VITE_POLYGON_NODE_URL, PUBLIC_RPC_URLS.polygon),
|
|
38
|
-
});
|
|
39
|
-
export const viemBaseClient = createPublicClient({
|
|
40
|
-
chain: base,
|
|
41
|
-
transport: createRpcTransport(process.env.VITE_BASE_NODE_URL, PUBLIC_RPC_URLS.base),
|
|
10
|
+
// Same-tick contract reads are batched into one multicall3 call
|
|
11
|
+
const createRpcClient = (chain, privateUrl, publicUrls) => createPublicClient({
|
|
12
|
+
chain,
|
|
13
|
+
transport: createRpcTransport(privateUrl, publicUrls),
|
|
14
|
+
batch: { multicall: true },
|
|
42
15
|
});
|
|
16
|
+
const multicall3 = { address: '0xcA11bde05977b3631167028862bE2a173976CA11' };
|
|
17
|
+
// First-class EVM chains
|
|
18
|
+
export const viemEthMainnetClient = createRpcClient(mainnet, process.env.VITE_ETHEREUM_NODE_URL, PUBLIC_RPC_URLS.ethereum);
|
|
19
|
+
export const viemBscClient = createRpcClient(bsc, process.env.VITE_BNBSMARTCHAIN_NODE_URL, PUBLIC_RPC_URLS.bsc);
|
|
20
|
+
export const viemAvalancheClient = createRpcClient(avalanche, process.env.VITE_AVALANCHE_NODE_URL, PUBLIC_RPC_URLS.avalanche);
|
|
21
|
+
export const viemArbitrumClient = createRpcClient(arbitrum, process.env.VITE_ARBITRUM_NODE_URL, PUBLIC_RPC_URLS.arbitrum);
|
|
22
|
+
export const viemOptimismClient = createRpcClient(optimism, process.env.VITE_OPTIMISM_NODE_URL, PUBLIC_RPC_URLS.optimism);
|
|
23
|
+
export const viemGnosisClient = createRpcClient(gnosis, process.env.VITE_GNOSIS_NODE_URL, PUBLIC_RPC_URLS.gnosis);
|
|
24
|
+
export const viemPolygonClient = createRpcClient(polygon, process.env.VITE_POLYGON_NODE_URL, PUBLIC_RPC_URLS.polygon);
|
|
25
|
+
export const viemBaseClient = createRpcClient(base, process.env.VITE_BASE_NODE_URL, PUBLIC_RPC_URLS.base);
|
|
43
26
|
// Second-class EVM chains (public RPCs only)
|
|
44
|
-
export const viemMonadClient =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export const
|
|
57
|
-
chain: plumeMainnet,
|
|
58
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.plume),
|
|
59
|
-
});
|
|
60
|
-
export const viemMantleClient = createPublicClient({
|
|
61
|
-
chain: mantle,
|
|
62
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.mantle),
|
|
63
|
-
});
|
|
64
|
-
export const viemInkClient = createPublicClient({
|
|
65
|
-
chain: ink,
|
|
66
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.ink),
|
|
67
|
-
});
|
|
68
|
-
export const viemMegaEthClient = createPublicClient({
|
|
69
|
-
chain: megaeth,
|
|
70
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.megaEth),
|
|
71
|
-
});
|
|
72
|
-
export const viemBerachainClient = createPublicClient({
|
|
73
|
-
chain: berachain,
|
|
74
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.berachain),
|
|
75
|
-
});
|
|
76
|
-
export const viemScrollClient = createPublicClient({
|
|
77
|
-
chain: scroll,
|
|
78
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.scroll),
|
|
79
|
-
});
|
|
80
|
-
export const viemCronosClient = createPublicClient({
|
|
81
|
-
chain: cronos,
|
|
82
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.cronos),
|
|
83
|
-
});
|
|
84
|
-
export const viemFlowEvmClient = createPublicClient({
|
|
85
|
-
chain: flowMainnet,
|
|
86
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.flowEvm),
|
|
87
|
-
});
|
|
88
|
-
export const viemCeloClient = createPublicClient({
|
|
89
|
-
chain: celo,
|
|
90
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.celo),
|
|
91
|
-
});
|
|
92
|
-
export const viemKatanaClient = createPublicClient({
|
|
93
|
-
chain: katana,
|
|
94
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.katana),
|
|
95
|
-
});
|
|
27
|
+
export const viemMonadClient = createRpcClient(monad, undefined, PUBLIC_RPC_URLS.monad);
|
|
28
|
+
export const viemHyperEvmClient = createRpcClient(hyperEvm, undefined, PUBLIC_RPC_URLS.hyperEvm);
|
|
29
|
+
export const viemPlasmaClient = createRpcClient(plasma, undefined, PUBLIC_RPC_URLS.plasma);
|
|
30
|
+
export const viemPlumeClient = createRpcClient(plumeMainnet, undefined, PUBLIC_RPC_URLS.plume);
|
|
31
|
+
export const viemMantleClient = createRpcClient(mantle, undefined, PUBLIC_RPC_URLS.mantle);
|
|
32
|
+
export const viemInkClient = createRpcClient(ink, undefined, PUBLIC_RPC_URLS.ink);
|
|
33
|
+
export const viemMegaEthClient = createRpcClient(megaeth, undefined, PUBLIC_RPC_URLS.megaEth);
|
|
34
|
+
export const viemBerachainClient = createRpcClient(berachain, undefined, PUBLIC_RPC_URLS.berachain);
|
|
35
|
+
export const viemScrollClient = createRpcClient(scroll, undefined, PUBLIC_RPC_URLS.scroll);
|
|
36
|
+
export const viemCronosClient = createRpcClient(cronos, undefined, PUBLIC_RPC_URLS.cronos);
|
|
37
|
+
export const viemFlowEvmClient = createRpcClient(flowMainnet, undefined, PUBLIC_RPC_URLS.flowEvm);
|
|
38
|
+
export const viemCeloClient = createRpcClient(celo, undefined, PUBLIC_RPC_URLS.celo);
|
|
39
|
+
export const viemKatanaClient = createRpcClient(katana, undefined, PUBLIC_RPC_URLS.katana);
|
|
96
40
|
export const ethereal = defineChain({
|
|
97
41
|
id: 5064014,
|
|
98
42
|
name: 'Ethereal',
|
|
@@ -101,67 +45,24 @@ export const ethereal = defineChain({
|
|
|
101
45
|
blockExplorers: {
|
|
102
46
|
default: { name: 'Ethereal Explorer', url: 'https://explorer.ethereal.global' },
|
|
103
47
|
},
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
export const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
export const
|
|
122
|
-
chain: worldchain,
|
|
123
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.worldChain),
|
|
124
|
-
});
|
|
125
|
-
export const viemHemiClient = createPublicClient({
|
|
126
|
-
chain: hemi,
|
|
127
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.hemi),
|
|
128
|
-
});
|
|
129
|
-
export const viemSeiClient = createPublicClient({
|
|
130
|
-
chain: sei,
|
|
131
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.sei),
|
|
132
|
-
});
|
|
133
|
-
export const viemAbstractClient = createPublicClient({
|
|
134
|
-
chain: abstract,
|
|
135
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.abstract),
|
|
136
|
-
});
|
|
137
|
-
export const viemLineaClient = createPublicClient({
|
|
138
|
-
chain: linea,
|
|
139
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.linea),
|
|
140
|
-
});
|
|
141
|
-
export const viemSonicClient = createPublicClient({
|
|
142
|
-
chain: sonic,
|
|
143
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.sonic),
|
|
144
|
-
});
|
|
145
|
-
export const viemUnichainClient = createPublicClient({
|
|
146
|
-
chain: unichain,
|
|
147
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.unichain),
|
|
148
|
-
});
|
|
149
|
-
export const viemBobClient = createPublicClient({
|
|
150
|
-
chain: bob,
|
|
151
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.bob),
|
|
152
|
-
});
|
|
153
|
-
export const viemModeClient = createPublicClient({
|
|
154
|
-
chain: mode,
|
|
155
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.mode),
|
|
156
|
-
});
|
|
157
|
-
export const viemSoneiumClient = createPublicClient({
|
|
158
|
-
chain: soneium,
|
|
159
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.soneium),
|
|
160
|
-
});
|
|
161
|
-
export const viemRobinhoodClient = createPublicClient({
|
|
162
|
-
chain: robinhood,
|
|
163
|
-
transport: createRpcTransport(undefined, PUBLIC_RPC_URLS.robinhood),
|
|
164
|
-
});
|
|
48
|
+
contracts: { multicall3 },
|
|
49
|
+
});
|
|
50
|
+
export const viemEtherealClient = createRpcClient(ethereal, undefined, PUBLIC_RPC_URLS.ethereal);
|
|
51
|
+
export const viemStoryClient = createRpcClient(story, undefined, PUBLIC_RPC_URLS.story);
|
|
52
|
+
export const viemZkSyncEraClient = createRpcClient(zksync, undefined, PUBLIC_RPC_URLS.zkSyncEra);
|
|
53
|
+
export const viemBlastClient = createRpcClient(blast, undefined, PUBLIC_RPC_URLS.blast);
|
|
54
|
+
export const viemWorldChainClient = createRpcClient(worldchain, undefined, PUBLIC_RPC_URLS.worldChain);
|
|
55
|
+
const hemi = defineChain({ ...viemHemi, contracts: { multicall3 } });
|
|
56
|
+
export const viemHemiClient = createRpcClient(hemi, undefined, PUBLIC_RPC_URLS.hemi);
|
|
57
|
+
export const viemSeiClient = createRpcClient(sei, undefined, PUBLIC_RPC_URLS.sei);
|
|
58
|
+
export const viemAbstractClient = createRpcClient(abstract, undefined, PUBLIC_RPC_URLS.abstract);
|
|
59
|
+
export const viemLineaClient = createRpcClient(linea, undefined, PUBLIC_RPC_URLS.linea);
|
|
60
|
+
export const viemSonicClient = createRpcClient(sonic, undefined, PUBLIC_RPC_URLS.sonic);
|
|
61
|
+
export const viemUnichainClient = createRpcClient(unichain, undefined, PUBLIC_RPC_URLS.unichain);
|
|
62
|
+
export const viemBobClient = createRpcClient(bob, undefined, PUBLIC_RPC_URLS.bob);
|
|
63
|
+
export const viemModeClient = createRpcClient(mode, undefined, PUBLIC_RPC_URLS.mode);
|
|
64
|
+
export const viemSoneiumClient = createRpcClient(soneium, undefined, PUBLIC_RPC_URLS.soneium);
|
|
65
|
+
export const viemRobinhoodClient = createRpcClient(robinhood, undefined, PUBLIC_RPC_URLS.robinhood);
|
|
165
66
|
export const viemClientByChainId = {
|
|
166
67
|
[KnownChainIds.EthereumMainnet]: viemEthMainnetClient,
|
|
167
68
|
[KnownChainIds.BnbSmartChainMainnet]: viemBscClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/contracts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"repository": "https://github.com/shapeshift/web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@uniswap/sdk": "^3.0.3",
|
|
25
|
-
"ethers": "6.11.1",
|
|
26
25
|
"ethers5": "npm:ethers@5.7.2",
|
|
27
26
|
"lodash": "^4.17.23",
|
|
28
27
|
"viem": "2.55.11",
|
|
29
|
-
"@shapeshiftoss/
|
|
30
|
-
"@shapeshiftoss/types": "^9.
|
|
31
|
-
"@shapeshiftoss/
|
|
28
|
+
"@shapeshiftoss/utils": "^2.0.0",
|
|
29
|
+
"@shapeshiftoss/types": "^9.2.0",
|
|
30
|
+
"@shapeshiftoss/caip": "^8.18.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@types/lodash": "^4.14.178"
|