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