@vleap/warps-adapter-evm 0.2.0-alpha.9 → 0.2.0-beta.44
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 +928 -477
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +921 -460
- 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,63 @@ 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
|
+
destination: null
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
handleWarpChainAction(warp, actionIndex, tx) {
|
|
743
|
+
const success = tx.status === "success";
|
|
744
|
+
const transactionHash = tx.id || tx.tx?.hash || "";
|
|
745
|
+
const gasUsed = tx.tx?.gasLimit || "0";
|
|
746
|
+
const gasPrice = tx.tx?.gasPrice || "0";
|
|
747
|
+
const blockNumber = tx.tx?.blockNumber || "0";
|
|
748
|
+
const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice];
|
|
749
|
+
const stringValues = rawValues.map(String);
|
|
750
|
+
return {
|
|
751
|
+
status: success ? "success" : "error",
|
|
752
|
+
warp,
|
|
753
|
+
action: actionIndex,
|
|
754
|
+
user: getWarpWalletAddressFromConfig(this.config, this.chain.name),
|
|
755
|
+
txHash: transactionHash,
|
|
756
|
+
tx,
|
|
757
|
+
next: null,
|
|
758
|
+
values: { string: stringValues, native: rawValues },
|
|
759
|
+
output: {},
|
|
760
|
+
messages: {},
|
|
761
|
+
destination: null
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
handleTransactionReceipt(warp, actionIndex, tx) {
|
|
586
765
|
const success = tx.status === 1;
|
|
587
766
|
const gasUsed = tx.gasUsed?.toString() || "0";
|
|
588
767
|
const gasPrice = tx.gasPrice?.toString() || "0";
|
|
@@ -590,63 +769,93 @@ var WarpEvmResults = class {
|
|
|
590
769
|
const transactionHash = tx.hash;
|
|
591
770
|
const logs = tx.logs.map((log) => ({
|
|
592
771
|
address: log.address,
|
|
593
|
-
topics: log.topics,
|
|
772
|
+
topics: [...log.topics],
|
|
594
773
|
data: log.data,
|
|
595
774
|
blockNumber: log.blockNumber?.toString() || "0",
|
|
596
775
|
transactionHash: log.transactionHash,
|
|
597
776
|
index: log.index?.toString() || "0"
|
|
598
777
|
}));
|
|
778
|
+
const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
|
|
779
|
+
const stringValues = rawValues.map(String);
|
|
599
780
|
return {
|
|
600
|
-
success,
|
|
781
|
+
status: success ? "success" : "error",
|
|
601
782
|
warp,
|
|
602
|
-
action:
|
|
603
|
-
user: this.config.
|
|
783
|
+
action: actionIndex,
|
|
784
|
+
user: getWarpWalletAddressFromConfig(this.config, this.chain.name),
|
|
604
785
|
txHash: transactionHash,
|
|
786
|
+
tx,
|
|
605
787
|
next: null,
|
|
606
|
-
values:
|
|
607
|
-
|
|
608
|
-
messages: {}
|
|
788
|
+
values: { string: stringValues, native: rawValues },
|
|
789
|
+
output: {},
|
|
790
|
+
messages: {},
|
|
791
|
+
destination: null
|
|
609
792
|
};
|
|
610
793
|
}
|
|
611
|
-
async
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
794
|
+
async extractQueryOutput(warp, typedValues, actionIndex, inputs) {
|
|
795
|
+
const stringValues = typedValues.map((t) => this.serializer.typedToString(t));
|
|
796
|
+
const nativeValues = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
|
|
797
|
+
const values = { string: stringValues, native: nativeValues };
|
|
798
|
+
let output = {};
|
|
799
|
+
if (!warp.output) return { values, output };
|
|
616
800
|
const getNestedValue = (path) => {
|
|
617
801
|
const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
|
|
618
802
|
if (indices.length === 0) return void 0;
|
|
619
|
-
let value =
|
|
803
|
+
let value = nativeValues[indices[0]];
|
|
620
804
|
for (let i = 1; i < indices.length; i++) {
|
|
621
805
|
if (value === void 0 || value === null) return void 0;
|
|
622
806
|
value = value[indices[i]];
|
|
623
807
|
}
|
|
624
808
|
return value;
|
|
625
809
|
};
|
|
626
|
-
for (const [key, path] of Object.entries(warp.
|
|
810
|
+
for (const [key, path] of Object.entries(warp.output)) {
|
|
627
811
|
if (path.startsWith(WarpConstants2.Transform.Prefix)) continue;
|
|
628
|
-
const currentActionIndex =
|
|
812
|
+
const currentActionIndex = parseOutputOutIndex(path);
|
|
629
813
|
if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
|
|
630
|
-
|
|
814
|
+
output[key] = null;
|
|
631
815
|
continue;
|
|
632
816
|
}
|
|
633
817
|
if (path.startsWith("out.") || path === "out" || path.startsWith("out[")) {
|
|
634
|
-
|
|
818
|
+
output[key] = getNestedValue(path) || null;
|
|
635
819
|
} else {
|
|
636
|
-
|
|
820
|
+
output[key] = path;
|
|
637
821
|
}
|
|
638
822
|
}
|
|
639
|
-
return { values,
|
|
823
|
+
return { values, output: await evaluateOutputCommon(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
|
|
824
|
+
}
|
|
825
|
+
async getTransactionStatus(txHash) {
|
|
826
|
+
try {
|
|
827
|
+
const receipt = await this.provider.getTransactionReceipt(txHash);
|
|
828
|
+
if (!receipt) {
|
|
829
|
+
return { status: "pending" };
|
|
830
|
+
}
|
|
831
|
+
return {
|
|
832
|
+
status: receipt.status === 1 ? "confirmed" : "failed",
|
|
833
|
+
blockNumber: receipt.blockNumber,
|
|
834
|
+
gasUsed: receipt.gasUsed
|
|
835
|
+
};
|
|
836
|
+
} catch (error) {
|
|
837
|
+
throw new Error(`Failed to get transaction status: ${error}`);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
async getTransactionReceipt(txHash) {
|
|
841
|
+
try {
|
|
842
|
+
return await this.provider.getTransactionReceipt(txHash);
|
|
843
|
+
} catch (error) {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
640
846
|
}
|
|
641
847
|
};
|
|
642
848
|
|
|
643
849
|
// src/WarpEvmExecutor.ts
|
|
644
850
|
var WarpEvmExecutor = class {
|
|
645
|
-
constructor(config) {
|
|
851
|
+
constructor(config, chain) {
|
|
646
852
|
this.config = config;
|
|
853
|
+
this.chain = chain;
|
|
647
854
|
this.serializer = new WarpEvmSerializer();
|
|
648
|
-
|
|
649
|
-
|
|
855
|
+
const providerConfig = getProviderConfig3(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
|
|
856
|
+
const network = new ethers4.Network(this.chain.name, parseInt(this.chain.chainId));
|
|
857
|
+
this.provider = new ethers4.JsonRpcProvider(providerConfig.url, network);
|
|
858
|
+
this.output = new WarpEvmOutput(config, this.chain);
|
|
650
859
|
}
|
|
651
860
|
async createTransaction(executable) {
|
|
652
861
|
const action = getWarpActionByIndex(executable.warp, executable.action);
|
|
@@ -664,13 +873,13 @@ var WarpEvmExecutor = class {
|
|
|
664
873
|
return tx;
|
|
665
874
|
}
|
|
666
875
|
async createTransferTransaction(executable) {
|
|
667
|
-
const userWallet = this.config
|
|
876
|
+
const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
|
|
668
877
|
if (!userWallet) throw new Error("WarpEvmExecutor: createTransfer - user address not set");
|
|
669
|
-
if (!
|
|
878
|
+
if (!ethers4.isAddress(executable.destination)) {
|
|
670
879
|
throw new Error(`WarpEvmExecutor: Invalid destination address: ${executable.destination}`);
|
|
671
880
|
}
|
|
672
|
-
if (executable.
|
|
673
|
-
|
|
881
|
+
if (executable.transfers && executable.transfers.length > 0) {
|
|
882
|
+
return this.createTokenTransferTransaction(executable, userWallet);
|
|
674
883
|
}
|
|
675
884
|
const tx = {
|
|
676
885
|
to: executable.destination,
|
|
@@ -680,21 +889,20 @@ var WarpEvmExecutor = class {
|
|
|
680
889
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
681
890
|
}
|
|
682
891
|
async createContractCallTransaction(executable) {
|
|
683
|
-
const userWallet = this.config
|
|
892
|
+
const userWallet = getWarpWalletAddressFromConfig2(this.config, executable.chain.name);
|
|
684
893
|
if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
|
|
685
894
|
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
|
-
}
|
|
895
|
+
if (!action || !("func" in action) || !action.func) throw new Error("WarpEvmExecutor: Contract action must have a function name");
|
|
896
|
+
if (!ethers4.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
|
|
695
897
|
try {
|
|
696
|
-
|
|
697
|
-
|
|
898
|
+
let iface;
|
|
899
|
+
try {
|
|
900
|
+
iface = new ethers4.Interface(JSON.parse(action.abi));
|
|
901
|
+
} catch {
|
|
902
|
+
iface = new ethers4.Interface([action.abi]);
|
|
903
|
+
}
|
|
904
|
+
const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
|
|
905
|
+
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
698
906
|
const tx = {
|
|
699
907
|
to: executable.destination,
|
|
700
908
|
value: executable.value,
|
|
@@ -705,101 +913,117 @@ var WarpEvmExecutor = class {
|
|
|
705
913
|
throw new Error(`WarpEvmExecutor: Failed to encode function data for ${action.func}: ${error}`);
|
|
706
914
|
}
|
|
707
915
|
}
|
|
708
|
-
async
|
|
709
|
-
|
|
710
|
-
if (
|
|
711
|
-
|
|
916
|
+
async createTokenTransferTransaction(executable, userWallet) {
|
|
917
|
+
if (executable.transfers.length === 0) throw new Error("WarpEvmExecutor: No transfers provided");
|
|
918
|
+
if (!this.chain.nativeToken?.identifier) throw new Error("WarpEvmExecutor: No native token defined for this chain");
|
|
919
|
+
const nativeTokenTransfers = executable.transfers.filter((transfer) => transfer.identifier === this.chain.nativeToken.identifier);
|
|
920
|
+
const erc20Transfers = executable.transfers.filter((transfer) => transfer.identifier !== this.chain.nativeToken.identifier);
|
|
921
|
+
if (nativeTokenTransfers.length === 1 && erc20Transfers.length === 0) {
|
|
922
|
+
const transfer = nativeTokenTransfers[0];
|
|
923
|
+
if (transfer.amount <= 0n) throw new Error("WarpEvmExecutor: Native token transfer amount must be positive");
|
|
924
|
+
const tx = {
|
|
925
|
+
to: executable.destination,
|
|
926
|
+
value: transfer.amount,
|
|
927
|
+
data: "0x"
|
|
928
|
+
};
|
|
929
|
+
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
712
930
|
}
|
|
713
|
-
if (
|
|
714
|
-
|
|
931
|
+
if (nativeTokenTransfers.length === 0 && erc20Transfers.length === 1) {
|
|
932
|
+
return this.createSingleTokenTransfer(executable, erc20Transfers[0], userWallet);
|
|
715
933
|
}
|
|
716
|
-
if (
|
|
717
|
-
|
|
934
|
+
if (executable.transfers.length > 1) throw new Error("WarpEvmExecutor: Multiple token transfers not yet supported");
|
|
935
|
+
throw new Error("WarpEvmExecutor: Invalid transfer configuration");
|
|
936
|
+
}
|
|
937
|
+
async createSingleTokenTransfer(executable, transfer, userWallet) {
|
|
938
|
+
if (!ethers4.isAddress(transfer.identifier)) {
|
|
939
|
+
throw new Error(`WarpEvmExecutor: Invalid token address: ${transfer.identifier}`);
|
|
718
940
|
}
|
|
941
|
+
const transferInterface = new ethers4.Interface(["function transfer(address to, uint256 amount) returns (bool)"]);
|
|
942
|
+
const encodedData = transferInterface.encodeFunctionData("transfer", [executable.destination, transfer.amount]);
|
|
943
|
+
const tx = {
|
|
944
|
+
to: transfer.identifier,
|
|
945
|
+
value: 0n,
|
|
946
|
+
data: encodedData
|
|
947
|
+
};
|
|
948
|
+
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
949
|
+
}
|
|
950
|
+
async executeQuery(executable) {
|
|
951
|
+
const action = getWarpActionByIndex(executable.warp, executable.action);
|
|
952
|
+
if (action.type !== "query") throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
|
|
953
|
+
if (!action.func) throw new Error("WarpEvmExecutor: Query action must have a function name");
|
|
954
|
+
if (!ethers4.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid address for query: ${executable.destination}`);
|
|
719
955
|
try {
|
|
720
|
-
|
|
721
|
-
|
|
956
|
+
let iface;
|
|
957
|
+
try {
|
|
958
|
+
iface = new ethers4.Interface(JSON.parse(action.abi));
|
|
959
|
+
} catch {
|
|
960
|
+
iface = new ethers4.Interface([action.abi]);
|
|
961
|
+
}
|
|
962
|
+
const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
|
|
963
|
+
const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
|
|
722
964
|
const result = await this.provider.call({
|
|
723
965
|
to: executable.destination,
|
|
724
966
|
data: encodedData
|
|
725
967
|
});
|
|
726
968
|
const decodedResult = iface.decodeFunctionResult(action.func, result);
|
|
727
969
|
const isSuccess = true;
|
|
728
|
-
const { values,
|
|
970
|
+
const { values, output } = await this.output.extractQueryOutput(
|
|
729
971
|
executable.warp,
|
|
730
972
|
decodedResult,
|
|
731
973
|
executable.action,
|
|
732
974
|
executable.resolvedInputs
|
|
733
975
|
);
|
|
734
|
-
const next = getNextInfo(this.config, [], executable.warp, executable.action,
|
|
976
|
+
const next = getNextInfo(this.config, [], executable.warp, executable.action, output);
|
|
977
|
+
const destinationInput = executable.resolvedInputs.find(
|
|
978
|
+
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
979
|
+
);
|
|
980
|
+
const destination = destinationInput?.value || executable.destination;
|
|
735
981
|
return {
|
|
736
|
-
success:
|
|
982
|
+
status: isSuccess ? "success" : "error",
|
|
737
983
|
warp: executable.warp,
|
|
738
984
|
action: executable.action,
|
|
739
|
-
user: this.config
|
|
985
|
+
user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
|
|
740
986
|
txHash: null,
|
|
987
|
+
tx: null,
|
|
741
988
|
next,
|
|
742
989
|
values,
|
|
743
|
-
|
|
744
|
-
messages:
|
|
990
|
+
output: { ...output, _DATA: decodedResult },
|
|
991
|
+
messages: applyOutputToMessages(executable.warp, output, this.config),
|
|
992
|
+
destination
|
|
745
993
|
};
|
|
746
994
|
} catch (error) {
|
|
995
|
+
const destinationInput = executable.resolvedInputs.find(
|
|
996
|
+
(i) => i.input.position === "receiver" || i.input.position === "destination"
|
|
997
|
+
);
|
|
998
|
+
const destination = destinationInput?.value || executable.destination;
|
|
747
999
|
return {
|
|
748
|
-
|
|
1000
|
+
status: "error",
|
|
749
1001
|
warp: executable.warp,
|
|
750
1002
|
action: executable.action,
|
|
751
|
-
user: this.config
|
|
1003
|
+
user: getWarpWalletAddressFromConfig2(this.config, executable.chain.name),
|
|
752
1004
|
txHash: null,
|
|
1005
|
+
tx: null,
|
|
753
1006
|
next: null,
|
|
754
|
-
values: [],
|
|
755
|
-
|
|
756
|
-
messages: {}
|
|
1007
|
+
values: { string: [], native: [] },
|
|
1008
|
+
output: { _DATA: error },
|
|
1009
|
+
messages: {},
|
|
1010
|
+
destination
|
|
757
1011
|
};
|
|
758
1012
|
}
|
|
759
1013
|
}
|
|
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
1014
|
async estimateGasAndSetDefaults(tx, from) {
|
|
788
1015
|
try {
|
|
789
1016
|
const gasEstimate = await this.provider.estimateGas({
|
|
790
1017
|
...tx,
|
|
791
1018
|
from
|
|
792
1019
|
});
|
|
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
|
-
}
|
|
1020
|
+
if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) throw new Error(`Gas estimate too low: ${gasEstimate}`);
|
|
1021
|
+
if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) throw new Error(`Gas estimate too high: ${gasEstimate}`);
|
|
799
1022
|
const feeData = await this.provider.getFeeData();
|
|
800
1023
|
if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
|
|
801
1024
|
return {
|
|
802
1025
|
...tx,
|
|
1026
|
+
chainId: parseInt(this.chain.chainId),
|
|
803
1027
|
gasLimit: gasEstimate,
|
|
804
1028
|
maxFeePerGas: feeData.maxFeePerGas,
|
|
805
1029
|
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
|
|
@@ -807,32 +1031,44 @@ var WarpEvmExecutor = class {
|
|
|
807
1031
|
} else if (feeData.gasPrice) {
|
|
808
1032
|
return {
|
|
809
1033
|
...tx,
|
|
1034
|
+
chainId: parseInt(this.chain.chainId),
|
|
810
1035
|
gasLimit: gasEstimate,
|
|
811
1036
|
gasPrice: feeData.gasPrice
|
|
812
1037
|
};
|
|
813
1038
|
} else {
|
|
814
1039
|
return {
|
|
815
1040
|
...tx,
|
|
1041
|
+
chainId: parseInt(this.chain.chainId),
|
|
816
1042
|
gasLimit: gasEstimate,
|
|
817
|
-
gasPrice:
|
|
1043
|
+
gasPrice: ethers4.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
818
1044
|
};
|
|
819
1045
|
}
|
|
820
1046
|
} catch (error) {
|
|
821
1047
|
let defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Default);
|
|
822
1048
|
if (tx.data && tx.data !== "0x") {
|
|
823
|
-
|
|
1049
|
+
if (tx.data.startsWith("0xa9059cbb")) {
|
|
1050
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.TokenTransfer);
|
|
1051
|
+
} else {
|
|
1052
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.ContractCall);
|
|
1053
|
+
}
|
|
824
1054
|
} else {
|
|
825
1055
|
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Transfer);
|
|
826
1056
|
}
|
|
827
1057
|
return {
|
|
828
1058
|
...tx,
|
|
1059
|
+
chainId: parseInt(this.chain.chainId),
|
|
829
1060
|
gasLimit: defaultGasLimit,
|
|
830
|
-
gasPrice:
|
|
1061
|
+
gasPrice: ethers4.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
831
1062
|
};
|
|
832
1063
|
}
|
|
833
1064
|
}
|
|
834
|
-
async
|
|
835
|
-
|
|
1065
|
+
async verifyMessage(message, signature) {
|
|
1066
|
+
try {
|
|
1067
|
+
const recoveredAddress = ethers4.verifyMessage(message, signature);
|
|
1068
|
+
return recoveredAddress;
|
|
1069
|
+
} catch (error) {
|
|
1070
|
+
throw new Error(`Failed to verify message: ${error}`);
|
|
1071
|
+
}
|
|
836
1072
|
}
|
|
837
1073
|
};
|
|
838
1074
|
|
|
@@ -920,154 +1156,379 @@ var WarpEvmExplorer = class {
|
|
|
920
1156
|
});
|
|
921
1157
|
return urls;
|
|
922
1158
|
}
|
|
1159
|
+
getAssetUrls(identifier) {
|
|
1160
|
+
const explorers = this.getAllExplorers();
|
|
1161
|
+
const urls = {};
|
|
1162
|
+
explorers.forEach((explorer) => {
|
|
1163
|
+
const url = ExplorerUrls[explorer];
|
|
1164
|
+
if (url) {
|
|
1165
|
+
urls[explorer] = `${url}/token/${identifier}`;
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
return urls;
|
|
1169
|
+
}
|
|
1170
|
+
getContractUrls(address) {
|
|
1171
|
+
const explorers = this.getAllExplorers();
|
|
1172
|
+
const urls = {};
|
|
1173
|
+
explorers.forEach((explorer) => {
|
|
1174
|
+
const url = ExplorerUrls[explorer];
|
|
1175
|
+
if (url) {
|
|
1176
|
+
urls[explorer] = `${url}/address/${address}`;
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
return urls;
|
|
1180
|
+
}
|
|
1181
|
+
getBlockUrls(blockNumber) {
|
|
1182
|
+
const explorers = this.getAllExplorers();
|
|
1183
|
+
const urls = {};
|
|
1184
|
+
explorers.forEach((explorer) => {
|
|
1185
|
+
const url = ExplorerUrls[explorer];
|
|
1186
|
+
if (url) {
|
|
1187
|
+
urls[explorer] = `${url}/block/${blockNumber}`;
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
return urls;
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// src/WarpEvmWallet.ts
|
|
1195
|
+
import {
|
|
1196
|
+
getProviderConfig as getProviderConfig4,
|
|
1197
|
+
getWarpWalletMnemonicFromConfig,
|
|
1198
|
+
getWarpWalletPrivateKeyFromConfig
|
|
1199
|
+
} from "@vleap/warps";
|
|
1200
|
+
import { ethers as ethers5 } from "ethers";
|
|
1201
|
+
var WarpEvmWallet = class {
|
|
1202
|
+
constructor(config, chain) {
|
|
1203
|
+
this.config = config;
|
|
1204
|
+
this.chain = chain;
|
|
1205
|
+
const providerConfig = getProviderConfig4(config, chain.name, config.env, chain.defaultApiUrl);
|
|
1206
|
+
this.provider = new ethers5.JsonRpcProvider(providerConfig.url);
|
|
1207
|
+
}
|
|
1208
|
+
async signTransaction(tx) {
|
|
1209
|
+
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
1210
|
+
const wallet = this.getWallet();
|
|
1211
|
+
const txRequest = {
|
|
1212
|
+
to: tx.to,
|
|
1213
|
+
data: tx.data,
|
|
1214
|
+
value: tx.value || 0,
|
|
1215
|
+
gasLimit: tx.gasLimit,
|
|
1216
|
+
maxFeePerGas: tx.maxFeePerGas,
|
|
1217
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
|
|
1218
|
+
nonce: tx.nonce,
|
|
1219
|
+
chainId: tx.chainId
|
|
1220
|
+
};
|
|
1221
|
+
const signedTx = await wallet.signTransaction(txRequest);
|
|
1222
|
+
return { ...tx, signature: signedTx };
|
|
1223
|
+
}
|
|
1224
|
+
async signTransactions(txs) {
|
|
1225
|
+
if (txs.length === 0) return [];
|
|
1226
|
+
if (txs.length > 1) {
|
|
1227
|
+
const wallet = this.getWallet();
|
|
1228
|
+
const address = wallet.address;
|
|
1229
|
+
const currentNonce = await this.provider.getTransactionCount(address, "pending");
|
|
1230
|
+
const signedTxs = [];
|
|
1231
|
+
for (let i = 0; i < txs.length; i++) {
|
|
1232
|
+
const tx = { ...txs[i] };
|
|
1233
|
+
tx.nonce = currentNonce + i;
|
|
1234
|
+
if (i > 0) {
|
|
1235
|
+
const priorityReduction = BigInt(i * 1e9);
|
|
1236
|
+
const minGasPrice = BigInt(1e9);
|
|
1237
|
+
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
|
1238
|
+
tx.maxFeePerGas = tx.maxFeePerGas > priorityReduction ? tx.maxFeePerGas - priorityReduction : minGasPrice;
|
|
1239
|
+
tx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas > priorityReduction ? tx.maxPriorityFeePerGas - priorityReduction : minGasPrice;
|
|
1240
|
+
delete tx.gasPrice;
|
|
1241
|
+
} else if (tx.gasPrice) {
|
|
1242
|
+
tx.gasPrice = tx.gasPrice > priorityReduction ? tx.gasPrice - priorityReduction : minGasPrice;
|
|
1243
|
+
delete tx.maxFeePerGas;
|
|
1244
|
+
delete tx.maxPriorityFeePerGas;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const signedTx = await this.signTransaction(tx);
|
|
1248
|
+
signedTxs.push(signedTx);
|
|
1249
|
+
}
|
|
1250
|
+
return signedTxs;
|
|
1251
|
+
}
|
|
1252
|
+
return Promise.all(txs.map(async (tx) => this.signTransaction(tx)));
|
|
1253
|
+
}
|
|
1254
|
+
async signMessage(message) {
|
|
1255
|
+
const wallet = this.getWallet();
|
|
1256
|
+
const signature = await wallet.signMessage(message);
|
|
1257
|
+
return signature;
|
|
1258
|
+
}
|
|
1259
|
+
async sendTransaction(tx) {
|
|
1260
|
+
if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
|
|
1261
|
+
if (!tx.signature) throw new Error("Transaction must be signed before sending");
|
|
1262
|
+
const wallet = this.getWallet();
|
|
1263
|
+
if (!wallet) throw new Error("Wallet not initialized - no private key provided");
|
|
1264
|
+
const connectedWallet = wallet.connect(this.provider);
|
|
1265
|
+
const txResponse = await connectedWallet.sendTransaction(tx);
|
|
1266
|
+
return txResponse.hash;
|
|
1267
|
+
}
|
|
1268
|
+
async sendTransactions(txs) {
|
|
1269
|
+
return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
|
|
1270
|
+
}
|
|
1271
|
+
create(mnemonic) {
|
|
1272
|
+
const wallet = ethers5.Wallet.fromPhrase(mnemonic);
|
|
1273
|
+
return { address: wallet.address, privateKey: wallet.privateKey, mnemonic };
|
|
1274
|
+
}
|
|
1275
|
+
generate() {
|
|
1276
|
+
const wallet = ethers5.Wallet.createRandom();
|
|
1277
|
+
return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
|
|
1278
|
+
}
|
|
1279
|
+
getAddress() {
|
|
1280
|
+
const wallet = this.getWallet();
|
|
1281
|
+
return wallet.address;
|
|
1282
|
+
}
|
|
1283
|
+
getWallet() {
|
|
1284
|
+
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
1285
|
+
if (privateKey) return new ethers5.Wallet(privateKey);
|
|
1286
|
+
const mnemonic = getWarpWalletMnemonicFromConfig(this.config, this.chain.name);
|
|
1287
|
+
if (mnemonic) return ethers5.Wallet.fromPhrase(mnemonic);
|
|
1288
|
+
throw new Error("No private key or mnemonic provided");
|
|
1289
|
+
}
|
|
923
1290
|
};
|
|
924
1291
|
|
|
925
1292
|
// src/chains/common.ts
|
|
926
|
-
var createEvmAdapter = (chainName,
|
|
1293
|
+
var createEvmAdapter = (chainName, chainInfos) => {
|
|
927
1294
|
return (config, fallback) => {
|
|
928
1295
|
if (!fallback) throw new Error(`${chainName} adapter requires a fallback adapter`);
|
|
929
1296
|
return {
|
|
930
|
-
chain: chainName,
|
|
931
1297
|
chainInfo: chainInfos[config.env],
|
|
932
|
-
prefix: chainPrefix,
|
|
933
1298
|
builder: () => fallback.builder(),
|
|
934
|
-
executor: new WarpEvmExecutor(config),
|
|
935
|
-
|
|
1299
|
+
executor: new WarpEvmExecutor(config, chainInfos[config.env]),
|
|
1300
|
+
output: new WarpEvmOutput(config, chainInfos[config.env]),
|
|
936
1301
|
serializer: new WarpEvmSerializer(),
|
|
937
1302
|
registry: fallback.registry,
|
|
938
1303
|
explorer: new WarpEvmExplorer(chainInfos[config.env], config),
|
|
939
1304
|
abiBuilder: () => fallback.abiBuilder(),
|
|
940
1305
|
brandBuilder: () => fallback.brandBuilder(),
|
|
941
|
-
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env])
|
|
1306
|
+
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env]),
|
|
1307
|
+
wallet: new WarpEvmWallet(config, chainInfos[config.env])
|
|
942
1308
|
};
|
|
943
1309
|
};
|
|
944
1310
|
};
|
|
945
1311
|
|
|
946
1312
|
// src/chains/arbitrum.ts
|
|
947
|
-
var
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1313
|
+
var NativeTokenArb = {
|
|
1314
|
+
chain: WarpChainName6.Arbitrum,
|
|
1315
|
+
identifier: "ARB",
|
|
1316
|
+
symbol: "ARB",
|
|
1317
|
+
name: "Arbitrum",
|
|
1318
|
+
decimals: 18,
|
|
1319
|
+
logoUrl: "https://vleap.ai/images/tokens/arb.svg"
|
|
1320
|
+
};
|
|
1321
|
+
var getArbitrumAdapter = createEvmAdapter(WarpChainName6.Arbitrum, {
|
|
1322
|
+
mainnet: {
|
|
1323
|
+
name: WarpChainName6.Arbitrum,
|
|
1324
|
+
displayName: "Arbitrum",
|
|
1325
|
+
chainId: "42161",
|
|
953
1326
|
blockTime: 1e3,
|
|
954
1327
|
addressHrp: "0x",
|
|
955
|
-
|
|
956
|
-
|
|
1328
|
+
defaultApiUrl: "https://arb1.arbitrum.io/rpc",
|
|
1329
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1330
|
+
nativeToken: NativeTokenArb
|
|
957
1331
|
},
|
|
958
1332
|
testnet: {
|
|
959
|
-
name:
|
|
960
|
-
displayName: "Arbitrum
|
|
961
|
-
chainId: "
|
|
1333
|
+
name: WarpChainName6.Arbitrum,
|
|
1334
|
+
displayName: "Arbitrum Sepolia",
|
|
1335
|
+
chainId: "421614",
|
|
962
1336
|
blockTime: 1e3,
|
|
963
1337
|
addressHrp: "0x",
|
|
964
|
-
|
|
965
|
-
|
|
1338
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1339
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1340
|
+
nativeToken: NativeTokenArb
|
|
966
1341
|
},
|
|
967
|
-
|
|
968
|
-
name:
|
|
969
|
-
displayName: "Arbitrum",
|
|
970
|
-
chainId: "
|
|
1342
|
+
devnet: {
|
|
1343
|
+
name: WarpChainName6.Arbitrum,
|
|
1344
|
+
displayName: "Arbitrum Sepolia",
|
|
1345
|
+
chainId: "421614",
|
|
971
1346
|
blockTime: 1e3,
|
|
972
1347
|
addressHrp: "0x",
|
|
973
|
-
|
|
974
|
-
|
|
1348
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1349
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1350
|
+
nativeToken: NativeTokenArb
|
|
975
1351
|
}
|
|
976
1352
|
});
|
|
977
1353
|
|
|
978
1354
|
// src/chains/base.ts
|
|
979
|
-
|
|
980
|
-
var
|
|
1355
|
+
import { WarpChainName as WarpChainName7 } from "@vleap/warps";
|
|
1356
|
+
var NativeTokenBase = {
|
|
1357
|
+
chain: WarpChainName7.Base,
|
|
1358
|
+
identifier: "ETH",
|
|
1359
|
+
name: "Ether",
|
|
1360
|
+
symbol: "ETH",
|
|
1361
|
+
decimals: 18,
|
|
1362
|
+
logoUrl: "https://vleap.ai/images/tokens/eth.svg"
|
|
1363
|
+
};
|
|
1364
|
+
var getBaseAdapter = createEvmAdapter(WarpChainName7.Base, {
|
|
981
1365
|
mainnet: {
|
|
982
|
-
name:
|
|
1366
|
+
name: WarpChainName7.Base,
|
|
983
1367
|
displayName: "Base",
|
|
984
1368
|
chainId: "8453",
|
|
985
1369
|
blockTime: 2e3,
|
|
986
1370
|
addressHrp: "0x",
|
|
987
|
-
|
|
988
|
-
|
|
1371
|
+
defaultApiUrl: "https://mainnet.base.org",
|
|
1372
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1373
|
+
nativeToken: NativeTokenBase
|
|
989
1374
|
},
|
|
990
1375
|
testnet: {
|
|
991
|
-
name:
|
|
992
|
-
displayName: "Base
|
|
993
|
-
chainId: "
|
|
1376
|
+
name: WarpChainName7.Base,
|
|
1377
|
+
displayName: "Base Sepolia",
|
|
1378
|
+
chainId: "84532",
|
|
994
1379
|
blockTime: 2e3,
|
|
995
1380
|
addressHrp: "0x",
|
|
996
|
-
|
|
997
|
-
|
|
1381
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1382
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1383
|
+
nativeToken: NativeTokenBase
|
|
998
1384
|
},
|
|
999
1385
|
devnet: {
|
|
1000
|
-
name:
|
|
1001
|
-
displayName: "Base
|
|
1386
|
+
name: WarpChainName7.Base,
|
|
1387
|
+
displayName: "Base Sepolia",
|
|
1002
1388
|
chainId: "84532",
|
|
1003
1389
|
blockTime: 2e3,
|
|
1004
1390
|
addressHrp: "0x",
|
|
1005
|
-
|
|
1006
|
-
|
|
1391
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1392
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1393
|
+
nativeToken: NativeTokenBase
|
|
1007
1394
|
}
|
|
1008
1395
|
});
|
|
1009
1396
|
|
|
1397
|
+
// src/chains/combined.ts
|
|
1398
|
+
import { WarpChainName as WarpChainName10 } from "@vleap/warps";
|
|
1399
|
+
|
|
1010
1400
|
// src/chains/ethereum.ts
|
|
1011
|
-
|
|
1012
|
-
var
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1401
|
+
import { WarpChainName as WarpChainName8 } from "@vleap/warps";
|
|
1402
|
+
var NativeTokenEth = {
|
|
1403
|
+
chain: WarpChainName8.Ethereum,
|
|
1404
|
+
identifier: "ETH",
|
|
1405
|
+
symbol: "ETH",
|
|
1406
|
+
name: "Ether",
|
|
1407
|
+
decimals: 18,
|
|
1408
|
+
logoUrl: "https://vleap.ai/images/tokens/eth.svg"
|
|
1409
|
+
};
|
|
1410
|
+
var getEthereumAdapter = createEvmAdapter(WarpChainName8.Ethereum, {
|
|
1411
|
+
mainnet: {
|
|
1412
|
+
name: WarpChainName8.Ethereum,
|
|
1413
|
+
displayName: "Ethereum Mainnet",
|
|
1414
|
+
chainId: "1",
|
|
1017
1415
|
blockTime: 12e3,
|
|
1018
1416
|
addressHrp: "0x",
|
|
1019
|
-
|
|
1020
|
-
|
|
1417
|
+
defaultApiUrl: "https://ethereum-rpc.publicnode.com",
|
|
1418
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1419
|
+
nativeToken: NativeTokenEth
|
|
1021
1420
|
},
|
|
1022
1421
|
testnet: {
|
|
1023
|
-
name:
|
|
1024
|
-
displayName: "Ethereum
|
|
1025
|
-
chainId: "
|
|
1422
|
+
name: WarpChainName8.Ethereum,
|
|
1423
|
+
displayName: "Ethereum Sepolia",
|
|
1424
|
+
chainId: "11155111",
|
|
1026
1425
|
blockTime: 12e3,
|
|
1027
1426
|
addressHrp: "0x",
|
|
1028
|
-
|
|
1029
|
-
|
|
1427
|
+
defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1428
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1429
|
+
nativeToken: NativeTokenEth
|
|
1030
1430
|
},
|
|
1031
|
-
|
|
1032
|
-
name:
|
|
1033
|
-
displayName: "Ethereum
|
|
1034
|
-
chainId: "
|
|
1431
|
+
devnet: {
|
|
1432
|
+
name: WarpChainName8.Ethereum,
|
|
1433
|
+
displayName: "Ethereum Sepolia",
|
|
1434
|
+
chainId: "11155111",
|
|
1035
1435
|
blockTime: 12e3,
|
|
1036
1436
|
addressHrp: "0x",
|
|
1037
|
-
|
|
1038
|
-
|
|
1437
|
+
defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1438
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1439
|
+
nativeToken: NativeTokenEth
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
// src/chains/somnia.ts
|
|
1444
|
+
import { WarpChainName as WarpChainName9 } from "@vleap/warps";
|
|
1445
|
+
var NativeTokenSomi = {
|
|
1446
|
+
chain: WarpChainName9.Somnia,
|
|
1447
|
+
identifier: "SOMI",
|
|
1448
|
+
symbol: "SOMI",
|
|
1449
|
+
name: "Somnia",
|
|
1450
|
+
decimals: 18,
|
|
1451
|
+
logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
|
|
1452
|
+
};
|
|
1453
|
+
var NativeTokenStt = {
|
|
1454
|
+
chain: WarpChainName9.Somnia,
|
|
1455
|
+
identifier: "STT",
|
|
1456
|
+
symbol: "STT",
|
|
1457
|
+
name: "Somnia Testnet Token",
|
|
1458
|
+
decimals: 18,
|
|
1459
|
+
logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
|
|
1460
|
+
};
|
|
1461
|
+
var getSomniaAdapter = createEvmAdapter(WarpChainName9.Somnia, {
|
|
1462
|
+
mainnet: {
|
|
1463
|
+
name: WarpChainName9.Somnia,
|
|
1464
|
+
displayName: "Somnia Mainnet",
|
|
1465
|
+
chainId: "5031",
|
|
1466
|
+
blockTime: 100,
|
|
1467
|
+
addressHrp: "0x",
|
|
1468
|
+
defaultApiUrl: "https://api.infra.mainnet.somnia.network/",
|
|
1469
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1470
|
+
nativeToken: NativeTokenSomi
|
|
1471
|
+
},
|
|
1472
|
+
testnet: {
|
|
1473
|
+
name: WarpChainName9.Somnia,
|
|
1474
|
+
displayName: "Somnia Testnet",
|
|
1475
|
+
chainId: "50312",
|
|
1476
|
+
blockTime: 100,
|
|
1477
|
+
addressHrp: "0x",
|
|
1478
|
+
defaultApiUrl: "https://dream-rpc.somnia.network/",
|
|
1479
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1480
|
+
nativeToken: NativeTokenStt
|
|
1481
|
+
},
|
|
1482
|
+
devnet: {
|
|
1483
|
+
name: WarpChainName9.Somnia,
|
|
1484
|
+
displayName: "Somnia Testnet",
|
|
1485
|
+
chainId: "50312",
|
|
1486
|
+
blockTime: 100,
|
|
1487
|
+
addressHrp: "0x",
|
|
1488
|
+
defaultApiUrl: "https://dream-rpc.somnia.network",
|
|
1489
|
+
logoUrl: "https://vleap.ai/images/chains/somnia.png",
|
|
1490
|
+
nativeToken: NativeTokenStt
|
|
1039
1491
|
}
|
|
1040
1492
|
});
|
|
1041
1493
|
|
|
1042
1494
|
// src/chains/combined.ts
|
|
1043
1495
|
var getAllEvmAdapters = (config, fallback) => [
|
|
1044
1496
|
getEthereumAdapter(config, fallback),
|
|
1497
|
+
getBaseAdapter(config, fallback),
|
|
1045
1498
|
getArbitrumAdapter(config, fallback),
|
|
1046
|
-
|
|
1499
|
+
getSomniaAdapter(config, fallback)
|
|
1500
|
+
];
|
|
1501
|
+
var getAllEvmChainNames = () => [
|
|
1502
|
+
WarpChainName10.Ethereum,
|
|
1503
|
+
WarpChainName10.Base,
|
|
1504
|
+
WarpChainName10.Arbitrum,
|
|
1505
|
+
WarpChainName10.Somnia
|
|
1047
1506
|
];
|
|
1048
|
-
var getAllEvmChainNames = () => [ChainNameArbitrum, ChainNameBase, ChainNameEthereum];
|
|
1049
1507
|
export {
|
|
1050
1508
|
ArbitrumExplorers,
|
|
1051
1509
|
BaseExplorers,
|
|
1052
|
-
ChainNameArbitrum,
|
|
1053
|
-
ChainNameBase,
|
|
1054
|
-
ChainNameEthereum,
|
|
1055
|
-
EVM_CHAIN_CONFIGS,
|
|
1056
1510
|
EthereumExplorers,
|
|
1057
1511
|
EvmExplorers,
|
|
1058
1512
|
ExplorerUrls,
|
|
1513
|
+
KnownTokens,
|
|
1514
|
+
NativeTokenArb,
|
|
1515
|
+
NativeTokenBase,
|
|
1516
|
+
NativeTokenEth,
|
|
1517
|
+
UniswapService,
|
|
1059
1518
|
WarpEvmConstants,
|
|
1519
|
+
WarpEvmDataLoader,
|
|
1060
1520
|
WarpEvmExecutor,
|
|
1061
1521
|
WarpEvmExplorer,
|
|
1062
|
-
|
|
1522
|
+
WarpEvmOutput,
|
|
1063
1523
|
WarpEvmSerializer,
|
|
1524
|
+
WarpEvmWallet,
|
|
1525
|
+
createEvmAdapter,
|
|
1526
|
+
findKnownTokenById,
|
|
1064
1527
|
getAllEvmAdapters,
|
|
1065
1528
|
getAllEvmChainNames,
|
|
1066
1529
|
getArbitrumAdapter,
|
|
1067
1530
|
getBaseAdapter,
|
|
1068
1531
|
getEthereumAdapter,
|
|
1069
|
-
|
|
1070
|
-
getEvmChainConfig,
|
|
1071
|
-
getEvmExplorerUrl
|
|
1532
|
+
getKnownTokensForChain
|
|
1072
1533
|
};
|
|
1073
1534
|
//# sourceMappingURL=index.mjs.map
|