@vleap/warps-adapter-evm 0.2.0-alpha.9 → 0.2.0-beta.43
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.cts +261 -0
- package/dist/index.d.ts +150 -29
- package/dist/index.js +913 -475
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +906 -458
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -10
- package/dist/index.d.mts +0 -140
package/dist/index.mjs
CHANGED
|
@@ -1,104 +1,297 @@
|
|
|
1
|
+
// src/chains/arbitrum.ts
|
|
2
|
+
import { WarpChainName as WarpChainName6 } from "@vleap/warps";
|
|
3
|
+
|
|
1
4
|
// src/WarpEvmDataLoader.ts
|
|
5
|
+
import {
|
|
6
|
+
CacheTtl as CacheTtl2,
|
|
7
|
+
getProviderConfig,
|
|
8
|
+
WarpCache as WarpCache2,
|
|
9
|
+
WarpCacheKey
|
|
10
|
+
} from "@vleap/warps";
|
|
2
11
|
import { ethers } from "ethers";
|
|
3
12
|
|
|
4
|
-
// src/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
blockTime: 12e3
|
|
22
|
-
},
|
|
23
|
-
devnet: {
|
|
24
|
-
apiUrl: "http://localhost:8545",
|
|
25
|
-
explorerUrl: "http://localhost:4000",
|
|
26
|
-
chainId: "1337",
|
|
27
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
28
|
-
nativeToken: "ETH",
|
|
29
|
-
blockTime: 12e3
|
|
13
|
+
// src/providers/UniswapService.ts
|
|
14
|
+
import { CacheTtl } from "@vleap/warps";
|
|
15
|
+
var _UniswapService = class _UniswapService {
|
|
16
|
+
constructor(cache, chainId) {
|
|
17
|
+
this.cache = cache;
|
|
18
|
+
this.chainId = chainId;
|
|
19
|
+
}
|
|
20
|
+
async getTokenList() {
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(_UniswapService.UNISWAP_TOKEN_LIST_URL);
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`Failed to fetch Uniswap token list: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
const tokenList = await response.json();
|
|
27
|
+
return tokenList;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(`Failed to fetch Uniswap token list: ${error}`);
|
|
30
30
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
nativeToken: "ETH",
|
|
39
|
-
blockTime: 1e3
|
|
40
|
-
},
|
|
41
|
-
testnet: {
|
|
42
|
-
apiUrl: "https://arb-sepolia.g.alchemy.com/v2/demo",
|
|
43
|
-
explorerUrl: "https://sepolia.arbiscan.io",
|
|
44
|
-
chainId: "421614",
|
|
45
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
46
|
-
nativeToken: "ETH",
|
|
47
|
-
blockTime: 1e3
|
|
48
|
-
},
|
|
49
|
-
devnet: {
|
|
50
|
-
apiUrl: "http://localhost:8545",
|
|
51
|
-
explorerUrl: "http://localhost:4000",
|
|
52
|
-
chainId: "1337",
|
|
53
|
-
registryAddress: "0x0000000000000000000000000000000000000000",
|
|
54
|
-
nativeToken: "ETH",
|
|
55
|
-
blockTime: 1e3
|
|
31
|
+
}
|
|
32
|
+
async findToken(address) {
|
|
33
|
+
const normalizedAddress = address.toLowerCase();
|
|
34
|
+
const cacheKey = `uniswap:token:${this.chainId}:${normalizedAddress}`;
|
|
35
|
+
const cachedToken = this.cache.get(cacheKey);
|
|
36
|
+
if (cachedToken) {
|
|
37
|
+
return cachedToken;
|
|
56
38
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
39
|
+
try {
|
|
40
|
+
const tokenList = await this.getTokenList();
|
|
41
|
+
const token = tokenList.tokens.find((token2) => token2.address.toLowerCase() === normalizedAddress) || null;
|
|
42
|
+
if (token && token.chainId !== this.chainId) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (token) {
|
|
46
|
+
this.cache.set(cacheKey, token, CacheTtl.OneHour);
|
|
47
|
+
} else {
|
|
48
|
+
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
49
|
+
}
|
|
50
|
+
return token;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async getTokenMetadata(address) {
|
|
56
|
+
const normalizedAddress = address.toLowerCase();
|
|
57
|
+
const cacheKey = `uniswap:metadata:${this.chainId}:${normalizedAddress}`;
|
|
58
|
+
const cachedMetadata = this.cache.get(cacheKey);
|
|
59
|
+
if (cachedMetadata !== null) {
|
|
60
|
+
return cachedMetadata;
|
|
61
|
+
}
|
|
62
|
+
const token = await this.findToken(address);
|
|
63
|
+
if (!token) {
|
|
64
|
+
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const metadata = {
|
|
68
|
+
name: token.name,
|
|
69
|
+
symbol: token.symbol,
|
|
70
|
+
decimals: token.decimals,
|
|
71
|
+
logoUrl: token.logoURI
|
|
72
|
+
};
|
|
73
|
+
this.cache.set(cacheKey, metadata, CacheTtl.OneHour);
|
|
74
|
+
return metadata;
|
|
75
|
+
}
|
|
76
|
+
async getBridgeInfo(address) {
|
|
77
|
+
const normalizedAddress = address.toLowerCase();
|
|
78
|
+
const cacheKey = `uniswap:bridge:${this.chainId}:${normalizedAddress}`;
|
|
79
|
+
const cachedBridgeInfo = this.cache.get(cacheKey);
|
|
80
|
+
if (cachedBridgeInfo !== null) {
|
|
81
|
+
return cachedBridgeInfo;
|
|
82
|
+
}
|
|
83
|
+
const token = await this.findToken(address);
|
|
84
|
+
if (!token?.extensions?.bridgeInfo) {
|
|
85
|
+
this.cache.set(cacheKey, null, CacheTtl.OneMinute * 5);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const bridgeInfo = {};
|
|
89
|
+
for (const [chainId, info] of Object.entries(token.extensions.bridgeInfo)) {
|
|
90
|
+
bridgeInfo[chainId] = info.tokenAddress;
|
|
82
91
|
}
|
|
92
|
+
this.cache.set(cacheKey, bridgeInfo, CacheTtl.OneHour);
|
|
93
|
+
return bridgeInfo;
|
|
83
94
|
}
|
|
84
95
|
};
|
|
85
|
-
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
_UniswapService.UNISWAP_TOKEN_LIST_URL = "https://tokens.uniswap.org";
|
|
97
|
+
var UniswapService = _UniswapService;
|
|
98
|
+
|
|
99
|
+
// src/tokens/arbitrum.ts
|
|
100
|
+
import { WarpChainName } from "@vleap/warps";
|
|
101
|
+
var ArbitrumChain = WarpChainName.Arbitrum;
|
|
102
|
+
var ArbitrumTokens = [
|
|
103
|
+
{
|
|
104
|
+
chain: ArbitrumChain,
|
|
105
|
+
identifier: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
|
|
106
|
+
name: "USD Coin",
|
|
107
|
+
symbol: "USDC",
|
|
108
|
+
decimals: 6,
|
|
109
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
chain: ArbitrumChain,
|
|
113
|
+
identifier: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
114
|
+
name: "Tether USD",
|
|
115
|
+
symbol: "USDT",
|
|
116
|
+
decimals: 6,
|
|
117
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
chain: ArbitrumChain,
|
|
121
|
+
identifier: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
122
|
+
name: "Wrapped Ether",
|
|
123
|
+
symbol: "WETH",
|
|
124
|
+
decimals: 18,
|
|
125
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
90
126
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
// src/tokens/base.ts
|
|
130
|
+
import { WarpChainName as WarpChainName2 } from "@vleap/warps";
|
|
131
|
+
var BaseChain = WarpChainName2.Base;
|
|
132
|
+
var BaseTokens = [
|
|
133
|
+
{
|
|
134
|
+
chain: BaseChain,
|
|
135
|
+
identifier: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
136
|
+
name: "USD Coin",
|
|
137
|
+
symbol: "USDC",
|
|
138
|
+
decimals: 6,
|
|
139
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
chain: BaseChain,
|
|
143
|
+
identifier: "0x4200000000000000000000000000000000000006",
|
|
144
|
+
name: "Wrapped Ether",
|
|
145
|
+
symbol: "WETH",
|
|
146
|
+
decimals: 18,
|
|
147
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
chain: BaseChain,
|
|
151
|
+
identifier: "0x808456652fdb597867f38412077A9182bf77359F",
|
|
152
|
+
name: "Euro",
|
|
153
|
+
symbol: "EURC",
|
|
154
|
+
decimals: 6,
|
|
155
|
+
logoUrl: "https://assets.coingecko.com/coins/images/26045/standard/euro.png"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
chain: BaseChain,
|
|
159
|
+
identifier: "0xcbB7C0006F23900c38EB856149F799620fcb8A4a",
|
|
160
|
+
name: "Coinbase Wrapped BTC",
|
|
161
|
+
symbol: "CBETH",
|
|
162
|
+
decimals: 8,
|
|
163
|
+
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
// src/tokens/base-sepolia.ts
|
|
168
|
+
import { WarpChainName as WarpChainName3 } from "@vleap/warps";
|
|
169
|
+
var BaseChain2 = WarpChainName3.Base;
|
|
170
|
+
var BaseSepoliaTokens = [
|
|
171
|
+
{
|
|
172
|
+
chain: BaseChain2,
|
|
173
|
+
identifier: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
174
|
+
name: "USD",
|
|
175
|
+
symbol: "USDC",
|
|
176
|
+
decimals: 6,
|
|
177
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
chain: BaseChain2,
|
|
181
|
+
identifier: "0x808456652fdb597867f38412077A9182bf77359F",
|
|
182
|
+
name: "Euro",
|
|
183
|
+
symbol: "EURC",
|
|
184
|
+
decimals: 6,
|
|
185
|
+
logoUrl: "https://assets.coingecko.com/coins/images/26045/thumb/euro-coin.png?1655394420"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
chain: BaseChain2,
|
|
189
|
+
identifier: "0xcbB7C0006F23900c38EB856149F799620fcb8A4a",
|
|
190
|
+
name: "Wrapped Bitcoin",
|
|
191
|
+
symbol: "WBTC",
|
|
192
|
+
decimals: 8,
|
|
193
|
+
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
|
|
197
|
+
// src/tokens/ethereum.ts
|
|
198
|
+
import { WarpChainName as WarpChainName4 } from "@vleap/warps";
|
|
199
|
+
var EthereumChain = WarpChainName4.Ethereum;
|
|
200
|
+
var EthereumTokens = [
|
|
201
|
+
{
|
|
202
|
+
chain: EthereumChain,
|
|
203
|
+
identifier: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
204
|
+
name: "USD Coin",
|
|
205
|
+
symbol: "USDC",
|
|
206
|
+
decimals: 6,
|
|
207
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
chain: EthereumChain,
|
|
211
|
+
identifier: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
212
|
+
name: "Tether USD",
|
|
213
|
+
symbol: "USDT",
|
|
214
|
+
decimals: 6,
|
|
215
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
chain: EthereumChain,
|
|
219
|
+
identifier: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
220
|
+
name: "Wrapped Bitcoin",
|
|
221
|
+
symbol: "WBTC",
|
|
222
|
+
decimals: 8,
|
|
223
|
+
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
chain: EthereumChain,
|
|
227
|
+
identifier: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
228
|
+
name: "Wrapped Ether",
|
|
229
|
+
symbol: "WETH",
|
|
230
|
+
decimals: 18,
|
|
231
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
chain: EthereumChain,
|
|
235
|
+
identifier: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
|
236
|
+
name: "Dai Stablecoin",
|
|
237
|
+
symbol: "DAI",
|
|
238
|
+
decimals: 18,
|
|
239
|
+
logoUrl: "https://assets.coingecko.com/coins/images/9956/small/4943.png"
|
|
240
|
+
}
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
// src/tokens/ethereum-sepolia.ts
|
|
244
|
+
import { WarpChainName as WarpChainName5 } from "@vleap/warps";
|
|
245
|
+
var EthereumChain2 = WarpChainName5.Ethereum;
|
|
246
|
+
var EthereumSepoliaTokens = [
|
|
247
|
+
{
|
|
248
|
+
chain: EthereumChain2,
|
|
249
|
+
identifier: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
250
|
+
name: "USD Coin",
|
|
251
|
+
symbol: "USDC",
|
|
252
|
+
decimals: 6,
|
|
253
|
+
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
chain: EthereumChain2,
|
|
257
|
+
identifier: "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06",
|
|
258
|
+
name: "Tether USD",
|
|
259
|
+
symbol: "USDT",
|
|
260
|
+
decimals: 6,
|
|
261
|
+
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
chain: EthereumChain2,
|
|
265
|
+
identifier: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
|
|
266
|
+
name: "Wrapped Ether",
|
|
267
|
+
symbol: "WETH",
|
|
268
|
+
decimals: 18,
|
|
269
|
+
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
270
|
+
}
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
// src/tokens.ts
|
|
274
|
+
var KnownTokens = {
|
|
275
|
+
ethereum: {
|
|
276
|
+
mainnet: EthereumTokens,
|
|
277
|
+
testnet: EthereumSepoliaTokens,
|
|
278
|
+
devnet: EthereumSepoliaTokens
|
|
279
|
+
},
|
|
280
|
+
base: {
|
|
281
|
+
mainnet: BaseTokens,
|
|
282
|
+
testnet: BaseSepoliaTokens,
|
|
283
|
+
devnet: BaseSepoliaTokens
|
|
284
|
+
},
|
|
285
|
+
arbitrum: {
|
|
286
|
+
mainnet: ArbitrumTokens
|
|
94
287
|
}
|
|
95
|
-
return config;
|
|
96
288
|
};
|
|
97
|
-
var
|
|
98
|
-
|
|
289
|
+
var findKnownTokenById = (chain, env, id) => {
|
|
290
|
+
const chainTokens = KnownTokens[chain]?.[env] || [];
|
|
291
|
+
return chainTokens.find((token) => token.identifier === id) || null;
|
|
99
292
|
};
|
|
100
|
-
var
|
|
101
|
-
return
|
|
293
|
+
var getKnownTokensForChain = (chainName, env = "mainnet") => {
|
|
294
|
+
return KnownTokens[chainName]?.[env] || [];
|
|
102
295
|
};
|
|
103
296
|
|
|
104
297
|
// src/WarpEvmDataLoader.ts
|
|
@@ -109,237 +302,168 @@ var ERC20_ABI = [
|
|
|
109
302
|
"function symbol() view returns (string)",
|
|
110
303
|
"function totalSupply() view returns (uint256)"
|
|
111
304
|
];
|
|
112
|
-
var KNOWN_TOKENS = {
|
|
113
|
-
ethereum: {
|
|
114
|
-
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
|
|
115
|
-
name: "USD Coin",
|
|
116
|
-
symbol: "USDC",
|
|
117
|
-
decimals: 6,
|
|
118
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
119
|
-
},
|
|
120
|
-
"0xdAC17F958D2ee523a2206206994597C13D831ec7": {
|
|
121
|
-
name: "Tether USD",
|
|
122
|
-
symbol: "USDT",
|
|
123
|
-
decimals: 6,
|
|
124
|
-
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
125
|
-
},
|
|
126
|
-
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
|
|
127
|
-
name: "Wrapped Bitcoin",
|
|
128
|
-
symbol: "WBTC",
|
|
129
|
-
decimals: 8,
|
|
130
|
-
logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
|
|
131
|
-
},
|
|
132
|
-
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
|
|
133
|
-
name: "Wrapped Ether",
|
|
134
|
-
symbol: "WETH",
|
|
135
|
-
decimals: 18,
|
|
136
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
137
|
-
},
|
|
138
|
-
"0x6B175474E89094C44Da98b954EedeAC495271d0F": {
|
|
139
|
-
name: "Dai Stablecoin",
|
|
140
|
-
symbol: "DAI",
|
|
141
|
-
decimals: 18,
|
|
142
|
-
logoUrl: "https://assets.coingecko.com/coins/images/9956/small/4943.png"
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
arbitrum: {
|
|
146
|
-
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8": {
|
|
147
|
-
name: "USD Coin",
|
|
148
|
-
symbol: "USDC",
|
|
149
|
-
decimals: 6,
|
|
150
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
151
|
-
},
|
|
152
|
-
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9": {
|
|
153
|
-
name: "Tether USD",
|
|
154
|
-
symbol: "USDT",
|
|
155
|
-
decimals: 6,
|
|
156
|
-
logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
|
|
157
|
-
},
|
|
158
|
-
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1": {
|
|
159
|
-
name: "Wrapped Ether",
|
|
160
|
-
symbol: "WETH",
|
|
161
|
-
decimals: 18,
|
|
162
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
base: {
|
|
166
|
-
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": {
|
|
167
|
-
name: "USD Coin",
|
|
168
|
-
symbol: "USDC",
|
|
169
|
-
decimals: 6,
|
|
170
|
-
logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
|
|
171
|
-
},
|
|
172
|
-
"0x4200000000000000000000000000000000000006": {
|
|
173
|
-
name: "Wrapped Ether",
|
|
174
|
-
symbol: "WETH",
|
|
175
|
-
decimals: 18,
|
|
176
|
-
logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
305
|
var WarpEvmDataLoader = class {
|
|
181
306
|
constructor(config, chain) {
|
|
182
307
|
this.config = config;
|
|
183
308
|
this.chain = chain;
|
|
184
|
-
|
|
185
|
-
|
|
309
|
+
const providerConfig = getProviderConfig(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
310
|
+
const network = new ethers.Network(this.chain.name, parseInt(this.chain.chainId));
|
|
311
|
+
this.provider = new ethers.JsonRpcProvider(providerConfig.url, network);
|
|
312
|
+
this.cache = new WarpCache2(config.cache?.type);
|
|
313
|
+
this.uniswapService = new UniswapService(this.cache, parseInt(this.chain.chainId));
|
|
186
314
|
}
|
|
187
315
|
async getAccount(address) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
} catch (error) {
|
|
195
|
-
throw new Error(`Failed to get account balance for ${address}: ${error}`);
|
|
196
|
-
}
|
|
316
|
+
const balance = await this.provider.getBalance(address);
|
|
317
|
+
return {
|
|
318
|
+
chain: this.chain.name,
|
|
319
|
+
address,
|
|
320
|
+
balance
|
|
321
|
+
};
|
|
197
322
|
}
|
|
198
323
|
async getAccountAssets(address) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
324
|
+
const account = await this.getAccount(address);
|
|
325
|
+
const tokenBalances = await this.getERC20TokenBalances(address);
|
|
326
|
+
let assets = account.balance > 0 ? [{ ...this.chain.nativeToken, amount: account.balance }] : [];
|
|
327
|
+
for (const tokenBalance of tokenBalances) {
|
|
328
|
+
if (tokenBalance.balance > 0n) {
|
|
329
|
+
assets.push({
|
|
330
|
+
chain: this.chain.name,
|
|
331
|
+
identifier: tokenBalance.tokenAddress,
|
|
332
|
+
name: tokenBalance.name,
|
|
333
|
+
symbol: tokenBalance.symbol,
|
|
334
|
+
amount: tokenBalance.balance,
|
|
335
|
+
decimals: tokenBalance.decimals,
|
|
336
|
+
logoUrl: tokenBalance.logoUrl || ""
|
|
337
|
+
});
|
|
212
338
|
}
|
|
213
|
-
return assets;
|
|
214
|
-
} catch (error) {
|
|
215
|
-
throw new Error(`Failed to get account assets for ${address}: ${error}`);
|
|
216
339
|
}
|
|
340
|
+
return assets;
|
|
217
341
|
}
|
|
218
|
-
async
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
try {
|
|
223
|
-
const balance = await this.getTokenBalance(address, tokenAddress);
|
|
224
|
-
if (balance > 0n) {
|
|
225
|
-
tokenBalances.push({
|
|
226
|
-
tokenAddress,
|
|
227
|
-
balance,
|
|
228
|
-
metadata
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.warn(`Failed to get balance for token ${tokenAddress}: ${error}`);
|
|
342
|
+
async getAsset(identifier) {
|
|
343
|
+
try {
|
|
344
|
+
if (identifier === this.chain.nativeToken.identifier) {
|
|
345
|
+
return this.chain.nativeToken;
|
|
233
346
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
const metadata = await this.getTokenMetadata(tokenAddress);
|
|
240
|
-
const balance = await this.getTokenBalance(address, tokenAddress);
|
|
241
|
-
if (balance > 0n) {
|
|
242
|
-
tokenBalances.push({
|
|
243
|
-
tokenAddress,
|
|
244
|
-
balance,
|
|
245
|
-
metadata
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
} catch (error) {
|
|
249
|
-
console.warn(`Failed to get metadata/balance for detected token ${tokenAddress}: ${error}`);
|
|
250
|
-
}
|
|
347
|
+
const cacheKey = WarpCacheKey.Asset(this.config.env, this.chain.name, identifier);
|
|
348
|
+
const cachedAsset = this.cache.get(cacheKey);
|
|
349
|
+
if (cachedAsset) {
|
|
350
|
+
return cachedAsset;
|
|
251
351
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
352
|
+
const knownToken = findKnownTokenById(this.chain.name, this.config.env, identifier);
|
|
353
|
+
if (knownToken) {
|
|
354
|
+
return {
|
|
355
|
+
chain: this.chain.name,
|
|
356
|
+
identifier,
|
|
357
|
+
name: knownToken.name,
|
|
358
|
+
symbol: knownToken.symbol,
|
|
359
|
+
amount: 0n,
|
|
360
|
+
decimals: knownToken.decimals,
|
|
361
|
+
logoUrl: knownToken.logoUrl
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
const metadata = await this.getTokenMetadata(identifier);
|
|
365
|
+
const asset = {
|
|
366
|
+
chain: this.chain.name,
|
|
367
|
+
identifier,
|
|
368
|
+
name: metadata.name,
|
|
369
|
+
symbol: metadata.symbol,
|
|
370
|
+
amount: 0n,
|
|
371
|
+
decimals: metadata.decimals,
|
|
372
|
+
logoUrl: metadata.logoUrl || ""
|
|
373
|
+
};
|
|
374
|
+
this.cache.set(cacheKey, asset, CacheTtl2.OneHour);
|
|
375
|
+
return asset;
|
|
260
376
|
} catch (error) {
|
|
261
|
-
|
|
377
|
+
return null;
|
|
262
378
|
}
|
|
263
379
|
}
|
|
264
|
-
async
|
|
380
|
+
async getAction(identifier, awaitCompleted = false) {
|
|
265
381
|
try {
|
|
266
|
-
const
|
|
267
|
-
|
|
382
|
+
const tx = await this.provider.getTransaction(identifier);
|
|
383
|
+
if (!tx) return null;
|
|
384
|
+
let receipt = await this.provider.getTransactionReceipt(identifier);
|
|
385
|
+
if (awaitCompleted && !receipt) {
|
|
386
|
+
receipt = await tx.wait();
|
|
387
|
+
}
|
|
388
|
+
const block = await this.provider.getBlock(tx.blockNumber || "latest");
|
|
268
389
|
return {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
390
|
+
chain: this.chain.name,
|
|
391
|
+
id: tx.hash || identifier,
|
|
392
|
+
receiver: tx.to || "",
|
|
393
|
+
sender: tx.from,
|
|
394
|
+
value: tx.value,
|
|
395
|
+
function: tx.data && tx.data !== "0x" ? "contract_call" : "",
|
|
396
|
+
status: receipt?.status === 1 ? "success" : receipt?.status === 0 ? "failed" : "pending",
|
|
397
|
+
createdAt: block?.timestamp ? new Date(Number(block.timestamp) * 1e3).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
398
|
+
error: receipt?.status === 0 ? "Transaction failed" : null,
|
|
399
|
+
tx: {
|
|
400
|
+
hash: tx.hash || "",
|
|
401
|
+
from: tx.from,
|
|
402
|
+
to: tx.to || "",
|
|
403
|
+
value: tx.value.toString(),
|
|
404
|
+
data: tx.data || "0x",
|
|
405
|
+
gasLimit: tx.gasLimit?.toString() || "0",
|
|
406
|
+
gasPrice: tx.gasPrice?.toString() || "0",
|
|
407
|
+
blockNumber: tx.blockNumber || 0,
|
|
408
|
+
blockHash: tx.blockHash || "",
|
|
409
|
+
transactionIndex: tx.index || 0
|
|
410
|
+
}
|
|
272
411
|
};
|
|
273
412
|
} catch (error) {
|
|
274
|
-
|
|
413
|
+
return null;
|
|
275
414
|
}
|
|
276
415
|
}
|
|
277
|
-
async
|
|
278
|
-
|
|
279
|
-
const currentBlock = await this.provider.getBlockNumber();
|
|
280
|
-
const fromBlock = Math.max(0, currentBlock - 1e4);
|
|
281
|
-
const filter = {
|
|
282
|
-
fromBlock,
|
|
283
|
-
toBlock: currentBlock,
|
|
284
|
-
topics: [
|
|
285
|
-
ethers.id("Transfer(address,address,uint256)"),
|
|
286
|
-
null,
|
|
287
|
-
// from address (any)
|
|
288
|
-
ethers.zeroPadValue(address, 32)
|
|
289
|
-
// to address (our target)
|
|
290
|
-
]
|
|
291
|
-
};
|
|
292
|
-
const logs = await this.provider.getLogs(filter);
|
|
293
|
-
const tokenAddresses = /* @__PURE__ */ new Set();
|
|
294
|
-
for (const log of logs) {
|
|
295
|
-
tokenAddresses.add(log.address);
|
|
296
|
-
}
|
|
297
|
-
return Array.from(tokenAddresses);
|
|
298
|
-
} catch (error) {
|
|
299
|
-
console.warn(`Failed to detect tokens from events: ${error}`);
|
|
300
|
-
return [];
|
|
301
|
-
}
|
|
416
|
+
async getAccountActions(address, options) {
|
|
417
|
+
return [];
|
|
302
418
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
419
|
+
async getERC20TokenBalances(address) {
|
|
420
|
+
const env = this.config.env === "mainnet" ? "mainnet" : "testnet";
|
|
421
|
+
const tokens = getKnownTokensForChain(this.chain.name, env);
|
|
422
|
+
const balanceReqs = tokens.map((token) => this.getTokenBalance(address, token.identifier).catch(() => 0n));
|
|
423
|
+
const balances = await Promise.all(balanceReqs);
|
|
424
|
+
return balances.map((balance, index) => ({ balance, token: tokens[index] })).filter(({ balance }) => balance > 0n).map(({ balance, token }) => ({
|
|
425
|
+
tokenAddress: token.identifier,
|
|
426
|
+
balance,
|
|
427
|
+
name: token.name,
|
|
428
|
+
symbol: token.symbol,
|
|
429
|
+
decimals: token.decimals || 18,
|
|
430
|
+
logoUrl: token.logoUrl || ""
|
|
431
|
+
}));
|
|
311
432
|
}
|
|
312
|
-
async
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
throw new Error(`Failed to get token balance for ${tokenAddress}: ${error}`);
|
|
317
|
-
}
|
|
433
|
+
async getTokenBalance(address, tokenAddress) {
|
|
434
|
+
const contract = new ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
435
|
+
const balance = await contract.balanceOf(address);
|
|
436
|
+
return balance;
|
|
318
437
|
}
|
|
319
|
-
async
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
438
|
+
async getTokenMetadata(tokenAddress) {
|
|
439
|
+
const uniswapMetadata = await this.uniswapService.getTokenMetadata(tokenAddress);
|
|
440
|
+
if (uniswapMetadata) {
|
|
441
|
+
return uniswapMetadata;
|
|
442
|
+
}
|
|
443
|
+
const contract = new ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
|
|
444
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
445
|
+
contract.name().catch(() => "Unknown Token"),
|
|
446
|
+
contract.symbol().catch(() => "UNKNOWN"),
|
|
447
|
+
contract.decimals().catch(() => 18)
|
|
448
|
+
]);
|
|
449
|
+
return {
|
|
450
|
+
name: name || "Unknown Token",
|
|
451
|
+
symbol: symbol || "UNKNOWN",
|
|
452
|
+
decimals: decimals || 18,
|
|
453
|
+
logoUrl: ""
|
|
454
|
+
};
|
|
333
455
|
}
|
|
334
456
|
};
|
|
335
457
|
|
|
336
458
|
// src/WarpEvmExecutor.ts
|
|
337
459
|
import {
|
|
338
|
-
|
|
460
|
+
applyOutputToMessages,
|
|
339
461
|
getNextInfo,
|
|
340
|
-
|
|
462
|
+
getProviderConfig as getProviderConfig3,
|
|
463
|
+
getWarpActionByIndex,
|
|
464
|
+
getWarpWalletAddressFromConfig as getWarpWalletAddressFromConfig2
|
|
341
465
|
} from "@vleap/warps";
|
|
342
|
-
import { ethers as
|
|
466
|
+
import { ethers as ethers4 } from "ethers";
|
|
343
467
|
|
|
344
468
|
// src/constants.ts
|
|
345
469
|
var WarpEvmConstants = {
|
|
@@ -348,6 +472,8 @@ var WarpEvmConstants = {
|
|
|
348
472
|
ContractCall: 1e5,
|
|
349
473
|
ContractDeploy: 5e5,
|
|
350
474
|
Transfer: 21e3,
|
|
475
|
+
TokenTransfer: 65e3,
|
|
476
|
+
// ERC-20 transfer gas limit
|
|
351
477
|
Approve: 46e3,
|
|
352
478
|
Swap: 2e5
|
|
353
479
|
},
|
|
@@ -414,12 +540,15 @@ var ExplorerUrls = {
|
|
|
414
540
|
["blockscout_base_sepolia" /* BlockscoutBaseSepolia */]: "https://sepolia.blockscout.com"
|
|
415
541
|
};
|
|
416
542
|
|
|
417
|
-
// src/
|
|
543
|
+
// src/WarpEvmOutput.ts
|
|
418
544
|
import {
|
|
419
|
-
|
|
420
|
-
|
|
545
|
+
evaluateOutputCommon,
|
|
546
|
+
getProviderConfig as getProviderConfig2,
|
|
547
|
+
getWarpWalletAddressFromConfig,
|
|
548
|
+
parseOutputOutIndex,
|
|
421
549
|
WarpConstants as WarpConstants2
|
|
422
550
|
} from "@vleap/warps";
|
|
551
|
+
import { ethers as ethers3 } from "ethers";
|
|
423
552
|
|
|
424
553
|
// src/WarpEvmSerializer.ts
|
|
425
554
|
import {
|
|
@@ -576,13 +705,61 @@ var WarpEvmSerializer = class {
|
|
|
576
705
|
}
|
|
577
706
|
};
|
|
578
707
|
|
|
579
|
-
// src/
|
|
580
|
-
var
|
|
581
|
-
constructor(config) {
|
|
708
|
+
// src/WarpEvmOutput.ts
|
|
709
|
+
var WarpEvmOutput = class {
|
|
710
|
+
constructor(config, chain) {
|
|
582
711
|
this.config = config;
|
|
712
|
+
this.chain = chain;
|
|
583
713
|
this.serializer = new WarpEvmSerializer();
|
|
714
|
+
const providerConfig = getProviderConfig2(this.config, this.chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
715
|
+
const network = new ethers3.Network(this.chain.name, parseInt(this.chain.chainId));
|
|
716
|
+
this.provider = new ethers3.JsonRpcProvider(providerConfig.url, network);
|
|
584
717
|
}
|
|
585
|
-
async
|
|
718
|
+
async getActionExecution(warp, actionIndex, tx) {
|
|
719
|
+
if (!tx) {
|
|
720
|
+
return this.createFailedExecution(warp, actionIndex);
|
|
721
|
+
}
|
|
722
|
+
if ("status" in tx && typeof tx.status === "string") {
|
|
723
|
+
return this.handleWarpChainAction(warp, actionIndex, tx);
|
|
724
|
+
}
|
|
725
|
+
return this.handleTransactionReceipt(warp, actionIndex, tx);
|
|
726
|
+
}
|
|
727
|
+
createFailedExecution(warp, actionIndex) {
|
|
728
|
+
return {
|
|
729
|
+
status: "error",
|
|
730
|
+
warp,
|
|
731
|
+
action: actionIndex,
|
|
732
|
+
user: getWarpWalletAddressFromConfig(this.config, this.chain.name),
|
|
733
|
+
txHash: "",
|
|
734
|
+
tx: null,
|
|
735
|
+
next: null,
|
|
736
|
+
values: { string: [], native: [] },
|
|
737
|
+
output: {},
|
|
738
|
+
messages: {}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
handleWarpChainAction(warp, actionIndex, tx) {
|
|
742
|
+
const success = tx.status === "success";
|
|
743
|
+
const transactionHash = tx.id || tx.tx?.hash || "";
|
|
744
|
+
const gasUsed = tx.tx?.gasLimit || "0";
|
|
745
|
+
const gasPrice = tx.tx?.gasPrice || "0";
|
|
746
|
+
const blockNumber = tx.tx?.blockNumber || "0";
|
|
747
|
+
const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice];
|
|
748
|
+
const stringValues = rawValues.map(String);
|
|
749
|
+
return {
|
|
750
|
+
status: success ? "success" : "error",
|
|
751
|
+
warp,
|
|
752
|
+
action: actionIndex,
|
|
753
|
+
user: getWarpWalletAddressFromConfig(this.config, this.chain.name),
|
|
754
|
+
txHash: transactionHash,
|
|
755
|
+
tx,
|
|
756
|
+
next: null,
|
|
757
|
+
values: { string: stringValues, native: rawValues },
|
|
758
|
+
output: {},
|
|
759
|
+
messages: {}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
handleTransactionReceipt(warp, actionIndex, tx) {
|
|
586
763
|
const success = tx.status === 1;
|
|
587
764
|
const gasUsed = tx.gasUsed?.toString() || "0";
|
|
588
765
|
const gasPrice = tx.gasPrice?.toString() || "0";
|
|
@@ -590,63 +767,92 @@ var WarpEvmResults = class {
|
|
|
590
767
|
const transactionHash = tx.hash;
|
|
591
768
|
const logs = tx.logs.map((log) => ({
|
|
592
769
|
address: log.address,
|
|
593
|
-
topics: log.topics,
|
|
770
|
+
topics: [...log.topics],
|
|
594
771
|
data: log.data,
|
|
595
772
|
blockNumber: log.blockNumber?.toString() || "0",
|
|
596
773
|
transactionHash: log.transactionHash,
|
|
597
774
|
index: log.index?.toString() || "0"
|
|
598
775
|
}));
|
|
776
|
+
const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
|
|
777
|
+
const stringValues = rawValues.map(String);
|
|
599
778
|
return {
|
|
600
|
-
success,
|
|
779
|
+
status: success ? "success" : "error",
|
|
601
780
|
warp,
|
|
602
|
-
action:
|
|
603
|
-
user: this.config.
|
|
781
|
+
action: actionIndex,
|
|
782
|
+
user: getWarpWalletAddressFromConfig(this.config, this.chain.name),
|
|
604
783
|
txHash: transactionHash,
|
|
784
|
+
tx,
|
|
605
785
|
next: null,
|
|
606
|
-
values:
|
|
607
|
-
|
|
786
|
+
values: { string: stringValues, native: rawValues },
|
|
787
|
+
output: {},
|
|
608
788
|
messages: {}
|
|
609
789
|
};
|
|
610
790
|
}
|
|
611
|
-
async
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
791
|
+
async extractQueryOutput(warp, typedValues, actionIndex, inputs) {
|
|
792
|
+
const stringValues = typedValues.map((t) => this.serializer.typedToString(t));
|
|
793
|
+
const nativeValues = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
|
|
794
|
+
const values = { string: stringValues, native: nativeValues };
|
|
795
|
+
let output = {};
|
|
796
|
+
if (!warp.output) return { values, output };
|
|
616
797
|
const getNestedValue = (path) => {
|
|
617
798
|
const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
|
|
618
799
|
if (indices.length === 0) return void 0;
|
|
619
|
-
let value =
|
|
800
|
+
let value = nativeValues[indices[0]];
|
|
620
801
|
for (let i = 1; i < indices.length; i++) {
|
|
621
802
|
if (value === void 0 || value === null) return void 0;
|
|
622
803
|
value = value[indices[i]];
|
|
623
804
|
}
|
|
624
805
|
return value;
|
|
625
806
|
};
|
|
626
|
-
for (const [key, path] of Object.entries(warp.
|
|
807
|
+
for (const [key, path] of Object.entries(warp.output)) {
|
|
627
808
|
if (path.startsWith(WarpConstants2.Transform.Prefix)) continue;
|
|
628
|
-
const currentActionIndex =
|
|
809
|
+
const currentActionIndex = parseOutputOutIndex(path);
|
|
629
810
|
if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
|
|
630
|
-
|
|
811
|
+
output[key] = null;
|
|
631
812
|
continue;
|
|
632
813
|
}
|
|
633
814
|
if (path.startsWith("out.") || path === "out" || path.startsWith("out[")) {
|
|
634
|
-
|
|
815
|
+
output[key] = getNestedValue(path) || null;
|
|
635
816
|
} else {
|
|
636
|
-
|
|
817
|
+
output[key] = path;
|
|
637
818
|
}
|
|
638
819
|
}
|
|
639
|
-
return { values,
|
|
820
|
+
return { values, output: await evaluateOutputCommon(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
821
|
+
}
|
|
822
|
+
async getTransactionStatus(txHash) {
|
|
823
|
+
try {
|
|
824
|
+
const receipt = await this.provider.getTransactionReceipt(txHash);
|
|
825
|
+
if (!receipt) {
|
|
826
|
+
return { status: "pending" };
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
status: receipt.status === 1 ? "confirmed" : "failed",
|
|
830
|
+
blockNumber: receipt.blockNumber,
|
|
831
|
+
gasUsed: receipt.gasUsed
|
|
832
|
+
};
|
|
833
|
+
} catch (error) {
|
|
834
|
+
throw new Error(`Failed to get transaction status: ${error}`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
async getTransactionReceipt(txHash) {
|
|
838
|
+
try {
|
|
839
|
+
return await this.provider.getTransactionReceipt(txHash);
|
|
840
|
+
} catch (error) {
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
640
843
|
}
|
|
641
844
|
};
|
|
642
845
|
|
|
643
846
|
// src/WarpEvmExecutor.ts
|
|
644
847
|
var WarpEvmExecutor = class {
|
|
645
|
-
constructor(config) {
|
|
848
|
+
constructor(config, chain) {
|
|
646
849
|
this.config = config;
|
|
850
|
+
this.chain = chain;
|
|
647
851
|
this.serializer = new WarpEvmSerializer();
|
|
648
|
-
|
|
649
|
-
|
|
852
|
+
const providerConfig = getProviderConfig3(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
853
|
+
const network = new ethers4.Network(this.chain.name, parseInt(this.chain.chainId));
|
|
854
|
+
this.provider = new ethers4.JsonRpcProvider(providerConfig.url, network);
|
|
855
|
+
this.output = new WarpEvmOutput(config, this.chain);
|
|
650
856
|
}
|
|
651
857
|
async createTransaction(executable) {
|
|
652
858
|
const action = getWarpActionByIndex(executable.warp, executable.action);
|
|
@@ -664,13 +870,13 @@ var WarpEvmExecutor = class {
|
|
|
664
870
|
return tx;
|
|
665
871
|
}
|
|
666
872
|
async createTransferTransaction(executable) {
|
|
667
|
-
const userWallet = this.config
|
|
873
|
+
const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
|
|
668
874
|
if (!userWallet) throw new Error("WarpEvmExecutor: createTransfer - user address not set");
|
|
669
|
-
if (!
|
|
875
|
+
if (!ethers4.isAddress(executable.destination)) {
|
|
670
876
|
throw new Error(`WarpEvmExecutor: Invalid destination address: ${executable.destination}`);
|
|
671
877
|
}
|
|
672
|
-
if (executable.
|
|
673
|
-
|
|
878
|
+
if (executable.transfers && executable.transfers.length > 0) {
|
|
879
|
+
return this.createTokenTransferTransaction(executable, userWallet);
|
|
674
880
|
}
|
|
675
881
|
const tx = {
|
|
676
882
|
to: executable.destination,
|
|
@@ -680,21 +886,20 @@ var WarpEvmExecutor = class {
|
|
|
680
886
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
681
887
|
}
|
|
682
888
|
async createContractCallTransaction(executable) {
|
|
683
|
-
const userWallet = this.config
|
|
889
|
+
const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
|
|
684
890
|
if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
|
|
685
891
|
const action = getWarpActionByIndex(executable.warp, executable.action);
|
|
686
|
-
if (!action || !("func" in action) || !action.func)
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
if (!ethers3.isAddress(executable.destination)) {
|
|
690
|
-
throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
|
|
691
|
-
}
|
|
692
|
-
if (executable.value < 0) {
|
|
693
|
-
throw new Error(`WarpEvmExecutor: Contract call value cannot be negative: ${executable.value}`);
|
|
694
|
-
}
|
|
892
|
+
if (!action || !("func" in action) || !action.func) throw new Error("WarpEvmExecutor: Contract action must have a function name");
|
|
893
|
+
if (!ethers4.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
|
|
695
894
|
try {
|
|
696
|
-
|
|
697
|
-
|
|
895
|
+
let iface;
|
|
896
|
+
try {
|
|
897
|
+
iface = new ethers4.Interface(JSON.parse(action.abi));
|
|
898
|
+
} catch {
|
|
899
|
+
iface = new ethers4.Interface([action.abi]);
|
|
900
|
+
}
|
|
901
|
+
const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
|
|
902
|
+
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
698
903
|
const tx = {
|
|
699
904
|
to: executable.destination,
|
|
700
905
|
value: executable.value,
|
|
@@ -705,101 +910,107 @@ var WarpEvmExecutor = class {
|
|
|
705
910
|
throw new Error(`WarpEvmExecutor: Failed to encode function data for ${action.func}: ${error}`);
|
|
706
911
|
}
|
|
707
912
|
}
|
|
708
|
-
async
|
|
709
|
-
|
|
710
|
-
if (
|
|
711
|
-
|
|
913
|
+
async createTokenTransferTransaction(executable, userWallet) {
|
|
914
|
+
if (executable.transfers.length === 0) throw new Error("WarpEvmExecutor: No transfers provided");
|
|
915
|
+
if (!this.chain.nativeToken?.identifier) throw new Error("WarpEvmExecutor: No native token defined for this chain");
|
|
916
|
+
const nativeTokenTransfers = executable.transfers.filter((transfer) => transfer.identifier === this.chain.nativeToken.identifier);
|
|
917
|
+
const erc20Transfers = executable.transfers.filter((transfer) => transfer.identifier !== this.chain.nativeToken.identifier);
|
|
918
|
+
if (nativeTokenTransfers.length === 1 && erc20Transfers.length === 0) {
|
|
919
|
+
const transfer = nativeTokenTransfers[0];
|
|
920
|
+
if (transfer.amount <= 0n) throw new Error("WarpEvmExecutor: Native token transfer amount must be positive");
|
|
921
|
+
const tx = {
|
|
922
|
+
to: executable.destination,
|
|
923
|
+
value: transfer.amount,
|
|
924
|
+
data: "0x"
|
|
925
|
+
};
|
|
926
|
+
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
712
927
|
}
|
|
713
|
-
if (
|
|
714
|
-
|
|
928
|
+
if (nativeTokenTransfers.length === 0 && erc20Transfers.length === 1) {
|
|
929
|
+
return this.createSingleTokenTransfer(executable, erc20Transfers[0], userWallet);
|
|
715
930
|
}
|
|
716
|
-
if (
|
|
717
|
-
|
|
931
|
+
if (executable.transfers.length > 1) throw new Error("WarpEvmExecutor: Multiple token transfers not yet supported");
|
|
932
|
+
throw new Error("WarpEvmExecutor: Invalid transfer configuration");
|
|
933
|
+
}
|
|
934
|
+
async createSingleTokenTransfer(executable, transfer, userWallet) {
|
|
935
|
+
if (!ethers4.isAddress(transfer.identifier)) {
|
|
936
|
+
throw new Error(`WarpEvmExecutor: Invalid token address: ${transfer.identifier}`);
|
|
718
937
|
}
|
|
938
|
+
const transferInterface = new ethers4.Interface(["function transfer(address to, uint256 amount) returns (bool)"]);
|
|
939
|
+
const encodedData = transferInterface.encodeFunctionData("transfer", [executable.destination, transfer.amount]);
|
|
940
|
+
const tx = {
|
|
941
|
+
to: transfer.identifier,
|
|
942
|
+
value: 0n,
|
|
943
|
+
data: encodedData
|
|
944
|
+
};
|
|
945
|
+
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
946
|
+
}
|
|
947
|
+
async executeQuery(executable) {
|
|
948
|
+
const action = getWarpActionByIndex(executable.warp, executable.action);
|
|
949
|
+
if (action.type !== "query") throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
|
|
950
|
+
if (!action.func) throw new Error("WarpEvmExecutor: Query action must have a function name");
|
|
951
|
+
if (!ethers4.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid address for query: ${executable.destination}`);
|
|
719
952
|
try {
|
|
720
|
-
|
|
721
|
-
|
|
953
|
+
let iface;
|
|
954
|
+
try {
|
|
955
|
+
iface = new ethers4.Interface(JSON.parse(action.abi));
|
|
956
|
+
} catch {
|
|
957
|
+
iface = new ethers4.Interface([action.abi]);
|
|
958
|
+
}
|
|
959
|
+
const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
|
|
960
|
+
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
722
961
|
const result = await this.provider.call({
|
|
723
962
|
to: executable.destination,
|
|
724
963
|
data: encodedData
|
|
725
964
|
});
|
|
726
965
|
const decodedResult = iface.decodeFunctionResult(action.func, result);
|
|
727
966
|
const isSuccess = true;
|
|
728
|
-
const { values,
|
|
967
|
+
const { values, output } = await this.output.extractQueryOutput(
|
|
729
968
|
executable.warp,
|
|
730
969
|
decodedResult,
|
|
731
970
|
executable.action,
|
|
732
971
|
executable.resolvedInputs
|
|
733
972
|
);
|
|
734
|
-
const next = getNextInfo(this.config, [], executable.warp, executable.action,
|
|
973
|
+
const next = getNextInfo(this.config, [], executable.warp, executable.action, output);
|
|
735
974
|
return {
|
|
736
|
-
success:
|
|
975
|
+
status: isSuccess ? "success" : "error",
|
|
737
976
|
warp: executable.warp,
|
|
738
977
|
action: executable.action,
|
|
739
|
-
user: this.config
|
|
978
|
+
user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
|
|
740
979
|
txHash: null,
|
|
980
|
+
tx: null,
|
|
741
981
|
next,
|
|
742
982
|
values,
|
|
743
|
-
|
|
744
|
-
messages:
|
|
983
|
+
output: { ...output, _DATA: decodedResult },
|
|
984
|
+
messages: applyOutputToMessages(executable.warp, output, this.config)
|
|
745
985
|
};
|
|
746
986
|
} catch (error) {
|
|
747
987
|
return {
|
|
748
|
-
|
|
988
|
+
status: "error",
|
|
749
989
|
warp: executable.warp,
|
|
750
990
|
action: executable.action,
|
|
751
|
-
user: this.config
|
|
991
|
+
user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
|
|
752
992
|
txHash: null,
|
|
993
|
+
tx: null,
|
|
753
994
|
next: null,
|
|
754
|
-
values: [],
|
|
755
|
-
|
|
995
|
+
values: { string: [], native: [] },
|
|
996
|
+
output: { _DATA: error },
|
|
756
997
|
messages: {}
|
|
757
998
|
};
|
|
758
999
|
}
|
|
759
1000
|
}
|
|
760
|
-
async preprocessInput(chain, input, type, value) {
|
|
761
|
-
const typedValue = this.serializer.stringToTyped(value);
|
|
762
|
-
switch (type) {
|
|
763
|
-
case "address":
|
|
764
|
-
if (!ethers3.isAddress(typedValue)) {
|
|
765
|
-
throw new Error(`Invalid address format: ${typedValue}`);
|
|
766
|
-
}
|
|
767
|
-
return ethers3.getAddress(typedValue);
|
|
768
|
-
case "hex":
|
|
769
|
-
if (!ethers3.isHexString(typedValue)) {
|
|
770
|
-
throw new Error(`Invalid hex format: ${typedValue}`);
|
|
771
|
-
}
|
|
772
|
-
return typedValue;
|
|
773
|
-
case "uint8":
|
|
774
|
-
case "uint16":
|
|
775
|
-
case "uint32":
|
|
776
|
-
case "uint64":
|
|
777
|
-
case "biguint":
|
|
778
|
-
const bigIntValue = BigInt(typedValue);
|
|
779
|
-
if (bigIntValue < 0) {
|
|
780
|
-
throw new Error(`Negative value not allowed for type ${type}: ${typedValue}`);
|
|
781
|
-
}
|
|
782
|
-
return bigIntValue.toString();
|
|
783
|
-
default:
|
|
784
|
-
return String(typedValue);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
1001
|
async estimateGasAndSetDefaults(tx, from) {
|
|
788
1002
|
try {
|
|
789
1003
|
const gasEstimate = await this.provider.estimateGas({
|
|
790
1004
|
...tx,
|
|
791
1005
|
from
|
|
792
1006
|
});
|
|
793
|
-
if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) {
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) {
|
|
797
|
-
throw new Error(`Gas estimate too high: ${gasEstimate}`);
|
|
798
|
-
}
|
|
1007
|
+
if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) throw new Error(`Gas estimate too low: ${gasEstimate}`);
|
|
1008
|
+
if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) throw new Error(`Gas estimate too high: ${gasEstimate}`);
|
|
799
1009
|
const feeData = await this.provider.getFeeData();
|
|
800
1010
|
if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
|
|
801
1011
|
return {
|
|
802
1012
|
...tx,
|
|
1013
|
+
chainId: parseInt(this.chain.chainId),
|
|
803
1014
|
gasLimit: gasEstimate,
|
|
804
1015
|
maxFeePerGas: feeData.maxFeePerGas,
|
|
805
1016
|
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
|
|
@@ -807,32 +1018,44 @@ var WarpEvmExecutor = class {
|
|
|
807
1018
|
} else if (feeData.gasPrice) {
|
|
808
1019
|
return {
|
|
809
1020
|
...tx,
|
|
1021
|
+
chainId: parseInt(this.chain.chainId),
|
|
810
1022
|
gasLimit: gasEstimate,
|
|
811
1023
|
gasPrice: feeData.gasPrice
|
|
812
1024
|
};
|
|
813
1025
|
} else {
|
|
814
1026
|
return {
|
|
815
1027
|
...tx,
|
|
1028
|
+
chainId: parseInt(this.chain.chainId),
|
|
816
1029
|
gasLimit: gasEstimate,
|
|
817
|
-
gasPrice:
|
|
1030
|
+
gasPrice: ethers4.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
818
1031
|
};
|
|
819
1032
|
}
|
|
820
1033
|
} catch (error) {
|
|
821
1034
|
let defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Default);
|
|
822
1035
|
if (tx.data && tx.data !== "0x") {
|
|
823
|
-
|
|
1036
|
+
if (tx.data.startsWith("0xa9059cbb")) {
|
|
1037
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.TokenTransfer);
|
|
1038
|
+
} else {
|
|
1039
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.ContractCall);
|
|
1040
|
+
}
|
|
824
1041
|
} else {
|
|
825
1042
|
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Transfer);
|
|
826
1043
|
}
|
|
827
1044
|
return {
|
|
828
1045
|
...tx,
|
|
1046
|
+
chainId: parseInt(this.chain.chainId),
|
|
829
1047
|
gasLimit: defaultGasLimit,
|
|
830
|
-
gasPrice:
|
|
1048
|
+
gasPrice: ethers4.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
831
1049
|
};
|
|
832
1050
|
}
|
|
833
1051
|
}
|
|
834
|
-
async
|
|
835
|
-
|
|
1052
|
+
async verifyMessage(message, signature) {
|
|
1053
|
+
try {
|
|
1054
|
+
const recoveredAddress = ethers4.verifyMessage(message, signature);
|
|
1055
|
+
return recoveredAddress;
|
|
1056
|
+
} catch (error) {
|
|
1057
|
+
throw new Error(`Failed to verify message: ${error}`);
|
|
1058
|
+
}
|
|
836
1059
|
}
|
|
837
1060
|
};
|
|
838
1061
|
|
|
@@ -920,154 +1143,379 @@ var WarpEvmExplorer = class {
|
|
|
920
1143
|
});
|
|
921
1144
|
return urls;
|
|
922
1145
|
}
|
|
1146
|
+
getAssetUrls(identifier) {
|
|
1147
|
+
const explorers = this.getAllExplorers();
|
|
1148
|
+
const urls = {};
|
|
1149
|
+
explorers.forEach((explorer) => {
|
|
1150
|
+
const url = ExplorerUrls[explorer];
|
|
1151
|
+
if (url) {
|
|
1152
|
+
urls[explorer] = `${url}/token/${identifier}`;
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
return urls;
|
|
1156
|
+
}
|
|
1157
|
+
getContractUrls(address) {
|
|
1158
|
+
const explorers = this.getAllExplorers();
|
|
1159
|
+
const urls = {};
|
|
1160
|
+
explorers.forEach((explorer) => {
|
|
1161
|
+
const url = ExplorerUrls[explorer];
|
|
1162
|
+
if (url) {
|
|
1163
|
+
urls[explorer] = `${url}/address/${address}`;
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
return urls;
|
|
1167
|
+
}
|
|
1168
|
+
getBlockUrls(blockNumber) {
|
|
1169
|
+
const explorers = this.getAllExplorers();
|
|
1170
|
+
const urls = {};
|
|
1171
|
+
explorers.forEach((explorer) => {
|
|
1172
|
+
const url = ExplorerUrls[explorer];
|
|
1173
|
+
if (url) {
|
|
1174
|
+
urls[explorer] = `${url}/block/${blockNumber}`;
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
return urls;
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
// src/WarpEvmWallet.ts
|
|
1182
|
+
import {
|
|
1183
|
+
getProviderConfig as getProviderConfig4,
|
|
1184
|
+
getWarpWalletMnemonicFromConfig,
|
|
1185
|
+
getWarpWalletPrivateKeyFromConfig
|
|
1186
|
+
} from "@vleap/warps";
|
|
1187
|
+
import { ethers as ethers5 } from "ethers";
|
|
1188
|
+
var WarpEvmWallet = class {
|
|
1189
|
+
constructor(config, chain) {
|
|
1190
|
+
this.config = config;
|
|
1191
|
+
this.chain = chain;
|
|
1192
|
+
const providerConfig = getProviderConfig4(config, chain.name, config.env, chain.defaultApiUrl);
|
|
1193
|
+
this.provider = new ethers5.JsonRpcProvider(providerConfig.url);
|
|
1194
|
+
}
|
|
1195
|
+
async signTransaction(tx) {
|
|
1196
|
+
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
1197
|
+
const wallet = this.getWallet();
|
|
1198
|
+
const txRequest = {
|
|
1199
|
+
to: tx.to,
|
|
1200
|
+
data: tx.data,
|
|
1201
|
+
value: tx.value || 0,
|
|
1202
|
+
gasLimit: tx.gasLimit,
|
|
1203
|
+
maxFeePerGas: tx.maxFeePerGas,
|
|
1204
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
|
|
1205
|
+
nonce: tx.nonce,
|
|
1206
|
+
chainId: tx.chainId
|
|
1207
|
+
};
|
|
1208
|
+
const signedTx = await wallet.signTransaction(txRequest);
|
|
1209
|
+
return { ...tx, signature: signedTx };
|
|
1210
|
+
}
|
|
1211
|
+
async signTransactions(txs) {
|
|
1212
|
+
if (txs.length === 0) return [];
|
|
1213
|
+
if (txs.length > 1) {
|
|
1214
|
+
const wallet = this.getWallet();
|
|
1215
|
+
const address = wallet.address;
|
|
1216
|
+
const currentNonce = await this.provider.getTransactionCount(address, "pending");
|
|
1217
|
+
const signedTxs = [];
|
|
1218
|
+
for (let i = 0; i < txs.length; i++) {
|
|
1219
|
+
const tx = { ...txs[i] };
|
|
1220
|
+
tx.nonce = currentNonce + i;
|
|
1221
|
+
if (i > 0) {
|
|
1222
|
+
const priorityReduction = BigInt(i * 1e9);
|
|
1223
|
+
const minGasPrice = BigInt(1e9);
|
|
1224
|
+
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
|
1225
|
+
tx.maxFeePerGas = tx.maxFeePerGas > priorityReduction ? tx.maxFeePerGas - priorityReduction : minGasPrice;
|
|
1226
|
+
tx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas > priorityReduction ? tx.maxPriorityFeePerGas - priorityReduction : minGasPrice;
|
|
1227
|
+
delete tx.gasPrice;
|
|
1228
|
+
} else if (tx.gasPrice) {
|
|
1229
|
+
tx.gasPrice = tx.gasPrice > priorityReduction ? tx.gasPrice - priorityReduction : minGasPrice;
|
|
1230
|
+
delete tx.maxFeePerGas;
|
|
1231
|
+
delete tx.maxPriorityFeePerGas;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
const signedTx = await this.signTransaction(tx);
|
|
1235
|
+
signedTxs.push(signedTx);
|
|
1236
|
+
}
|
|
1237
|
+
return signedTxs;
|
|
1238
|
+
}
|
|
1239
|
+
return Promise.all(txs.map(async (tx) => this.signTransaction(tx)));
|
|
1240
|
+
}
|
|
1241
|
+
async signMessage(message) {
|
|
1242
|
+
const wallet = this.getWallet();
|
|
1243
|
+
const signature = await wallet.signMessage(message);
|
|
1244
|
+
return signature;
|
|
1245
|
+
}
|
|
1246
|
+
async sendTransaction(tx) {
|
|
1247
|
+
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
1248
|
+
if (!tx.signature) throw new Error("Transaction must be signed before sending");
|
|
1249
|
+
const wallet = this.getWallet();
|
|
1250
|
+
if (!wallet) throw new Error("Wallet not initialized - no private key provided");
|
|
1251
|
+
const connectedWallet = wallet.connect(this.provider);
|
|
1252
|
+
const txResponse = await connectedWallet.sendTransaction(tx);
|
|
1253
|
+
return txResponse.hash;
|
|
1254
|
+
}
|
|
1255
|
+
async sendTransactions(txs) {
|
|
1256
|
+
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
1257
|
+
}
|
|
1258
|
+
create(mnemonic) {
|
|
1259
|
+
const wallet = ethers5.Wallet.fromPhrase(mnemonic);
|
|
1260
|
+
return { address: wallet.address, privateKey: wallet.privateKey, mnemonic };
|
|
1261
|
+
}
|
|
1262
|
+
generate() {
|
|
1263
|
+
const wallet = ethers5.Wallet.createRandom();
|
|
1264
|
+
return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
|
|
1265
|
+
}
|
|
1266
|
+
getAddress() {
|
|
1267
|
+
const wallet = this.getWallet();
|
|
1268
|
+
return wallet.address;
|
|
1269
|
+
}
|
|
1270
|
+
getWallet() {
|
|
1271
|
+
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
1272
|
+
if (privateKey) return new ethers5.Wallet(privateKey);
|
|
1273
|
+
const mnemonic = getWarpWalletMnemonicFromConfig(this.config, this.chain.name);
|
|
1274
|
+
if (mnemonic) return ethers5.Wallet.fromPhrase(mnemonic);
|
|
1275
|
+
throw new Error("No private key or mnemonic provided");
|
|
1276
|
+
}
|
|
923
1277
|
};
|
|
924
1278
|
|
|
925
1279
|
// src/chains/common.ts
|
|
926
|
-
var createEvmAdapter = (chainName,
|
|
1280
|
+
var createEvmAdapter = (chainName, chainInfos) => {
|
|
927
1281
|
return (config, fallback) => {
|
|
928
1282
|
if (!fallback) throw new Error(`${chainName} adapter requires a fallback adapter`);
|
|
929
1283
|
return {
|
|
930
|
-
chain: chainName,
|
|
931
1284
|
chainInfo: chainInfos[config.env],
|
|
932
|
-
prefix: chainPrefix,
|
|
933
1285
|
builder: () => fallback.builder(),
|
|
934
|
-
executor: new WarpEvmExecutor(config),
|
|
935
|
-
|
|
1286
|
+
executor: new WarpEvmExecutor(config, chainInfos[config.env]),
|
|
1287
|
+
output: new WarpEvmOutput(config, chainInfos[config.env]),
|
|
936
1288
|
serializer: new WarpEvmSerializer(),
|
|
937
1289
|
registry: fallback.registry,
|
|
938
1290
|
explorer: new WarpEvmExplorer(chainInfos[config.env], config),
|
|
939
1291
|
abiBuilder: () => fallback.abiBuilder(),
|
|
940
1292
|
brandBuilder: () => fallback.brandBuilder(),
|
|
941
|
-
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env])
|
|
1293
|
+
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env]),
|
|
1294
|
+
wallet: new WarpEvmWallet(config, chainInfos[config.env])
|
|
942
1295
|
};
|
|
943
1296
|
};
|
|
944
1297
|
};
|
|
945
1298
|
|
|
946
1299
|
// src/chains/arbitrum.ts
|
|
947
|
-
var
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1300
|
+
var NativeTokenArb = {
|
|
1301
|
+
chain: WarpChainName6.Arbitrum,
|
|
1302
|
+
identifier: "ARB",
|
|
1303
|
+
symbol: "ARB",
|
|
1304
|
+
name: "Arbitrum",
|
|
1305
|
+
decimals: 18,
|
|
1306
|
+
logoUrl: "https://vleap.ai/images/tokens/arb.svg"
|
|
1307
|
+
};
|
|
1308
|
+
var getArbitrumAdapter = createEvmAdapter(WarpChainName6.Arbitrum, {
|
|
1309
|
+
mainnet: {
|
|
1310
|
+
name: WarpChainName6.Arbitrum,
|
|
1311
|
+
displayName: "Arbitrum",
|
|
1312
|
+
chainId: "42161",
|
|
953
1313
|
blockTime: 1e3,
|
|
954
1314
|
addressHrp: "0x",
|
|
955
|
-
|
|
956
|
-
|
|
1315
|
+
defaultApiUrl: "https://arb1.arbitrum.io/rpc",
|
|
1316
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1317
|
+
nativeToken: NativeTokenArb
|
|
957
1318
|
},
|
|
958
1319
|
testnet: {
|
|
959
|
-
name:
|
|
960
|
-
displayName: "Arbitrum
|
|
961
|
-
chainId: "
|
|
1320
|
+
name: WarpChainName6.Arbitrum,
|
|
1321
|
+
displayName: "Arbitrum Sepolia",
|
|
1322
|
+
chainId: "421614",
|
|
962
1323
|
blockTime: 1e3,
|
|
963
1324
|
addressHrp: "0x",
|
|
964
|
-
|
|
965
|
-
|
|
1325
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1326
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1327
|
+
nativeToken: NativeTokenArb
|
|
966
1328
|
},
|
|
967
|
-
|
|
968
|
-
name:
|
|
969
|
-
displayName: "Arbitrum",
|
|
970
|
-
chainId: "
|
|
1329
|
+
devnet: {
|
|
1330
|
+
name: WarpChainName6.Arbitrum,
|
|
1331
|
+
displayName: "Arbitrum Sepolia",
|
|
1332
|
+
chainId: "421614",
|
|
971
1333
|
blockTime: 1e3,
|
|
972
1334
|
addressHrp: "0x",
|
|
973
|
-
|
|
974
|
-
|
|
1335
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1336
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1337
|
+
nativeToken: NativeTokenArb
|
|
975
1338
|
}
|
|
976
1339
|
});
|
|
977
1340
|
|
|
978
1341
|
// src/chains/base.ts
|
|
979
|
-
|
|
980
|
-
var
|
|
1342
|
+
import { WarpChainName as WarpChainName7 } from "@vleap/warps";
|
|
1343
|
+
var NativeTokenBase = {
|
|
1344
|
+
chain: WarpChainName7.Base,
|
|
1345
|
+
identifier: "ETH",
|
|
1346
|
+
name: "Ether",
|
|
1347
|
+
symbol: "ETH",
|
|
1348
|
+
decimals: 18,
|
|
1349
|
+
logoUrl: "https://vleap.ai/images/tokens/eth.svg"
|
|
1350
|
+
};
|
|
1351
|
+
var getBaseAdapter = createEvmAdapter(WarpChainName7.Base, {
|
|
981
1352
|
mainnet: {
|
|
982
|
-
name:
|
|
1353
|
+
name: WarpChainName7.Base,
|
|
983
1354
|
displayName: "Base",
|
|
984
1355
|
chainId: "8453",
|
|
985
1356
|
blockTime: 2e3,
|
|
986
1357
|
addressHrp: "0x",
|
|
987
|
-
|
|
988
|
-
|
|
1358
|
+
defaultApiUrl: "https://mainnet.base.org",
|
|
1359
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1360
|
+
nativeToken: NativeTokenBase
|
|
989
1361
|
},
|
|
990
1362
|
testnet: {
|
|
991
|
-
name:
|
|
992
|
-
displayName: "Base
|
|
993
|
-
chainId: "
|
|
1363
|
+
name: WarpChainName7.Base,
|
|
1364
|
+
displayName: "Base Sepolia",
|
|
1365
|
+
chainId: "84532",
|
|
994
1366
|
blockTime: 2e3,
|
|
995
1367
|
addressHrp: "0x",
|
|
996
|
-
|
|
997
|
-
|
|
1368
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1369
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1370
|
+
nativeToken: NativeTokenBase
|
|
998
1371
|
},
|
|
999
1372
|
devnet: {
|
|
1000
|
-
name:
|
|
1001
|
-
displayName: "Base
|
|
1373
|
+
name: WarpChainName7.Base,
|
|
1374
|
+
displayName: "Base Sepolia",
|
|
1002
1375
|
chainId: "84532",
|
|
1003
1376
|
blockTime: 2e3,
|
|
1004
1377
|
addressHrp: "0x",
|
|
1005
|
-
|
|
1006
|
-
|
|
1378
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1379
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1380
|
+
nativeToken: NativeTokenBase
|
|
1007
1381
|
}
|
|
1008
1382
|
});
|
|
1009
1383
|
|
|
1384
|
+
// src/chains/combined.ts
|
|
1385
|
+
import { WarpChainName as WarpChainName10 } from "@vleap/warps";
|
|
1386
|
+
|
|
1010
1387
|
// src/chains/ethereum.ts
|
|
1011
|
-
|
|
1012
|
-
var
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1388
|
+
import { WarpChainName as WarpChainName8 } from "@vleap/warps";
|
|
1389
|
+
var NativeTokenEth = {
|
|
1390
|
+
chain: WarpChainName8.Ethereum,
|
|
1391
|
+
identifier: "ETH",
|
|
1392
|
+
symbol: "ETH",
|
|
1393
|
+
name: "Ether",
|
|
1394
|
+
decimals: 18,
|
|
1395
|
+
logoUrl: "https://vleap.ai/images/tokens/eth.svg"
|
|
1396
|
+
};
|
|
1397
|
+
var getEthereumAdapter = createEvmAdapter(WarpChainName8.Ethereum, {
|
|
1398
|
+
mainnet: {
|
|
1399
|
+
name: WarpChainName8.Ethereum,
|
|
1400
|
+
displayName: "Ethereum Mainnet",
|
|
1401
|
+
chainId: "1",
|
|
1017
1402
|
blockTime: 12e3,
|
|
1018
1403
|
addressHrp: "0x",
|
|
1019
|
-
|
|
1020
|
-
|
|
1404
|
+
defaultApiUrl: "https://ethereum-rpc.publicnode.com",
|
|
1405
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1406
|
+
nativeToken: NativeTokenEth
|
|
1021
1407
|
},
|
|
1022
1408
|
testnet: {
|
|
1023
|
-
name:
|
|
1024
|
-
displayName: "Ethereum
|
|
1025
|
-
chainId: "
|
|
1409
|
+
name: WarpChainName8.Ethereum,
|
|
1410
|
+
displayName: "Ethereum Sepolia",
|
|
1411
|
+
chainId: "11155111",
|
|
1026
1412
|
blockTime: 12e3,
|
|
1027
1413
|
addressHrp: "0x",
|
|
1028
|
-
|
|
1029
|
-
|
|
1414
|
+
defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1415
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1416
|
+
nativeToken: NativeTokenEth
|
|
1030
1417
|
},
|
|
1031
|
-
|
|
1032
|
-
name:
|
|
1033
|
-
displayName: "Ethereum
|
|
1034
|
-
chainId: "
|
|
1418
|
+
devnet: {
|
|
1419
|
+
name: WarpChainName8.Ethereum,
|
|
1420
|
+
displayName: "Ethereum Sepolia",
|
|
1421
|
+
chainId: "11155111",
|
|
1035
1422
|
blockTime: 12e3,
|
|
1036
1423
|
addressHrp: "0x",
|
|
1037
|
-
|
|
1038
|
-
|
|
1424
|
+
defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1425
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1426
|
+
nativeToken: NativeTokenEth
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
// src/chains/somnia.ts
|
|
1431
|
+
import { WarpChainName as WarpChainName9 } from "@vleap/warps";
|
|
1432
|
+
var NativeTokenSomi = {
|
|
1433
|
+
chain: WarpChainName9.Somnia,
|
|
1434
|
+
identifier: "SOMI",
|
|
1435
|
+
symbol: "SOMI",
|
|
1436
|
+
name: "Somnia",
|
|
1437
|
+
decimals: 18,
|
|
1438
|
+
logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
|
|
1439
|
+
};
|
|
1440
|
+
var NativeTokenStt = {
|
|
1441
|
+
chain: WarpChainName9.Somnia,
|
|
1442
|
+
identifier: "STT",
|
|
1443
|
+
symbol: "STT",
|
|
1444
|
+
name: "Somnia Testnet Token",
|
|
1445
|
+
decimals: 18,
|
|
1446
|
+
logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
|
|
1447
|
+
};
|
|
1448
|
+
var getSomniaAdapter = createEvmAdapter(WarpChainName9.Somnia, {
|
|
1449
|
+
mainnet: {
|
|
1450
|
+
name: WarpChainName9.Somnia,
|
|
1451
|
+
displayName: "Somnia Mainnet",
|
|
1452
|
+
chainId: "5031",
|
|
1453
|
+
blockTime: 100,
|
|
1454
|
+
addressHrp: "0x",
|
|
1455
|
+
defaultApiUrl: "https://api.infra.mainnet.somnia.network/",
|
|
1456
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1457
|
+
nativeToken: NativeTokenSomi
|
|
1458
|
+
},
|
|
1459
|
+
testnet: {
|
|
1460
|
+
name: WarpChainName9.Somnia,
|
|
1461
|
+
displayName: "Somnia Testnet",
|
|
1462
|
+
chainId: "50312",
|
|
1463
|
+
blockTime: 100,
|
|
1464
|
+
addressHrp: "0x",
|
|
1465
|
+
defaultApiUrl: "https://dream-rpc.somnia.network/",
|
|
1466
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1467
|
+
nativeToken: NativeTokenStt
|
|
1468
|
+
},
|
|
1469
|
+
devnet: {
|
|
1470
|
+
name: WarpChainName9.Somnia,
|
|
1471
|
+
displayName: "Somnia Testnet",
|
|
1472
|
+
chainId: "50312",
|
|
1473
|
+
blockTime: 100,
|
|
1474
|
+
addressHrp: "0x",
|
|
1475
|
+
defaultApiUrl: "https://dream-rpc.somnia.network",
|
|
1476
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1477
|
+
nativeToken: NativeTokenStt
|
|
1039
1478
|
}
|
|
1040
1479
|
});
|
|
1041
1480
|
|
|
1042
1481
|
// src/chains/combined.ts
|
|
1043
1482
|
var getAllEvmAdapters = (config, fallback) => [
|
|
1044
1483
|
getEthereumAdapter(config, fallback),
|
|
1484
|
+
getBaseAdapter(config, fallback),
|
|
1045
1485
|
getArbitrumAdapter(config, fallback),
|
|
1046
|
-
|
|
1486
|
+
getSomniaAdapter(config, fallback)
|
|
1487
|
+
];
|
|
1488
|
+
var getAllEvmChainNames = () => [
|
|
1489
|
+
WarpChainName10.Ethereum,
|
|
1490
|
+
WarpChainName10.Base,
|
|
1491
|
+
WarpChainName10.Arbitrum,
|
|
1492
|
+
WarpChainName10.Somnia
|
|
1047
1493
|
];
|
|
1048
|
-
var getAllEvmChainNames = () => [ChainNameArbitrum, ChainNameBase, ChainNameEthereum];
|
|
1049
1494
|
export {
|
|
1050
1495
|
ArbitrumExplorers,
|
|
1051
1496
|
BaseExplorers,
|
|
1052
|
-
ChainNameArbitrum,
|
|
1053
|
-
ChainNameBase,
|
|
1054
|
-
ChainNameEthereum,
|
|
1055
|
-
EVM_CHAIN_CONFIGS,
|
|
1056
1497
|
EthereumExplorers,
|
|
1057
1498
|
EvmExplorers,
|
|
1058
1499
|
ExplorerUrls,
|
|
1500
|
+
KnownTokens,
|
|
1501
|
+
NativeTokenArb,
|
|
1502
|
+
NativeTokenBase,
|
|
1503
|
+
NativeTokenEth,
|
|
1504
|
+
UniswapService,
|
|
1059
1505
|
WarpEvmConstants,
|
|
1506
|
+
WarpEvmDataLoader,
|
|
1060
1507
|
WarpEvmExecutor,
|
|
1061
1508
|
WarpEvmExplorer,
|
|
1062
|
-
|
|
1509
|
+
WarpEvmOutput,
|
|
1063
1510
|
WarpEvmSerializer,
|
|
1511
|
+
WarpEvmWallet,
|
|
1512
|
+
createEvmAdapter,
|
|
1513
|
+
findKnownTokenById,
|
|
1064
1514
|
getAllEvmAdapters,
|
|
1065
1515
|
getAllEvmChainNames,
|
|
1066
1516
|
getArbitrumAdapter,
|
|
1067
1517
|
getBaseAdapter,
|
|
1068
1518
|
getEthereumAdapter,
|
|
1069
|
-
|
|
1070
|
-
getEvmChainConfig,
|
|
1071
|
-
getEvmExplorerUrl
|
|
1519
|
+
getKnownTokensForChain
|
|
1072
1520
|
};
|
|
1073
1521
|
//# sourceMappingURL=index.mjs.map
|