@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.js CHANGED
@@ -22,130 +22,321 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ArbitrumExplorers: () => ArbitrumExplorers,
24
24
  BaseExplorers: () => BaseExplorers,
25
- ChainNameArbitrum: () => ChainNameArbitrum,
26
- ChainNameBase: () => ChainNameBase,
27
- ChainNameEthereum: () => ChainNameEthereum,
28
- EVM_CHAIN_CONFIGS: () => EVM_CHAIN_CONFIGS,
29
25
  EthereumExplorers: () => EthereumExplorers,
30
26
  EvmExplorers: () => EvmExplorers,
31
27
  ExplorerUrls: () => ExplorerUrls,
28
+ KnownTokens: () => KnownTokens,
29
+ NativeTokenArb: () => NativeTokenArb,
30
+ NativeTokenBase: () => NativeTokenBase,
31
+ NativeTokenEth: () => NativeTokenEth,
32
+ UniswapService: () => UniswapService,
32
33
  WarpEvmConstants: () => WarpEvmConstants,
34
+ WarpEvmDataLoader: () => WarpEvmDataLoader,
33
35
  WarpEvmExecutor: () => WarpEvmExecutor,
34
36
  WarpEvmExplorer: () => WarpEvmExplorer,
35
- WarpEvmResults: () => WarpEvmResults,
37
+ WarpEvmOutput: () => WarpEvmOutput,
36
38
  WarpEvmSerializer: () => WarpEvmSerializer,
39
+ WarpEvmWallet: () => WarpEvmWallet,
40
+ createEvmAdapter: () => createEvmAdapter,
41
+ findKnownTokenById: () => findKnownTokenById,
37
42
  getAllEvmAdapters: () => getAllEvmAdapters,
38
43
  getAllEvmChainNames: () => getAllEvmChainNames,
39
44
  getArbitrumAdapter: () => getArbitrumAdapter,
40
45
  getBaseAdapter: () => getBaseAdapter,
41
46
  getEthereumAdapter: () => getEthereumAdapter,
42
- getEvmApiUrl: () => getEvmApiUrl,
43
- getEvmChainConfig: () => getEvmChainConfig,
44
- getEvmExplorerUrl: () => getEvmExplorerUrl
47
+ getKnownTokensForChain: () => getKnownTokensForChain
45
48
  });
46
49
  module.exports = __toCommonJS(index_exports);
47
50
 
51
+ // src/chains/arbitrum.ts
52
+ var import_warps12 = require("@vleap/warps");
53
+
48
54
  // src/WarpEvmDataLoader.ts
55
+ var import_warps7 = require("@vleap/warps");
49
56
  var import_ethers = require("ethers");
50
57
 
51
- // src/config.ts
52
- var EVM_CHAIN_CONFIGS = {
53
- ethereum: {
54
- mainnet: {
55
- apiUrl: "https://eth-mainnet.g.alchemy.com/v2/demo",
56
- explorerUrl: "https://etherscan.io",
57
- chainId: "1",
58
- registryAddress: "0x0000000000000000000000000000000000000000",
59
- nativeToken: "ETH",
60
- blockTime: 12e3
61
- },
62
- testnet: {
63
- apiUrl: "https://eth-sepolia.g.alchemy.com/v2/demo",
64
- explorerUrl: "https://sepolia.etherscan.io",
65
- chainId: "11155111",
66
- registryAddress: "0x0000000000000000000000000000000000000000",
67
- nativeToken: "ETH",
68
- blockTime: 12e3
69
- },
70
- devnet: {
71
- apiUrl: "http://localhost:8545",
72
- explorerUrl: "http://localhost:4000",
73
- chainId: "1337",
74
- registryAddress: "0x0000000000000000000000000000000000000000",
75
- nativeToken: "ETH",
76
- blockTime: 12e3
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}`);
77
75
  }
78
- },
79
- arbitrum: {
80
- mainnet: {
81
- apiUrl: "https://arb-mainnet.g.alchemy.com/v2/demo",
82
- explorerUrl: "https://arbiscan.io",
83
- chainId: "42161",
84
- registryAddress: "0x0000000000000000000000000000000000000000",
85
- nativeToken: "ETH",
86
- blockTime: 1e3
87
- },
88
- testnet: {
89
- apiUrl: "https://arb-sepolia.g.alchemy.com/v2/demo",
90
- explorerUrl: "https://sepolia.arbiscan.io",
91
- chainId: "421614",
92
- registryAddress: "0x0000000000000000000000000000000000000000",
93
- nativeToken: "ETH",
94
- blockTime: 1e3
95
- },
96
- devnet: {
97
- apiUrl: "http://localhost:8545",
98
- explorerUrl: "http://localhost:4000",
99
- chainId: "1337",
100
- registryAddress: "0x0000000000000000000000000000000000000000",
101
- nativeToken: "ETH",
102
- blockTime: 1e3
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;
103
83
  }
104
- },
105
- base: {
106
- mainnet: {
107
- apiUrl: "https://mainnet.base.org",
108
- explorerUrl: "https://basescan.org",
109
- chainId: "8453",
110
- registryAddress: "0x0000000000000000000000000000000000000000",
111
- nativeToken: "ETH",
112
- blockTime: 2e3
113
- },
114
- testnet: {
115
- apiUrl: "https://sepolia.base.org",
116
- explorerUrl: "https://sepolia.basescan.org",
117
- chainId: "84532",
118
- registryAddress: "0x0000000000000000000000000000000000000000",
119
- nativeToken: "ETH",
120
- blockTime: 2e3
121
- },
122
- devnet: {
123
- apiUrl: "http://localhost:8545",
124
- explorerUrl: "http://localhost:4000",
125
- chainId: "1337",
126
- registryAddress: "0x0000000000000000000000000000000000000000",
127
- nativeToken: "ETH",
128
- blockTime: 2e3
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;
129
98
  }
130
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
+ }
131
140
  };
132
- var DEFAULT_CHAIN = "ethereum";
133
- var getEvmChainConfig = (chain = DEFAULT_CHAIN, env) => {
134
- const chainConfigs = EVM_CHAIN_CONFIGS[chain];
135
- if (!chainConfigs) {
136
- throw new Error(`Unsupported EVM chain: ${chain}`);
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"
137
171
  }
138
- const config = chainConfigs[env];
139
- if (!config) {
140
- throw new Error(`Unsupported environment ${env} for chain ${chain}`);
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
141
332
  }
142
- return config;
143
333
  };
144
- var getEvmApiUrl = (env, chain = DEFAULT_CHAIN) => {
145
- return getEvmChainConfig(chain, env).apiUrl;
334
+ var findKnownTokenById = (chain, env, id) => {
335
+ const chainTokens = KnownTokens[chain]?.[env] || [];
336
+ return chainTokens.find((token) => token.identifier === id) || null;
146
337
  };
147
- var getEvmExplorerUrl = (env, chain = DEFAULT_CHAIN) => {
148
- return getEvmChainConfig(chain, env).explorerUrl;
338
+ var getKnownTokensForChain = (chainName, env = "mainnet") => {
339
+ return KnownTokens[chainName]?.[env] || [];
149
340
  };
150
341
 
151
342
  // src/WarpEvmDataLoader.ts
@@ -156,233 +347,162 @@ var ERC20_ABI = [
156
347
  "function symbol() view returns (string)",
157
348
  "function totalSupply() view returns (uint256)"
158
349
  ];
159
- var KNOWN_TOKENS = {
160
- ethereum: {
161
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
162
- name: "USD Coin",
163
- symbol: "USDC",
164
- decimals: 6,
165
- logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
166
- },
167
- "0xdAC17F958D2ee523a2206206994597C13D831ec7": {
168
- name: "Tether USD",
169
- symbol: "USDT",
170
- decimals: 6,
171
- logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
172
- },
173
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
174
- name: "Wrapped Bitcoin",
175
- symbol: "WBTC",
176
- decimals: 8,
177
- logoUrl: "https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"
178
- },
179
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
180
- name: "Wrapped Ether",
181
- symbol: "WETH",
182
- decimals: 18,
183
- logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
184
- },
185
- "0x6B175474E89094C44Da98b954EedeAC495271d0F": {
186
- name: "Dai Stablecoin",
187
- symbol: "DAI",
188
- decimals: 18,
189
- logoUrl: "https://assets.coingecko.com/coins/images/9956/small/4943.png"
190
- }
191
- },
192
- arbitrum: {
193
- "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8": {
194
- name: "USD Coin",
195
- symbol: "USDC",
196
- decimals: 6,
197
- logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
198
- },
199
- "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9": {
200
- name: "Tether USD",
201
- symbol: "USDT",
202
- decimals: 6,
203
- logoUrl: "https://assets.coingecko.com/coins/images/325/small/Tether.png"
204
- },
205
- "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1": {
206
- name: "Wrapped Ether",
207
- symbol: "WETH",
208
- decimals: 18,
209
- logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
210
- }
211
- },
212
- base: {
213
- "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913": {
214
- name: "USD Coin",
215
- symbol: "USDC",
216
- decimals: 6,
217
- logoUrl: "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"
218
- },
219
- "0x4200000000000000000000000000000000000006": {
220
- name: "Wrapped Ether",
221
- symbol: "WETH",
222
- decimals: 18,
223
- logoUrl: "https://assets.coingecko.com/coins/images/2518/small/weth.png"
224
- }
225
- }
226
- };
227
350
  var WarpEvmDataLoader = class {
228
351
  constructor(config, chain) {
229
352
  this.config = config;
230
353
  this.chain = chain;
231
- this.provider = new import_ethers.ethers.JsonRpcProvider(getEvmApiUrl(this.config.env, this.chain.name));
232
- this.chainConfig = getEvmChainConfig(this.chain.name, this.config.env);
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));
233
359
  }
234
360
  async getAccount(address) {
235
- try {
236
- const balance = await this.provider.getBalance(address);
237
- return {
238
- address,
239
- balance
240
- };
241
- } catch (error) {
242
- throw new Error(`Failed to get account balance for ${address}: ${error}`);
243
- }
361
+ const balance = await this.provider.getBalance(address);
362
+ return {
363
+ chain: this.chain.name,
364
+ address,
365
+ balance
366
+ };
244
367
  }
245
368
  async getAccountAssets(address) {
246
- try {
247
- const assets = [];
248
- const tokenBalances = await this.getERC20TokenBalances(address);
249
- for (const tokenBalance of tokenBalances) {
250
- if (tokenBalance.balance > 0n) {
251
- assets.push({
252
- identifier: tokenBalance.tokenAddress,
253
- name: tokenBalance.metadata.name,
254
- amount: tokenBalance.balance,
255
- decimals: tokenBalance.metadata.decimals,
256
- logoUrl: tokenBalance.metadata.logoUrl || ""
257
- });
258
- }
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
+ });
259
383
  }
260
- return assets;
261
- } catch (error) {
262
- throw new Error(`Failed to get account assets for ${address}: ${error}`);
263
384
  }
385
+ return assets;
264
386
  }
265
- async getERC20TokenBalances(address) {
266
- const tokenBalances = [];
267
- const knownTokens = KNOWN_TOKENS[this.chain.name] || {};
268
- for (const [tokenAddress, metadata] of Object.entries(knownTokens)) {
269
- try {
270
- const balance = await this.getTokenBalance(address, tokenAddress);
271
- if (balance > 0n) {
272
- tokenBalances.push({
273
- tokenAddress,
274
- balance,
275
- metadata
276
- });
277
- }
278
- } catch (error) {
279
- console.warn(`Failed to get balance for token ${tokenAddress}: ${error}`);
387
+ async getAsset(identifier) {
388
+ try {
389
+ if (identifier === this.chain.nativeToken.identifier) {
390
+ return this.chain.nativeToken;
280
391
  }
281
- }
282
- const additionalTokens = await this.detectTokensFromEvents(address);
283
- for (const tokenAddress of additionalTokens) {
284
- if (!knownTokens[tokenAddress]) {
285
- try {
286
- const metadata = await this.getTokenMetadata(tokenAddress);
287
- const balance = await this.getTokenBalance(address, tokenAddress);
288
- if (balance > 0n) {
289
- tokenBalances.push({
290
- tokenAddress,
291
- balance,
292
- metadata
293
- });
294
- }
295
- } catch (error) {
296
- console.warn(`Failed to get metadata/balance for detected token ${tokenAddress}: ${error}`);
297
- }
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;
298
396
  }
299
- }
300
- return tokenBalances;
301
- }
302
- async getTokenBalance(address, tokenAddress) {
303
- try {
304
- const contract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
305
- const balance = await contract.balanceOf(address);
306
- return balance;
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;
307
421
  } catch (error) {
308
- throw new Error(`Failed to get token balance: ${error}`);
422
+ return null;
309
423
  }
310
424
  }
311
- async getTokenMetadata(tokenAddress) {
425
+ async getAction(identifier, awaitCompleted = false) {
312
426
  try {
313
- const contract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI, this.provider);
314
- const [name, symbol, decimals] = await Promise.all([contract.name(), contract.symbol(), contract.decimals()]);
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");
315
434
  return {
316
- name: name || "Unknown Token",
317
- symbol: symbol || "UNKNOWN",
318
- decimals: decimals || 18
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
+ }
319
456
  };
320
457
  } catch (error) {
321
- throw new Error(`Failed to get token metadata: ${error}`);
458
+ return null;
322
459
  }
323
460
  }
324
- async detectTokensFromEvents(address) {
325
- try {
326
- const currentBlock = await this.provider.getBlockNumber();
327
- const fromBlock = Math.max(0, currentBlock - 1e4);
328
- const filter = {
329
- fromBlock,
330
- toBlock: currentBlock,
331
- topics: [
332
- import_ethers.ethers.id("Transfer(address,address,uint256)"),
333
- null,
334
- // from address (any)
335
- import_ethers.ethers.zeroPadValue(address, 32)
336
- // to address (our target)
337
- ]
338
- };
339
- const logs = await this.provider.getLogs(filter);
340
- const tokenAddresses = /* @__PURE__ */ new Set();
341
- for (const log of logs) {
342
- tokenAddresses.add(log.address);
343
- }
344
- return Array.from(tokenAddresses);
345
- } catch (error) {
346
- console.warn(`Failed to detect tokens from events: ${error}`);
347
- return [];
348
- }
461
+ async getAccountActions(address, options) {
462
+ return [];
349
463
  }
350
- // Additional utility methods for enhanced token support
351
- async getTokenInfo(tokenAddress) {
352
- try {
353
- return await this.getTokenMetadata(tokenAddress);
354
- } catch (error) {
355
- console.warn(`Failed to get token info for ${tokenAddress}: ${error}`);
356
- return null;
357
- }
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
+ }));
358
477
  }
359
- async getTokenBalanceForAddress(address, tokenAddress) {
360
- try {
361
- return await this.getTokenBalance(address, tokenAddress);
362
- } catch (error) {
363
- throw new Error(`Failed to get token balance for ${tokenAddress}: ${error}`);
364
- }
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;
365
482
  }
366
- async getMultipleTokenBalances(address, tokenAddresses) {
367
- const balances = /* @__PURE__ */ new Map();
368
- await Promise.all(
369
- tokenAddresses.map(async (tokenAddress) => {
370
- try {
371
- const balance = await this.getTokenBalance(address, tokenAddress);
372
- balances.set(tokenAddress, balance);
373
- } catch (error) {
374
- console.warn(`Failed to get balance for token ${tokenAddress}: ${error}`);
375
- balances.set(tokenAddress, 0n);
376
- }
377
- })
378
- );
379
- return balances;
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
+ };
380
500
  }
381
501
  };
382
502
 
383
503
  // src/WarpEvmExecutor.ts
384
- var import_warps3 = require("@vleap/warps");
385
- var import_ethers3 = require("ethers");
504
+ var import_warps10 = require("@vleap/warps");
505
+ var import_ethers4 = require("ethers");
386
506
 
387
507
  // src/constants.ts
388
508
  var WarpEvmConstants = {
@@ -391,6 +511,8 @@ var WarpEvmConstants = {
391
511
  ContractCall: 1e5,
392
512
  ContractDeploy: 5e5,
393
513
  Transfer: 21e3,
514
+ TokenTransfer: 65e3,
515
+ // ERC-20 transfer gas limit
394
516
  Approve: 46e3,
395
517
  Swap: 2e5
396
518
  },
@@ -457,16 +579,17 @@ var ExplorerUrls = {
457
579
  ["blockscout_base_sepolia" /* BlockscoutBaseSepolia */]: "https://sepolia.blockscout.com"
458
580
  };
459
581
 
460
- // src/WarpEvmResults.ts
461
- var import_warps2 = require("@vleap/warps");
582
+ // src/WarpEvmOutput.ts
583
+ var import_warps9 = require("@vleap/warps");
584
+ var import_ethers3 = require("ethers");
462
585
 
463
586
  // src/WarpEvmSerializer.ts
464
- var import_warps = require("@vleap/warps");
587
+ var import_warps8 = require("@vleap/warps");
465
588
  var import_ethers2 = require("ethers");
466
- var SplitParamsRegex = new RegExp(`${import_warps.WarpConstants.ArgParamsSeparator}(.*)`);
589
+ var SplitParamsRegex = new RegExp(`${import_warps8.WarpConstants.ArgParamsSeparator}(.*)`);
467
590
  var WarpEvmSerializer = class {
468
591
  constructor() {
469
- this.coreSerializer = new import_warps.WarpSerializer();
592
+ this.coreSerializer = new import_warps8.WarpSerializer();
470
593
  }
471
594
  typedToString(value) {
472
595
  if (typeof value === "string") {
@@ -495,9 +618,9 @@ var WarpEvmSerializer = class {
495
618
  }
496
619
  if (Array.isArray(value)) {
497
620
  if (value.length === 0) return `list:string:`;
498
- const types = value.map((item) => this.typedToString(item).split(import_warps.WarpConstants.ArgParamsSeparator)[0]);
621
+ const types = value.map((item) => this.typedToString(item).split(import_warps8.WarpConstants.ArgParamsSeparator)[0]);
499
622
  const type = types[0];
500
- const values = value.map((item) => this.typedToString(item).split(import_warps.WarpConstants.ArgParamsSeparator)[1]);
623
+ const values = value.map((item) => this.typedToString(item).split(import_warps8.WarpConstants.ArgParamsSeparator)[1]);
501
624
  return `list:${type}:${values.join(",")}`;
502
625
  }
503
626
  if (value === null || value === void 0) {
@@ -507,8 +630,8 @@ var WarpEvmSerializer = class {
507
630
  }
508
631
  typedToNative(value) {
509
632
  const stringValue = this.typedToString(value);
510
- const [type, ...valueParts] = stringValue.split(import_warps.WarpConstants.ArgParamsSeparator);
511
- const nativeValue = valueParts.join(import_warps.WarpConstants.ArgParamsSeparator);
633
+ const [type, ...valueParts] = stringValue.split(import_warps8.WarpConstants.ArgParamsSeparator);
634
+ const nativeValue = valueParts.join(import_warps8.WarpConstants.ArgParamsSeparator);
512
635
  return [type, this.parseNativeValue(type, nativeValue)];
513
636
  }
514
637
  nativeToTyped(type, value) {
@@ -559,7 +682,7 @@ var WarpEvmSerializer = class {
559
682
  }
560
683
  }
561
684
  stringToTyped(value) {
562
- const parts = value.split(import_warps.WarpConstants.ArgParamsSeparator, 2);
685
+ const parts = value.split(import_warps8.WarpConstants.ArgParamsSeparator, 2);
563
686
  if (parts.length < 2) {
564
687
  return value;
565
688
  }
@@ -612,13 +735,63 @@ var WarpEvmSerializer = class {
612
735
  }
613
736
  };
614
737
 
615
- // src/WarpEvmResults.ts
616
- var WarpEvmResults = class {
617
- constructor(config) {
738
+ // src/WarpEvmOutput.ts
739
+ var WarpEvmOutput = class {
740
+ constructor(config, chain) {
618
741
  this.config = config;
742
+ this.chain = chain;
619
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
+ status: "error",
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
+ output: {},
768
+ messages: {},
769
+ destination: null
770
+ };
771
+ }
772
+ handleWarpChainAction(warp, actionIndex, tx) {
773
+ const success = tx.status === "success";
774
+ const transactionHash = tx.id || tx.tx?.hash || "";
775
+ const gasUsed = tx.tx?.gasLimit || "0";
776
+ const gasPrice = tx.tx?.gasPrice || "0";
777
+ const blockNumber = tx.tx?.blockNumber || "0";
778
+ const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice];
779
+ const stringValues = rawValues.map(String);
780
+ return {
781
+ status: success ? "success" : "error",
782
+ warp,
783
+ action: actionIndex,
784
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
785
+ txHash: transactionHash,
786
+ tx,
787
+ next: null,
788
+ values: { string: stringValues, native: rawValues },
789
+ output: {},
790
+ messages: {},
791
+ destination: null
792
+ };
620
793
  }
621
- async getTransactionExecutionResults(warp, tx) {
794
+ handleTransactionReceipt(warp, actionIndex, tx) {
622
795
  const success = tx.status === 1;
623
796
  const gasUsed = tx.gasUsed?.toString() || "0";
624
797
  const gasPrice = tx.gasPrice?.toString() || "0";
@@ -626,66 +799,96 @@ var WarpEvmResults = class {
626
799
  const transactionHash = tx.hash;
627
800
  const logs = tx.logs.map((log) => ({
628
801
  address: log.address,
629
- topics: log.topics,
802
+ topics: [...log.topics],
630
803
  data: log.data,
631
804
  blockNumber: log.blockNumber?.toString() || "0",
632
805
  transactionHash: log.transactionHash,
633
806
  index: log.index?.toString() || "0"
634
807
  }));
808
+ const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
809
+ const stringValues = rawValues.map(String);
635
810
  return {
636
- success,
811
+ status: success ? "success" : "error",
637
812
  warp,
638
- action: 0,
639
- user: this.config.user?.wallets?.evm || null,
813
+ action: actionIndex,
814
+ user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
640
815
  txHash: transactionHash,
816
+ tx,
641
817
  next: null,
642
- values: [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []],
643
- results: {},
644
- messages: {}
818
+ values: { string: stringValues, native: rawValues },
819
+ output: {},
820
+ messages: {},
821
+ destination: null
645
822
  };
646
823
  }
647
- async extractQueryResults(warp, typedValues, actionIndex, inputs) {
648
- const values = typedValues.map((t) => this.serializer.typedToString(t));
649
- const valuesRaw = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
650
- let results = {};
651
- if (!warp.results) return { values, results };
824
+ async extractQueryOutput(warp, typedValues, actionIndex, inputs) {
825
+ const stringValues = typedValues.map((t) => this.serializer.typedToString(t));
826
+ const nativeValues = typedValues.map((t) => this.serializer.typedToNative(t)[1]);
827
+ const values = { string: stringValues, native: nativeValues };
828
+ let output = {};
829
+ if (!warp.output) return { values, output };
652
830
  const getNestedValue = (path) => {
653
831
  const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
654
832
  if (indices.length === 0) return void 0;
655
- let value = valuesRaw[indices[0]];
833
+ let value = nativeValues[indices[0]];
656
834
  for (let i = 1; i < indices.length; i++) {
657
835
  if (value === void 0 || value === null) return void 0;
658
836
  value = value[indices[i]];
659
837
  }
660
838
  return value;
661
839
  };
662
- for (const [key, path] of Object.entries(warp.results)) {
663
- if (path.startsWith(import_warps2.WarpConstants.Transform.Prefix)) continue;
664
- const currentActionIndex = (0, import_warps2.parseResultsOutIndex)(path);
840
+ for (const [key, path] of Object.entries(warp.output)) {
841
+ if (path.startsWith(import_warps9.WarpConstants.Transform.Prefix)) continue;
842
+ const currentActionIndex = (0, import_warps9.parseOutputOutIndex)(path);
665
843
  if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
666
- results[key] = null;
844
+ output[key] = null;
667
845
  continue;
668
846
  }
669
847
  if (path.startsWith("out.") || path === "out" || path.startsWith("out[")) {
670
- results[key] = getNestedValue(path) || null;
848
+ output[key] = getNestedValue(path) || null;
671
849
  } else {
672
- results[key] = path;
850
+ output[key] = path;
673
851
  }
674
852
  }
675
- return { values, results: await (0, import_warps2.evaluateResultsCommon)(warp, results, actionIndex, inputs) };
853
+ return { values, output: await (0, import_warps9.evaluateOutputCommon)(warp, output, actionIndex, inputs, this.serializer.coreSerializer, this.config) };
854
+ }
855
+ async getTransactionStatus(txHash) {
856
+ try {
857
+ const receipt = await this.provider.getTransactionReceipt(txHash);
858
+ if (!receipt) {
859
+ return { status: "pending" };
860
+ }
861
+ return {
862
+ status: receipt.status === 1 ? "confirmed" : "failed",
863
+ blockNumber: receipt.blockNumber,
864
+ gasUsed: receipt.gasUsed
865
+ };
866
+ } catch (error) {
867
+ throw new Error(`Failed to get transaction status: ${error}`);
868
+ }
869
+ }
870
+ async getTransactionReceipt(txHash) {
871
+ try {
872
+ return await this.provider.getTransactionReceipt(txHash);
873
+ } catch (error) {
874
+ return null;
875
+ }
676
876
  }
677
877
  };
678
878
 
679
879
  // src/WarpEvmExecutor.ts
680
880
  var WarpEvmExecutor = class {
681
- constructor(config) {
881
+ constructor(config, chain) {
682
882
  this.config = config;
883
+ this.chain = chain;
683
884
  this.serializer = new WarpEvmSerializer();
684
- this.provider = new import_ethers3.ethers.JsonRpcProvider(getEvmApiUrl(config.env));
685
- this.results = new WarpEvmResults(config);
885
+ const providerConfig = (0, import_warps10.getProviderConfig)(this.config, chain.name, this.config.env, this.chain.defaultApiUrl);
886
+ const network = new import_ethers4.ethers.Network(this.chain.name, parseInt(this.chain.chainId));
887
+ this.provider = new import_ethers4.ethers.JsonRpcProvider(providerConfig.url, network);
888
+ this.output = new WarpEvmOutput(config, this.chain);
686
889
  }
687
890
  async createTransaction(executable) {
688
- const action = (0, import_warps3.getWarpActionByIndex)(executable.warp, executable.action);
891
+ const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
689
892
  let tx = null;
690
893
  if (action.type === "transfer") {
691
894
  tx = await this.createTransferTransaction(executable);
@@ -700,13 +903,13 @@ var WarpEvmExecutor = class {
700
903
  return tx;
701
904
  }
702
905
  async createTransferTransaction(executable) {
703
- const userWallet = this.config.user?.wallets?.[executable.chain.name];
906
+ const userWallet = (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
704
907
  if (!userWallet) throw new Error("WarpEvmExecutor: createTransfer - user address not set");
705
- if (!import_ethers3.ethers.isAddress(executable.destination)) {
908
+ if (!import_ethers4.ethers.isAddress(executable.destination)) {
706
909
  throw new Error(`WarpEvmExecutor: Invalid destination address: ${executable.destination}`);
707
910
  }
708
- if (executable.value < 0) {
709
- throw new Error(`WarpEvmExecutor: Transfer value cannot be negative: ${executable.value}`);
911
+ if (executable.transfers && executable.transfers.length > 0) {
912
+ return this.createTokenTransferTransaction(executable, userWallet);
710
913
  }
711
914
  const tx = {
712
915
  to: executable.destination,
@@ -716,21 +919,20 @@ var WarpEvmExecutor = class {
716
919
  return this.estimateGasAndSetDefaults(tx, userWallet);
717
920
  }
718
921
  async createContractCallTransaction(executable) {
719
- const userWallet = this.config.user?.wallets?.[executable.chain.name];
922
+ const userWallet = (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
720
923
  if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
721
- const action = (0, import_warps3.getWarpActionByIndex)(executable.warp, executable.action);
722
- if (!action || !("func" in action) || !action.func) {
723
- throw new Error("WarpEvmExecutor: Contract action must have a function name");
724
- }
725
- if (!import_ethers3.ethers.isAddress(executable.destination)) {
726
- throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
727
- }
728
- if (executable.value < 0) {
729
- throw new Error(`WarpEvmExecutor: Contract call value cannot be negative: ${executable.value}`);
730
- }
924
+ const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
925
+ if (!action || !("func" in action) || !action.func) throw new Error("WarpEvmExecutor: Contract action must have a function name");
926
+ if (!import_ethers4.ethers.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid contract address: ${executable.destination}`);
731
927
  try {
732
- const iface = new import_ethers3.ethers.Interface([`function ${action.func}`]);
733
- const encodedData = iface.encodeFunctionData(action.func, executable.args);
928
+ let iface;
929
+ try {
930
+ iface = new import_ethers4.ethers.Interface(JSON.parse(action.abi));
931
+ } catch {
932
+ iface = new import_ethers4.ethers.Interface([action.abi]);
933
+ }
934
+ const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
935
+ const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
734
936
  const tx = {
735
937
  to: executable.destination,
736
938
  value: executable.value,
@@ -741,101 +943,117 @@ var WarpEvmExecutor = class {
741
943
  throw new Error(`WarpEvmExecutor: Failed to encode function data for ${action.func}: ${error}`);
742
944
  }
743
945
  }
744
- async executeQuery(executable) {
745
- const action = (0, import_warps3.getWarpActionByIndex)(executable.warp, executable.action);
746
- if (action.type !== "query") {
747
- throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
946
+ async createTokenTransferTransaction(executable, userWallet) {
947
+ if (executable.transfers.length === 0) throw new Error("WarpEvmExecutor: No transfers provided");
948
+ if (!this.chain.nativeToken?.identifier) throw new Error("WarpEvmExecutor: No native token defined for this chain");
949
+ const nativeTokenTransfers = executable.transfers.filter((transfer) => transfer.identifier === this.chain.nativeToken.identifier);
950
+ const erc20Transfers = executable.transfers.filter((transfer) => transfer.identifier !== this.chain.nativeToken.identifier);
951
+ if (nativeTokenTransfers.length === 1 && erc20Transfers.length === 0) {
952
+ const transfer = nativeTokenTransfers[0];
953
+ if (transfer.amount <= 0n) throw new Error("WarpEvmExecutor: Native token transfer amount must be positive");
954
+ const tx = {
955
+ to: executable.destination,
956
+ value: transfer.amount,
957
+ data: "0x"
958
+ };
959
+ return this.estimateGasAndSetDefaults(tx, userWallet);
748
960
  }
749
- if (!action.func) {
750
- throw new Error("WarpEvmExecutor: Query action must have a function name");
961
+ if (nativeTokenTransfers.length === 0 && erc20Transfers.length === 1) {
962
+ return this.createSingleTokenTransfer(executable, erc20Transfers[0], userWallet);
751
963
  }
752
- if (!import_ethers3.ethers.isAddress(executable.destination)) {
753
- throw new Error(`WarpEvmExecutor: Invalid contract address for query: ${executable.destination}`);
964
+ if (executable.transfers.length > 1) throw new Error("WarpEvmExecutor: Multiple token transfers not yet supported");
965
+ throw new Error("WarpEvmExecutor: Invalid transfer configuration");
966
+ }
967
+ async createSingleTokenTransfer(executable, transfer, userWallet) {
968
+ if (!import_ethers4.ethers.isAddress(transfer.identifier)) {
969
+ throw new Error(`WarpEvmExecutor: Invalid token address: ${transfer.identifier}`);
754
970
  }
971
+ const transferInterface = new import_ethers4.ethers.Interface(["function transfer(address to, uint256 amount) returns (bool)"]);
972
+ const encodedData = transferInterface.encodeFunctionData("transfer", [executable.destination, transfer.amount]);
973
+ const tx = {
974
+ to: transfer.identifier,
975
+ value: 0n,
976
+ data: encodedData
977
+ };
978
+ return this.estimateGasAndSetDefaults(tx, userWallet);
979
+ }
980
+ async executeQuery(executable) {
981
+ const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
982
+ if (action.type !== "query") throw new Error(`WarpEvmExecutor: Invalid action type for executeQuery: ${action.type}`);
983
+ if (!action.func) throw new Error("WarpEvmExecutor: Query action must have a function name");
984
+ if (!import_ethers4.ethers.isAddress(executable.destination)) throw new Error(`WarpEvmExecutor: Invalid address for query: ${executable.destination}`);
755
985
  try {
756
- const iface = new import_ethers3.ethers.Interface([`function ${action.func}`]);
757
- const encodedData = iface.encodeFunctionData(action.func, executable.args);
986
+ let iface;
987
+ try {
988
+ iface = new import_ethers4.ethers.Interface(JSON.parse(action.abi));
989
+ } catch {
990
+ iface = new import_ethers4.ethers.Interface([action.abi]);
991
+ }
992
+ const nativeArgs = executable.args.map((arg) => this.serializer.coreSerializer.stringToNative(arg)[1]);
993
+ const encodedData = iface.encodeFunctionData(action.func, nativeArgs);
758
994
  const result = await this.provider.call({
759
995
  to: executable.destination,
760
996
  data: encodedData
761
997
  });
762
998
  const decodedResult = iface.decodeFunctionResult(action.func, result);
763
999
  const isSuccess = true;
764
- const { values, results } = await this.results.extractQueryResults(
1000
+ const { values, output } = await this.output.extractQueryOutput(
765
1001
  executable.warp,
766
1002
  decodedResult,
767
1003
  executable.action,
768
1004
  executable.resolvedInputs
769
1005
  );
770
- const next = (0, import_warps3.getNextInfo)(this.config, [], executable.warp, executable.action, results);
1006
+ const next = (0, import_warps10.getNextInfo)(this.config, [], executable.warp, executable.action, output);
1007
+ const destinationInput = executable.resolvedInputs.find(
1008
+ (i) => i.input.position === "receiver" || i.input.position === "destination"
1009
+ );
1010
+ const destination = destinationInput?.value || executable.destination;
771
1011
  return {
772
- success: isSuccess,
1012
+ status: isSuccess ? "success" : "error",
773
1013
  warp: executable.warp,
774
1014
  action: executable.action,
775
- user: this.config.user?.wallets?.[executable.chain.name] || null,
1015
+ user: (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
776
1016
  txHash: null,
1017
+ tx: null,
777
1018
  next,
778
1019
  values,
779
- results,
780
- messages: (0, import_warps3.applyResultsToMessages)(executable.warp, results)
1020
+ output: { ...output, _DATA: decodedResult },
1021
+ messages: (0, import_warps10.applyOutputToMessages)(executable.warp, output, this.config),
1022
+ destination
781
1023
  };
782
1024
  } catch (error) {
1025
+ const destinationInput = executable.resolvedInputs.find(
1026
+ (i) => i.input.position === "receiver" || i.input.position === "destination"
1027
+ );
1028
+ const destination = destinationInput?.value || executable.destination;
783
1029
  return {
784
- success: false,
1030
+ status: "error",
785
1031
  warp: executable.warp,
786
1032
  action: executable.action,
787
- user: this.config.user?.wallets?.[executable.chain.name] || null,
1033
+ user: (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
788
1034
  txHash: null,
1035
+ tx: null,
789
1036
  next: null,
790
- values: [],
791
- results: {},
792
- messages: {}
1037
+ values: { string: [], native: [] },
1038
+ output: { _DATA: error },
1039
+ messages: {},
1040
+ destination
793
1041
  };
794
1042
  }
795
1043
  }
796
- async preprocessInput(chain, input, type, value) {
797
- const typedValue = this.serializer.stringToTyped(value);
798
- switch (type) {
799
- case "address":
800
- if (!import_ethers3.ethers.isAddress(typedValue)) {
801
- throw new Error(`Invalid address format: ${typedValue}`);
802
- }
803
- return import_ethers3.ethers.getAddress(typedValue);
804
- case "hex":
805
- if (!import_ethers3.ethers.isHexString(typedValue)) {
806
- throw new Error(`Invalid hex format: ${typedValue}`);
807
- }
808
- return typedValue;
809
- case "uint8":
810
- case "uint16":
811
- case "uint32":
812
- case "uint64":
813
- case "biguint":
814
- const bigIntValue = BigInt(typedValue);
815
- if (bigIntValue < 0) {
816
- throw new Error(`Negative value not allowed for type ${type}: ${typedValue}`);
817
- }
818
- return bigIntValue.toString();
819
- default:
820
- return String(typedValue);
821
- }
822
- }
823
1044
  async estimateGasAndSetDefaults(tx, from) {
824
1045
  try {
825
1046
  const gasEstimate = await this.provider.estimateGas({
826
1047
  ...tx,
827
1048
  from
828
1049
  });
829
- if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) {
830
- throw new Error(`Gas estimate too low: ${gasEstimate}`);
831
- }
832
- if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) {
833
- throw new Error(`Gas estimate too high: ${gasEstimate}`);
834
- }
1050
+ if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) throw new Error(`Gas estimate too low: ${gasEstimate}`);
1051
+ if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) throw new Error(`Gas estimate too high: ${gasEstimate}`);
835
1052
  const feeData = await this.provider.getFeeData();
836
1053
  if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
837
1054
  return {
838
1055
  ...tx,
1056
+ chainId: parseInt(this.chain.chainId),
839
1057
  gasLimit: gasEstimate,
840
1058
  maxFeePerGas: feeData.maxFeePerGas,
841
1059
  maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
@@ -843,32 +1061,44 @@ var WarpEvmExecutor = class {
843
1061
  } else if (feeData.gasPrice) {
844
1062
  return {
845
1063
  ...tx,
1064
+ chainId: parseInt(this.chain.chainId),
846
1065
  gasLimit: gasEstimate,
847
1066
  gasPrice: feeData.gasPrice
848
1067
  };
849
1068
  } else {
850
1069
  return {
851
1070
  ...tx,
1071
+ chainId: parseInt(this.chain.chainId),
852
1072
  gasLimit: gasEstimate,
853
- gasPrice: import_ethers3.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
1073
+ gasPrice: import_ethers4.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
854
1074
  };
855
1075
  }
856
1076
  } catch (error) {
857
1077
  let defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Default);
858
1078
  if (tx.data && tx.data !== "0x") {
859
- defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.ContractCall);
1079
+ if (tx.data.startsWith("0xa9059cbb")) {
1080
+ defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.TokenTransfer);
1081
+ } else {
1082
+ defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.ContractCall);
1083
+ }
860
1084
  } else {
861
1085
  defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Transfer);
862
1086
  }
863
1087
  return {
864
1088
  ...tx,
1089
+ chainId: parseInt(this.chain.chainId),
865
1090
  gasLimit: defaultGasLimit,
866
- gasPrice: import_ethers3.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
1091
+ gasPrice: import_ethers4.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
867
1092
  };
868
1093
  }
869
1094
  }
870
- async signMessage(message, privateKey) {
871
- throw new Error("Not implemented");
1095
+ async verifyMessage(message, signature) {
1096
+ try {
1097
+ const recoveredAddress = import_ethers4.ethers.verifyMessage(message, signature);
1098
+ return recoveredAddress;
1099
+ } catch (error) {
1100
+ throw new Error(`Failed to verify message: ${error}`);
1101
+ }
872
1102
  }
873
1103
  };
874
1104
 
@@ -956,155 +1186,376 @@ var WarpEvmExplorer = class {
956
1186
  });
957
1187
  return urls;
958
1188
  }
1189
+ getAssetUrls(identifier) {
1190
+ const explorers = this.getAllExplorers();
1191
+ const urls = {};
1192
+ explorers.forEach((explorer) => {
1193
+ const url = ExplorerUrls[explorer];
1194
+ if (url) {
1195
+ urls[explorer] = `${url}/token/${identifier}`;
1196
+ }
1197
+ });
1198
+ return urls;
1199
+ }
1200
+ getContractUrls(address) {
1201
+ const explorers = this.getAllExplorers();
1202
+ const urls = {};
1203
+ explorers.forEach((explorer) => {
1204
+ const url = ExplorerUrls[explorer];
1205
+ if (url) {
1206
+ urls[explorer] = `${url}/address/${address}`;
1207
+ }
1208
+ });
1209
+ return urls;
1210
+ }
1211
+ getBlockUrls(blockNumber) {
1212
+ const explorers = this.getAllExplorers();
1213
+ const urls = {};
1214
+ explorers.forEach((explorer) => {
1215
+ const url = ExplorerUrls[explorer];
1216
+ if (url) {
1217
+ urls[explorer] = `${url}/block/${blockNumber}`;
1218
+ }
1219
+ });
1220
+ return urls;
1221
+ }
1222
+ };
1223
+
1224
+ // src/WarpEvmWallet.ts
1225
+ var import_warps11 = require("@vleap/warps");
1226
+ var import_ethers5 = require("ethers");
1227
+ var WarpEvmWallet = class {
1228
+ constructor(config, chain) {
1229
+ this.config = config;
1230
+ this.chain = chain;
1231
+ const providerConfig = (0, import_warps11.getProviderConfig)(config, chain.name, config.env, chain.defaultApiUrl);
1232
+ this.provider = new import_ethers5.ethers.JsonRpcProvider(providerConfig.url);
1233
+ }
1234
+ async signTransaction(tx) {
1235
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1236
+ const wallet = this.getWallet();
1237
+ const txRequest = {
1238
+ to: tx.to,
1239
+ data: tx.data,
1240
+ value: tx.value || 0,
1241
+ gasLimit: tx.gasLimit,
1242
+ maxFeePerGas: tx.maxFeePerGas,
1243
+ maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1244
+ nonce: tx.nonce,
1245
+ chainId: tx.chainId
1246
+ };
1247
+ const signedTx = await wallet.signTransaction(txRequest);
1248
+ return { ...tx, signature: signedTx };
1249
+ }
1250
+ async signTransactions(txs) {
1251
+ if (txs.length === 0) return [];
1252
+ if (txs.length > 1) {
1253
+ const wallet = this.getWallet();
1254
+ const address = wallet.address;
1255
+ const currentNonce = await this.provider.getTransactionCount(address, "pending");
1256
+ const signedTxs = [];
1257
+ for (let i = 0; i < txs.length; i++) {
1258
+ const tx = { ...txs[i] };
1259
+ tx.nonce = currentNonce + i;
1260
+ if (i > 0) {
1261
+ const priorityReduction = BigInt(i * 1e9);
1262
+ const minGasPrice = BigInt(1e9);
1263
+ if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
1264
+ tx.maxFeePerGas = tx.maxFeePerGas > priorityReduction ? tx.maxFeePerGas - priorityReduction : minGasPrice;
1265
+ tx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas > priorityReduction ? tx.maxPriorityFeePerGas - priorityReduction : minGasPrice;
1266
+ delete tx.gasPrice;
1267
+ } else if (tx.gasPrice) {
1268
+ tx.gasPrice = tx.gasPrice > priorityReduction ? tx.gasPrice - priorityReduction : minGasPrice;
1269
+ delete tx.maxFeePerGas;
1270
+ delete tx.maxPriorityFeePerGas;
1271
+ }
1272
+ }
1273
+ const signedTx = await this.signTransaction(tx);
1274
+ signedTxs.push(signedTx);
1275
+ }
1276
+ return signedTxs;
1277
+ }
1278
+ return Promise.all(txs.map(async (tx) => this.signTransaction(tx)));
1279
+ }
1280
+ async signMessage(message) {
1281
+ const wallet = this.getWallet();
1282
+ const signature = await wallet.signMessage(message);
1283
+ return signature;
1284
+ }
1285
+ async sendTransaction(tx) {
1286
+ if (!tx || typeof tx !== "object") throw new Error("Invalid transaction object");
1287
+ if (!tx.signature) throw new Error("Transaction must be signed before sending");
1288
+ const wallet = this.getWallet();
1289
+ if (!wallet) throw new Error("Wallet not initialized - no private key provided");
1290
+ const connectedWallet = wallet.connect(this.provider);
1291
+ const txResponse = await connectedWallet.sendTransaction(tx);
1292
+ return txResponse.hash;
1293
+ }
1294
+ async sendTransactions(txs) {
1295
+ return Promise.all(txs.map(async (tx) => this.sendTransaction(tx)));
1296
+ }
1297
+ create(mnemonic) {
1298
+ const wallet = import_ethers5.ethers.Wallet.fromPhrase(mnemonic);
1299
+ return { address: wallet.address, privateKey: wallet.privateKey, mnemonic };
1300
+ }
1301
+ generate() {
1302
+ const wallet = import_ethers5.ethers.Wallet.createRandom();
1303
+ return { address: wallet.address, privateKey: wallet.privateKey, mnemonic: wallet.mnemonic?.phrase || "" };
1304
+ }
1305
+ getAddress() {
1306
+ const wallet = this.getWallet();
1307
+ return wallet.address;
1308
+ }
1309
+ getWallet() {
1310
+ const privateKey = (0, import_warps11.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
1311
+ if (privateKey) return new import_ethers5.ethers.Wallet(privateKey);
1312
+ const mnemonic = (0, import_warps11.getWarpWalletMnemonicFromConfig)(this.config, this.chain.name);
1313
+ if (mnemonic) return import_ethers5.ethers.Wallet.fromPhrase(mnemonic);
1314
+ throw new Error("No private key or mnemonic provided");
1315
+ }
959
1316
  };
960
1317
 
961
1318
  // src/chains/common.ts
962
- var createEvmAdapter = (chainName, chainPrefix, chainInfos) => {
1319
+ var createEvmAdapter = (chainName, chainInfos) => {
963
1320
  return (config, fallback) => {
964
1321
  if (!fallback) throw new Error(`${chainName} adapter requires a fallback adapter`);
965
1322
  return {
966
- chain: chainName,
967
1323
  chainInfo: chainInfos[config.env],
968
- prefix: chainPrefix,
969
1324
  builder: () => fallback.builder(),
970
- executor: new WarpEvmExecutor(config),
971
- results: new WarpEvmResults(config),
1325
+ executor: new WarpEvmExecutor(config, chainInfos[config.env]),
1326
+ output: new WarpEvmOutput(config, chainInfos[config.env]),
972
1327
  serializer: new WarpEvmSerializer(),
973
1328
  registry: fallback.registry,
974
1329
  explorer: new WarpEvmExplorer(chainInfos[config.env], config),
975
1330
  abiBuilder: () => fallback.abiBuilder(),
976
1331
  brandBuilder: () => fallback.brandBuilder(),
977
- dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env])
1332
+ dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env]),
1333
+ wallet: new WarpEvmWallet(config, chainInfos[config.env])
978
1334
  };
979
1335
  };
980
1336
  };
981
1337
 
982
1338
  // src/chains/arbitrum.ts
983
- var ChainNameArbitrum = "arbitrum";
984
- var getArbitrumAdapter = createEvmAdapter(ChainNameArbitrum, "arb", {
985
- devnet: {
986
- name: ChainNameArbitrum,
987
- displayName: "Arbitrum Devnet",
988
- chainId: "421614",
1339
+ var NativeTokenArb = {
1340
+ chain: import_warps12.WarpChainName.Arbitrum,
1341
+ identifier: "ARB",
1342
+ symbol: "ARB",
1343
+ name: "Arbitrum",
1344
+ decimals: 18,
1345
+ logoUrl: "https://vleap.ai/images/tokens/arb.svg"
1346
+ };
1347
+ var getArbitrumAdapter = createEvmAdapter(import_warps12.WarpChainName.Arbitrum, {
1348
+ mainnet: {
1349
+ name: import_warps12.WarpChainName.Arbitrum,
1350
+ displayName: "Arbitrum",
1351
+ chainId: "42161",
989
1352
  blockTime: 1e3,
990
1353
  addressHrp: "0x",
991
- apiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
992
- nativeToken: "ETH"
1354
+ defaultApiUrl: "https://arb1.arbitrum.io/rpc",
1355
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1356
+ nativeToken: NativeTokenArb
993
1357
  },
994
1358
  testnet: {
995
- name: ChainNameArbitrum,
996
- displayName: "Arbitrum Testnet",
997
- chainId: "421613",
1359
+ name: import_warps12.WarpChainName.Arbitrum,
1360
+ displayName: "Arbitrum Sepolia",
1361
+ chainId: "421614",
998
1362
  blockTime: 1e3,
999
1363
  addressHrp: "0x",
1000
- apiUrl: "https://goerli-rollup.arbitrum.io/rpc",
1001
- nativeToken: "ETH"
1364
+ defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
1365
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1366
+ nativeToken: NativeTokenArb
1002
1367
  },
1003
- mainnet: {
1004
- name: ChainNameArbitrum,
1005
- displayName: "Arbitrum",
1006
- chainId: "42161",
1368
+ devnet: {
1369
+ name: import_warps12.WarpChainName.Arbitrum,
1370
+ displayName: "Arbitrum Sepolia",
1371
+ chainId: "421614",
1007
1372
  blockTime: 1e3,
1008
1373
  addressHrp: "0x",
1009
- apiUrl: "https://arb1.arbitrum.io/rpc",
1010
- nativeToken: "ETH"
1374
+ defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
1375
+ logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
1376
+ nativeToken: NativeTokenArb
1011
1377
  }
1012
1378
  });
1013
1379
 
1014
1380
  // src/chains/base.ts
1015
- var ChainNameBase = "base";
1016
- var getBaseAdapter = createEvmAdapter(ChainNameBase, "base", {
1381
+ var import_warps13 = require("@vleap/warps");
1382
+ var NativeTokenBase = {
1383
+ chain: import_warps13.WarpChainName.Base,
1384
+ identifier: "ETH",
1385
+ name: "Ether",
1386
+ symbol: "ETH",
1387
+ decimals: 18,
1388
+ logoUrl: "https://vleap.ai/images/tokens/eth.svg"
1389
+ };
1390
+ var getBaseAdapter = createEvmAdapter(import_warps13.WarpChainName.Base, {
1017
1391
  mainnet: {
1018
- name: ChainNameBase,
1392
+ name: import_warps13.WarpChainName.Base,
1019
1393
  displayName: "Base",
1020
1394
  chainId: "8453",
1021
1395
  blockTime: 2e3,
1022
1396
  addressHrp: "0x",
1023
- apiUrl: "https://mainnet.base.org",
1024
- nativeToken: "ETH"
1397
+ defaultApiUrl: "https://mainnet.base.org",
1398
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1399
+ nativeToken: NativeTokenBase
1025
1400
  },
1026
1401
  testnet: {
1027
- name: ChainNameBase,
1028
- displayName: "Base Testnet",
1029
- chainId: "84531",
1402
+ name: import_warps13.WarpChainName.Base,
1403
+ displayName: "Base Sepolia",
1404
+ chainId: "84532",
1030
1405
  blockTime: 2e3,
1031
1406
  addressHrp: "0x",
1032
- apiUrl: "https://goerli.base.org",
1033
- nativeToken: "ETH"
1407
+ defaultApiUrl: "https://sepolia.base.org",
1408
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1409
+ nativeToken: NativeTokenBase
1034
1410
  },
1035
1411
  devnet: {
1036
- name: ChainNameBase,
1037
- displayName: "Base Devnet",
1412
+ name: import_warps13.WarpChainName.Base,
1413
+ displayName: "Base Sepolia",
1038
1414
  chainId: "84532",
1039
1415
  blockTime: 2e3,
1040
1416
  addressHrp: "0x",
1041
- apiUrl: "https://sepolia.base.org",
1042
- nativeToken: "ETH"
1417
+ defaultApiUrl: "https://sepolia.base.org",
1418
+ logoUrl: "https://vleap.ai/images/chains/base.svg",
1419
+ nativeToken: NativeTokenBase
1043
1420
  }
1044
1421
  });
1045
1422
 
1423
+ // src/chains/combined.ts
1424
+ var import_warps16 = require("@vleap/warps");
1425
+
1046
1426
  // src/chains/ethereum.ts
1047
- var ChainNameEthereum = "ethereum";
1048
- var getEthereumAdapter = createEvmAdapter(ChainNameEthereum, "eth", {
1049
- devnet: {
1050
- name: ChainNameEthereum,
1051
- displayName: "Ethereum Devnet",
1052
- chainId: "11155111",
1427
+ var import_warps14 = require("@vleap/warps");
1428
+ var NativeTokenEth = {
1429
+ chain: import_warps14.WarpChainName.Ethereum,
1430
+ identifier: "ETH",
1431
+ symbol: "ETH",
1432
+ name: "Ether",
1433
+ decimals: 18,
1434
+ logoUrl: "https://vleap.ai/images/tokens/eth.svg"
1435
+ };
1436
+ var getEthereumAdapter = createEvmAdapter(import_warps14.WarpChainName.Ethereum, {
1437
+ mainnet: {
1438
+ name: import_warps14.WarpChainName.Ethereum,
1439
+ displayName: "Ethereum Mainnet",
1440
+ chainId: "1",
1053
1441
  blockTime: 12e3,
1054
1442
  addressHrp: "0x",
1055
- apiUrl: "https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY",
1056
- nativeToken: "ETH"
1443
+ defaultApiUrl: "https://ethereum-rpc.publicnode.com",
1444
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1445
+ nativeToken: NativeTokenEth
1057
1446
  },
1058
1447
  testnet: {
1059
- name: ChainNameEthereum,
1060
- displayName: "Ethereum Testnet",
1061
- chainId: "5",
1448
+ name: import_warps14.WarpChainName.Ethereum,
1449
+ displayName: "Ethereum Sepolia",
1450
+ chainId: "11155111",
1062
1451
  blockTime: 12e3,
1063
1452
  addressHrp: "0x",
1064
- apiUrl: "https://eth-goerli.g.alchemy.com/v2/YOUR_API_KEY",
1065
- nativeToken: "ETH"
1453
+ defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
1454
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1455
+ nativeToken: NativeTokenEth
1066
1456
  },
1067
- mainnet: {
1068
- name: ChainNameEthereum,
1069
- displayName: "Ethereum Mainnet",
1070
- chainId: "1",
1457
+ devnet: {
1458
+ name: import_warps14.WarpChainName.Ethereum,
1459
+ displayName: "Ethereum Sepolia",
1460
+ chainId: "11155111",
1071
1461
  blockTime: 12e3,
1072
1462
  addressHrp: "0x",
1073
- apiUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY",
1074
- nativeToken: "ETH"
1463
+ defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
1464
+ logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
1465
+ nativeToken: NativeTokenEth
1466
+ }
1467
+ });
1468
+
1469
+ // src/chains/somnia.ts
1470
+ var import_warps15 = require("@vleap/warps");
1471
+ var NativeTokenSomi = {
1472
+ chain: import_warps15.WarpChainName.Somnia,
1473
+ identifier: "SOMI",
1474
+ symbol: "SOMI",
1475
+ name: "Somnia",
1476
+ decimals: 18,
1477
+ logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
1478
+ };
1479
+ var NativeTokenStt = {
1480
+ chain: import_warps15.WarpChainName.Somnia,
1481
+ identifier: "STT",
1482
+ symbol: "STT",
1483
+ name: "Somnia Testnet Token",
1484
+ decimals: 18,
1485
+ logoUrl: "https://assets.coingecko.com/coins/images/68061/standard/somniacg.png?1754641117"
1486
+ };
1487
+ var getSomniaAdapter = createEvmAdapter(import_warps15.WarpChainName.Somnia, {
1488
+ mainnet: {
1489
+ name: import_warps15.WarpChainName.Somnia,
1490
+ displayName: "Somnia Mainnet",
1491
+ chainId: "5031",
1492
+ blockTime: 100,
1493
+ addressHrp: "0x",
1494
+ defaultApiUrl: "https://api.infra.mainnet.somnia.network/",
1495
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1496
+ nativeToken: NativeTokenSomi
1497
+ },
1498
+ testnet: {
1499
+ name: import_warps15.WarpChainName.Somnia,
1500
+ displayName: "Somnia Testnet",
1501
+ chainId: "50312",
1502
+ blockTime: 100,
1503
+ addressHrp: "0x",
1504
+ defaultApiUrl: "https://dream-rpc.somnia.network/",
1505
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1506
+ nativeToken: NativeTokenStt
1507
+ },
1508
+ devnet: {
1509
+ name: import_warps15.WarpChainName.Somnia,
1510
+ displayName: "Somnia Testnet",
1511
+ chainId: "50312",
1512
+ blockTime: 100,
1513
+ addressHrp: "0x",
1514
+ defaultApiUrl: "https://dream-rpc.somnia.network",
1515
+ logoUrl: "https://vleap.ai/images/chains/somnia.png",
1516
+ nativeToken: NativeTokenStt
1075
1517
  }
1076
1518
  });
1077
1519
 
1078
1520
  // src/chains/combined.ts
1079
1521
  var getAllEvmAdapters = (config, fallback) => [
1080
1522
  getEthereumAdapter(config, fallback),
1523
+ getBaseAdapter(config, fallback),
1081
1524
  getArbitrumAdapter(config, fallback),
1082
- getBaseAdapter(config, fallback)
1525
+ getSomniaAdapter(config, fallback)
1526
+ ];
1527
+ var getAllEvmChainNames = () => [
1528
+ import_warps16.WarpChainName.Ethereum,
1529
+ import_warps16.WarpChainName.Base,
1530
+ import_warps16.WarpChainName.Arbitrum,
1531
+ import_warps16.WarpChainName.Somnia
1083
1532
  ];
1084
- var getAllEvmChainNames = () => [ChainNameArbitrum, ChainNameBase, ChainNameEthereum];
1085
1533
  // Annotate the CommonJS export names for ESM import in node:
1086
1534
  0 && (module.exports = {
1087
1535
  ArbitrumExplorers,
1088
1536
  BaseExplorers,
1089
- ChainNameArbitrum,
1090
- ChainNameBase,
1091
- ChainNameEthereum,
1092
- EVM_CHAIN_CONFIGS,
1093
1537
  EthereumExplorers,
1094
1538
  EvmExplorers,
1095
1539
  ExplorerUrls,
1540
+ KnownTokens,
1541
+ NativeTokenArb,
1542
+ NativeTokenBase,
1543
+ NativeTokenEth,
1544
+ UniswapService,
1096
1545
  WarpEvmConstants,
1546
+ WarpEvmDataLoader,
1097
1547
  WarpEvmExecutor,
1098
1548
  WarpEvmExplorer,
1099
- WarpEvmResults,
1549
+ WarpEvmOutput,
1100
1550
  WarpEvmSerializer,
1551
+ WarpEvmWallet,
1552
+ createEvmAdapter,
1553
+ findKnownTokenById,
1101
1554
  getAllEvmAdapters,
1102
1555
  getAllEvmChainNames,
1103
1556
  getArbitrumAdapter,
1104
1557
  getBaseAdapter,
1105
1558
  getEthereumAdapter,
1106
- getEvmApiUrl,
1107
- getEvmChainConfig,
1108
- getEvmExplorerUrl
1559
+ getKnownTokensForChain
1109
1560
  });
1110
1561
  //# sourceMappingURL=index.js.map