@vleap/warps-adapter-evm 0.2.0-alpha.9 → 0.2.0-beta.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +261 -0
- package/dist/index.d.ts +150 -29
- package/dist/index.js +913 -475
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +906 -458
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -10
- package/dist/index.d.mts +0 -140
package/dist/index.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
|
-
|
|
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
|
-
|
|
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/
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
|
145
|
-
|
|
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
|
|
148
|
-
return
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
422
|
+
return null;
|
|
309
423
|
}
|
|
310
424
|
}
|
|
311
|
-
async
|
|
425
|
+
async getAction(identifier, awaitCompleted = false) {
|
|
312
426
|
try {
|
|
313
|
-
const
|
|
314
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
458
|
+
return null;
|
|
322
459
|
}
|
|
323
460
|
}
|
|
324
|
-
async
|
|
325
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
|
385
|
-
var
|
|
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/
|
|
461
|
-
var
|
|
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
|
|
587
|
+
var import_warps8 = require("@vleap/warps");
|
|
465
588
|
var import_ethers2 = require("ethers");
|
|
466
|
-
var SplitParamsRegex = new RegExp(`${
|
|
589
|
+
var SplitParamsRegex = new RegExp(`${import_warps8.WarpConstants.ArgParamsSeparator}(.*)`);
|
|
467
590
|
var WarpEvmSerializer = class {
|
|
468
591
|
constructor() {
|
|
469
|
-
this.coreSerializer = new
|
|
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(
|
|
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(
|
|
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(
|
|
511
|
-
const nativeValue = valueParts.join(
|
|
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(
|
|
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,61 @@ var WarpEvmSerializer = class {
|
|
|
612
735
|
}
|
|
613
736
|
};
|
|
614
737
|
|
|
615
|
-
// src/
|
|
616
|
-
var
|
|
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
|
+
};
|
|
620
770
|
}
|
|
621
|
-
|
|
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
|
+
status: success ? "success" : "error",
|
|
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
|
+
output: {},
|
|
789
|
+
messages: {}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
handleTransactionReceipt(warp, actionIndex, tx) {
|
|
622
793
|
const success = tx.status === 1;
|
|
623
794
|
const gasUsed = tx.gasUsed?.toString() || "0";
|
|
624
795
|
const gasPrice = tx.gasPrice?.toString() || "0";
|
|
@@ -626,66 +797,95 @@ var WarpEvmResults = class {
|
|
|
626
797
|
const transactionHash = tx.hash;
|
|
627
798
|
const logs = tx.logs.map((log) => ({
|
|
628
799
|
address: log.address,
|
|
629
|
-
topics: log.topics,
|
|
800
|
+
topics: [...log.topics],
|
|
630
801
|
data: log.data,
|
|
631
802
|
blockNumber: log.blockNumber?.toString() || "0",
|
|
632
803
|
transactionHash: log.transactionHash,
|
|
633
804
|
index: log.index?.toString() || "0"
|
|
634
805
|
}));
|
|
806
|
+
const rawValues = [transactionHash, blockNumber, gasUsed, gasPrice, ...logs.length > 0 ? logs : []];
|
|
807
|
+
const stringValues = rawValues.map(String);
|
|
635
808
|
return {
|
|
636
|
-
success,
|
|
809
|
+
status: success ? "success" : "error",
|
|
637
810
|
warp,
|
|
638
|
-
action:
|
|
639
|
-
user: this.config.
|
|
811
|
+
action: actionIndex,
|
|
812
|
+
user: (0, import_warps9.getWarpWalletAddressFromConfig)(this.config, this.chain.name),
|
|
640
813
|
txHash: transactionHash,
|
|
814
|
+
tx,
|
|
641
815
|
next: null,
|
|
642
|
-
values:
|
|
643
|
-
|
|
816
|
+
values: { string: stringValues, native: rawValues },
|
|
817
|
+
output: {},
|
|
644
818
|
messages: {}
|
|
645
819
|
};
|
|
646
820
|
}
|
|
647
|
-
async
|
|
648
|
-
const
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
821
|
+
async extractQueryOutput(warp, typedValues, actionIndex, inputs) {
|
|
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 };
|
|
825
|
+
let output = {};
|
|
826
|
+
if (!warp.output) return { values, output };
|
|
652
827
|
const getNestedValue = (path) => {
|
|
653
828
|
const indices = path.split(".").slice(1).map((i) => parseInt(i) - 1);
|
|
654
829
|
if (indices.length === 0) return void 0;
|
|
655
|
-
let value =
|
|
830
|
+
let value = nativeValues[indices[0]];
|
|
656
831
|
for (let i = 1; i < indices.length; i++) {
|
|
657
832
|
if (value === void 0 || value === null) return void 0;
|
|
658
833
|
value = value[indices[i]];
|
|
659
834
|
}
|
|
660
835
|
return value;
|
|
661
836
|
};
|
|
662
|
-
for (const [key, path] of Object.entries(warp.
|
|
663
|
-
if (path.startsWith(
|
|
664
|
-
const currentActionIndex = (0,
|
|
837
|
+
for (const [key, path] of Object.entries(warp.output)) {
|
|
838
|
+
if (path.startsWith(import_warps9.WarpConstants.Transform.Prefix)) continue;
|
|
839
|
+
const currentActionIndex = (0, import_warps9.parseOutputOutIndex)(path);
|
|
665
840
|
if (currentActionIndex !== null && currentActionIndex !== actionIndex) {
|
|
666
|
-
|
|
841
|
+
output[key] = null;
|
|
667
842
|
continue;
|
|
668
843
|
}
|
|
669
844
|
if (path.startsWith("out.") || path === "out" || path.startsWith("out[")) {
|
|
670
|
-
|
|
845
|
+
output[key] = getNestedValue(path) || null;
|
|
671
846
|
} else {
|
|
672
|
-
|
|
847
|
+
output[key] = path;
|
|
673
848
|
}
|
|
674
849
|
}
|
|
675
|
-
return { values,
|
|
850
|
+
return { values, output: await (0, import_warps9.evaluateOutputCommon)(warp, output, 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
|
+
}
|
|
676
873
|
}
|
|
677
874
|
};
|
|
678
875
|
|
|
679
876
|
// src/WarpEvmExecutor.ts
|
|
680
877
|
var WarpEvmExecutor = class {
|
|
681
|
-
constructor(config) {
|
|
878
|
+
constructor(config, chain) {
|
|
682
879
|
this.config = config;
|
|
880
|
+
this.chain = chain;
|
|
683
881
|
this.serializer = new WarpEvmSerializer();
|
|
684
|
-
|
|
685
|
-
|
|
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.output = new WarpEvmOutput(config, this.chain);
|
|
686
886
|
}
|
|
687
887
|
async createTransaction(executable) {
|
|
688
|
-
const action = (0,
|
|
888
|
+
const action = (0, import_warps10.getWarpActionByIndex)(executable.warp, executable.action);
|
|
689
889
|
let tx = null;
|
|
690
890
|
if (action.type === "transfer") {
|
|
691
891
|
tx = await this.createTransferTransaction(executable);
|
|
@@ -700,13 +900,13 @@ var WarpEvmExecutor = class {
|
|
|
700
900
|
return tx;
|
|
701
901
|
}
|
|
702
902
|
async createTransferTransaction(executable) {
|
|
703
|
-
const userWallet = this.config
|
|
903
|
+
const userWallet = (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
704
904
|
if (!userWallet) throw new Error("WarpEvmExecutor: createTransfer - user address not set");
|
|
705
|
-
if (!
|
|
905
|
+
if (!import_ethers4.ethers.isAddress(executable.destination)) {
|
|
706
906
|
throw new Error(`WarpEvmExecutor: Invalid destination address: ${executable.destination}`);
|
|
707
907
|
}
|
|
708
|
-
if (executable.
|
|
709
|
-
|
|
908
|
+
if (executable.transfers && executable.transfers.length > 0) {
|
|
909
|
+
return this.createTokenTransferTransaction(executable, userWallet);
|
|
710
910
|
}
|
|
711
911
|
const tx = {
|
|
712
912
|
to: executable.destination,
|
|
@@ -716,21 +916,20 @@ var WarpEvmExecutor = class {
|
|
|
716
916
|
return this.estimateGasAndSetDefaults(tx, userWallet);
|
|
717
917
|
}
|
|
718
918
|
async createContractCallTransaction(executable) {
|
|
719
|
-
const userWallet = this.config
|
|
919
|
+
const userWallet = (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name);
|
|
720
920
|
if (!userWallet) throw new Error("WarpEvmExecutor: createContractCall - user address not set");
|
|
721
|
-
const action = (0,
|
|
722
|
-
if (!action || !("func" in action) || !action.func)
|
|
723
|
-
|
|
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
|
-
}
|
|
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}`);
|
|
731
924
|
try {
|
|
732
|
-
|
|
733
|
-
|
|
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);
|
|
734
933
|
const tx = {
|
|
735
934
|
to: executable.destination,
|
|
736
935
|
value: executable.value,
|
|
@@ -741,101 +940,107 @@ var WarpEvmExecutor = class {
|
|
|
741
940
|
throw new Error(`WarpEvmExecutor: Failed to encode function data for ${action.func}: ${error}`);
|
|
742
941
|
}
|
|
743
942
|
}
|
|
744
|
-
async
|
|
745
|
-
|
|
746
|
-
if (
|
|
747
|
-
|
|
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);
|
|
748
957
|
}
|
|
749
|
-
if (
|
|
750
|
-
|
|
958
|
+
if (nativeTokenTransfers.length === 0 && erc20Transfers.length === 1) {
|
|
959
|
+
return this.createSingleTokenTransfer(executable, erc20Transfers[0], userWallet);
|
|
751
960
|
}
|
|
752
|
-
if (
|
|
753
|
-
|
|
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}`);
|
|
754
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}`);
|
|
755
982
|
try {
|
|
756
|
-
|
|
757
|
-
|
|
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);
|
|
758
991
|
const result = await this.provider.call({
|
|
759
992
|
to: executable.destination,
|
|
760
993
|
data: encodedData
|
|
761
994
|
});
|
|
762
995
|
const decodedResult = iface.decodeFunctionResult(action.func, result);
|
|
763
996
|
const isSuccess = true;
|
|
764
|
-
const { values,
|
|
997
|
+
const { values, output } = await this.output.extractQueryOutput(
|
|
765
998
|
executable.warp,
|
|
766
999
|
decodedResult,
|
|
767
1000
|
executable.action,
|
|
768
1001
|
executable.resolvedInputs
|
|
769
1002
|
);
|
|
770
|
-
const next = (0,
|
|
1003
|
+
const next = (0, import_warps10.getNextInfo)(this.config, [], executable.warp, executable.action, output);
|
|
771
1004
|
return {
|
|
772
|
-
success:
|
|
1005
|
+
status: isSuccess ? "success" : "error",
|
|
773
1006
|
warp: executable.warp,
|
|
774
1007
|
action: executable.action,
|
|
775
|
-
user: this.config
|
|
1008
|
+
user: (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
776
1009
|
txHash: null,
|
|
1010
|
+
tx: null,
|
|
777
1011
|
next,
|
|
778
1012
|
values,
|
|
779
|
-
|
|
780
|
-
messages: (0,
|
|
1013
|
+
output: { ...output, _DATA: decodedResult },
|
|
1014
|
+
messages: (0, import_warps10.applyOutputToMessages)(executable.warp, output, this.config)
|
|
781
1015
|
};
|
|
782
1016
|
} catch (error) {
|
|
783
1017
|
return {
|
|
784
|
-
|
|
1018
|
+
status: "error",
|
|
785
1019
|
warp: executable.warp,
|
|
786
1020
|
action: executable.action,
|
|
787
|
-
user: this.config
|
|
1021
|
+
user: (0, import_warps10.getWarpWalletAddressFromConfig)(this.config, executable.chain.name),
|
|
788
1022
|
txHash: null,
|
|
1023
|
+
tx: null,
|
|
789
1024
|
next: null,
|
|
790
|
-
values: [],
|
|
791
|
-
|
|
1025
|
+
values: { string: [], native: [] },
|
|
1026
|
+
output: { _DATA: error },
|
|
792
1027
|
messages: {}
|
|
793
1028
|
};
|
|
794
1029
|
}
|
|
795
1030
|
}
|
|
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
1031
|
async estimateGasAndSetDefaults(tx, from) {
|
|
824
1032
|
try {
|
|
825
1033
|
const gasEstimate = await this.provider.estimateGas({
|
|
826
1034
|
...tx,
|
|
827
1035
|
from
|
|
828
1036
|
});
|
|
829
|
-
if (gasEstimate < BigInt(WarpEvmConstants.Validation.MinGasLimit)) {
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
if (gasEstimate > BigInt(WarpEvmConstants.Validation.MaxGasLimit)) {
|
|
833
|
-
throw new Error(`Gas estimate too high: ${gasEstimate}`);
|
|
834
|
-
}
|
|
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}`);
|
|
835
1039
|
const feeData = await this.provider.getFeeData();
|
|
836
1040
|
if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) {
|
|
837
1041
|
return {
|
|
838
1042
|
...tx,
|
|
1043
|
+
chainId: parseInt(this.chain.chainId),
|
|
839
1044
|
gasLimit: gasEstimate,
|
|
840
1045
|
maxFeePerGas: feeData.maxFeePerGas,
|
|
841
1046
|
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas
|
|
@@ -843,32 +1048,44 @@ var WarpEvmExecutor = class {
|
|
|
843
1048
|
} else if (feeData.gasPrice) {
|
|
844
1049
|
return {
|
|
845
1050
|
...tx,
|
|
1051
|
+
chainId: parseInt(this.chain.chainId),
|
|
846
1052
|
gasLimit: gasEstimate,
|
|
847
1053
|
gasPrice: feeData.gasPrice
|
|
848
1054
|
};
|
|
849
1055
|
} else {
|
|
850
1056
|
return {
|
|
851
1057
|
...tx,
|
|
1058
|
+
chainId: parseInt(this.chain.chainId),
|
|
852
1059
|
gasLimit: gasEstimate,
|
|
853
|
-
gasPrice:
|
|
1060
|
+
gasPrice: import_ethers4.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
854
1061
|
};
|
|
855
1062
|
}
|
|
856
1063
|
} catch (error) {
|
|
857
1064
|
let defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Default);
|
|
858
1065
|
if (tx.data && tx.data !== "0x") {
|
|
859
|
-
|
|
1066
|
+
if (tx.data.startsWith("0xa9059cbb")) {
|
|
1067
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.TokenTransfer);
|
|
1068
|
+
} else {
|
|
1069
|
+
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.ContractCall);
|
|
1070
|
+
}
|
|
860
1071
|
} else {
|
|
861
1072
|
defaultGasLimit = BigInt(WarpEvmConstants.GasLimit.Transfer);
|
|
862
1073
|
}
|
|
863
1074
|
return {
|
|
864
1075
|
...tx,
|
|
1076
|
+
chainId: parseInt(this.chain.chainId),
|
|
865
1077
|
gasLimit: defaultGasLimit,
|
|
866
|
-
gasPrice:
|
|
1078
|
+
gasPrice: import_ethers4.ethers.parseUnits(WarpEvmConstants.GasPrice.Default, "wei")
|
|
867
1079
|
};
|
|
868
1080
|
}
|
|
869
1081
|
}
|
|
870
|
-
async
|
|
871
|
-
|
|
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
|
+
}
|
|
872
1089
|
}
|
|
873
1090
|
};
|
|
874
1091
|
|
|
@@ -956,155 +1173,376 @@ var WarpEvmExplorer = class {
|
|
|
956
1173
|
});
|
|
957
1174
|
return urls;
|
|
958
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
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
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
|
+
}
|
|
959
1303
|
};
|
|
960
1304
|
|
|
961
1305
|
// src/chains/common.ts
|
|
962
|
-
var createEvmAdapter = (chainName,
|
|
1306
|
+
var createEvmAdapter = (chainName, chainInfos) => {
|
|
963
1307
|
return (config, fallback) => {
|
|
964
1308
|
if (!fallback) throw new Error(`${chainName} adapter requires a fallback adapter`);
|
|
965
1309
|
return {
|
|
966
|
-
chain: chainName,
|
|
967
1310
|
chainInfo: chainInfos[config.env],
|
|
968
|
-
prefix: chainPrefix,
|
|
969
1311
|
builder: () => fallback.builder(),
|
|
970
|
-
executor: new WarpEvmExecutor(config),
|
|
971
|
-
|
|
1312
|
+
executor: new WarpEvmExecutor(config, chainInfos[config.env]),
|
|
1313
|
+
output: new WarpEvmOutput(config, chainInfos[config.env]),
|
|
972
1314
|
serializer: new WarpEvmSerializer(),
|
|
973
1315
|
registry: fallback.registry,
|
|
974
1316
|
explorer: new WarpEvmExplorer(chainInfos[config.env], config),
|
|
975
1317
|
abiBuilder: () => fallback.abiBuilder(),
|
|
976
1318
|
brandBuilder: () => fallback.brandBuilder(),
|
|
977
|
-
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env])
|
|
1319
|
+
dataLoader: new WarpEvmDataLoader(config, chainInfos[config.env]),
|
|
1320
|
+
wallet: new WarpEvmWallet(config, chainInfos[config.env])
|
|
978
1321
|
};
|
|
979
1322
|
};
|
|
980
1323
|
};
|
|
981
1324
|
|
|
982
1325
|
// src/chains/arbitrum.ts
|
|
983
|
-
var
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
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",
|
|
989
1339
|
blockTime: 1e3,
|
|
990
1340
|
addressHrp: "0x",
|
|
991
|
-
|
|
992
|
-
|
|
1341
|
+
defaultApiUrl: "https://arb1.arbitrum.io/rpc",
|
|
1342
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1343
|
+
nativeToken: NativeTokenArb
|
|
993
1344
|
},
|
|
994
1345
|
testnet: {
|
|
995
|
-
name:
|
|
996
|
-
displayName: "Arbitrum
|
|
997
|
-
chainId: "
|
|
1346
|
+
name: import_warps12.WarpChainName.Arbitrum,
|
|
1347
|
+
displayName: "Arbitrum Sepolia",
|
|
1348
|
+
chainId: "421614",
|
|
998
1349
|
blockTime: 1e3,
|
|
999
1350
|
addressHrp: "0x",
|
|
1000
|
-
|
|
1001
|
-
|
|
1351
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1352
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1353
|
+
nativeToken: NativeTokenArb
|
|
1002
1354
|
},
|
|
1003
|
-
|
|
1004
|
-
name:
|
|
1005
|
-
displayName: "Arbitrum",
|
|
1006
|
-
chainId: "
|
|
1355
|
+
devnet: {
|
|
1356
|
+
name: import_warps12.WarpChainName.Arbitrum,
|
|
1357
|
+
displayName: "Arbitrum Sepolia",
|
|
1358
|
+
chainId: "421614",
|
|
1007
1359
|
blockTime: 1e3,
|
|
1008
1360
|
addressHrp: "0x",
|
|
1009
|
-
|
|
1010
|
-
|
|
1361
|
+
defaultApiUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
1362
|
+
logoUrl: "https://vleap.ai/images/chains/arbitrum.svg",
|
|
1363
|
+
nativeToken: NativeTokenArb
|
|
1011
1364
|
}
|
|
1012
1365
|
});
|
|
1013
1366
|
|
|
1014
1367
|
// src/chains/base.ts
|
|
1015
|
-
var
|
|
1016
|
-
var
|
|
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, {
|
|
1017
1378
|
mainnet: {
|
|
1018
|
-
name:
|
|
1379
|
+
name: import_warps13.WarpChainName.Base,
|
|
1019
1380
|
displayName: "Base",
|
|
1020
1381
|
chainId: "8453",
|
|
1021
1382
|
blockTime: 2e3,
|
|
1022
1383
|
addressHrp: "0x",
|
|
1023
|
-
|
|
1024
|
-
|
|
1384
|
+
defaultApiUrl: "https://mainnet.base.org",
|
|
1385
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1386
|
+
nativeToken: NativeTokenBase
|
|
1025
1387
|
},
|
|
1026
1388
|
testnet: {
|
|
1027
|
-
name:
|
|
1028
|
-
displayName: "Base
|
|
1029
|
-
chainId: "
|
|
1389
|
+
name: import_warps13.WarpChainName.Base,
|
|
1390
|
+
displayName: "Base Sepolia",
|
|
1391
|
+
chainId: "84532",
|
|
1030
1392
|
blockTime: 2e3,
|
|
1031
1393
|
addressHrp: "0x",
|
|
1032
|
-
|
|
1033
|
-
|
|
1394
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1395
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1396
|
+
nativeToken: NativeTokenBase
|
|
1034
1397
|
},
|
|
1035
1398
|
devnet: {
|
|
1036
|
-
name:
|
|
1037
|
-
displayName: "Base
|
|
1399
|
+
name: import_warps13.WarpChainName.Base,
|
|
1400
|
+
displayName: "Base Sepolia",
|
|
1038
1401
|
chainId: "84532",
|
|
1039
1402
|
blockTime: 2e3,
|
|
1040
1403
|
addressHrp: "0x",
|
|
1041
|
-
|
|
1042
|
-
|
|
1404
|
+
defaultApiUrl: "https://sepolia.base.org",
|
|
1405
|
+
logoUrl: "https://vleap.ai/images/chains/base.svg",
|
|
1406
|
+
nativeToken: NativeTokenBase
|
|
1043
1407
|
}
|
|
1044
1408
|
});
|
|
1045
1409
|
|
|
1410
|
+
// src/chains/combined.ts
|
|
1411
|
+
var import_warps16 = require("@vleap/warps");
|
|
1412
|
+
|
|
1046
1413
|
// src/chains/ethereum.ts
|
|
1047
|
-
var
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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",
|
|
1053
1428
|
blockTime: 12e3,
|
|
1054
1429
|
addressHrp: "0x",
|
|
1055
|
-
|
|
1056
|
-
|
|
1430
|
+
defaultApiUrl: "https://ethereum-rpc.publicnode.com",
|
|
1431
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1432
|
+
nativeToken: NativeTokenEth
|
|
1057
1433
|
},
|
|
1058
1434
|
testnet: {
|
|
1059
|
-
name:
|
|
1060
|
-
displayName: "Ethereum
|
|
1061
|
-
chainId: "
|
|
1435
|
+
name: import_warps14.WarpChainName.Ethereum,
|
|
1436
|
+
displayName: "Ethereum Sepolia",
|
|
1437
|
+
chainId: "11155111",
|
|
1062
1438
|
blockTime: 12e3,
|
|
1063
1439
|
addressHrp: "0x",
|
|
1064
|
-
|
|
1065
|
-
|
|
1440
|
+
defaultApiUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
1441
|
+
logoUrl: "https://vleap.ai/images/chains/ethereum.svg",
|
|
1442
|
+
nativeToken: NativeTokenEth
|
|
1066
1443
|
},
|
|
1067
|
-
|
|
1068
|
-
name:
|
|
1069
|
-
displayName: "Ethereum
|
|
1070
|
-
chainId: "
|
|
1444
|
+
devnet: {
|
|
1445
|
+
name: import_warps14.WarpChainName.Ethereum,
|
|
1446
|
+
displayName: "Ethereum Sepolia",
|
|
1447
|
+
chainId: "11155111",
|
|
1071
1448
|
blockTime: 12e3,
|
|
1072
1449
|
addressHrp: "0x",
|
|
1073
|
-
|
|
1074
|
-
|
|
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
|
|
1075
1504
|
}
|
|
1076
1505
|
});
|
|
1077
1506
|
|
|
1078
1507
|
// src/chains/combined.ts
|
|
1079
1508
|
var getAllEvmAdapters = (config, fallback) => [
|
|
1080
1509
|
getEthereumAdapter(config, fallback),
|
|
1510
|
+
getBaseAdapter(config, fallback),
|
|
1081
1511
|
getArbitrumAdapter(config, fallback),
|
|
1082
|
-
|
|
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
|
|
1083
1519
|
];
|
|
1084
|
-
var getAllEvmChainNames = () => [ChainNameArbitrum, ChainNameBase, ChainNameEthereum];
|
|
1085
1520
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1086
1521
|
0 && (module.exports = {
|
|
1087
1522
|
ArbitrumExplorers,
|
|
1088
1523
|
BaseExplorers,
|
|
1089
|
-
ChainNameArbitrum,
|
|
1090
|
-
ChainNameBase,
|
|
1091
|
-
ChainNameEthereum,
|
|
1092
|
-
EVM_CHAIN_CONFIGS,
|
|
1093
1524
|
EthereumExplorers,
|
|
1094
1525
|
EvmExplorers,
|
|
1095
1526
|
ExplorerUrls,
|
|
1527
|
+
KnownTokens,
|
|
1528
|
+
NativeTokenArb,
|
|
1529
|
+
NativeTokenBase,
|
|
1530
|
+
NativeTokenEth,
|
|
1531
|
+
UniswapService,
|
|
1096
1532
|
WarpEvmConstants,
|
|
1533
|
+
WarpEvmDataLoader,
|
|
1097
1534
|
WarpEvmExecutor,
|
|
1098
1535
|
WarpEvmExplorer,
|
|
1099
|
-
|
|
1536
|
+
WarpEvmOutput,
|
|
1100
1537
|
WarpEvmSerializer,
|
|
1538
|
+
WarpEvmWallet,
|
|
1539
|
+
createEvmAdapter,
|
|
1540
|
+
findKnownTokenById,
|
|
1101
1541
|
getAllEvmAdapters,
|
|
1102
1542
|
getAllEvmChainNames,
|
|
1103
1543
|
getArbitrumAdapter,
|
|
1104
1544
|
getBaseAdapter,
|
|
1105
1545
|
getEthereumAdapter,
|
|
1106
|
-
|
|
1107
|
-
getEvmChainConfig,
|
|
1108
|
-
getEvmExplorerUrl
|
|
1546
|
+
getKnownTokensForChain
|
|
1109
1547
|
});
|
|
1110
1548
|
//# sourceMappingURL=index.js.map
|