@joai/warps-adapter-evm 1.0.0-beta.74
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/README.md +64 -0
- package/dist/index.d.cts +296 -0
- package/dist/index.d.ts +296 -0
- package/dist/index.js +2329 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2301 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @joai/warps-adapter-evm
|
|
2
|
+
|
|
3
|
+
EVM-compatible blockchain adapter for the Warps SDK. Supports Ethereum, Base, Polygon, Arbitrum, Optimism, and other EVM chains.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @joai/warps-adapter-evm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { WarpClient } from '@joai/warps'
|
|
15
|
+
import { getAllEvmAdapters } from '@joai/warps-adapter-evm'
|
|
16
|
+
import { MultiversxAdapter } from '@joai/warps-adapter-multiversx'
|
|
17
|
+
|
|
18
|
+
// Use all EVM chains (requires a fallback adapter)
|
|
19
|
+
const client = new WarpClient(config, {
|
|
20
|
+
chains: getAllEvmAdapters(MultiversxAdapter),
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Individual Chain Adapters
|
|
25
|
+
|
|
26
|
+
You can also import individual chain adapters:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { EthereumAdapter, BaseAdapter, PolygonAdapter } from '@joai/warps-adapter-evm'
|
|
30
|
+
import { withAdapterFallback } from '@joai/warps'
|
|
31
|
+
import { MultiversxAdapter } from '@joai/warps-adapter-multiversx'
|
|
32
|
+
|
|
33
|
+
const client = new WarpClient(config, {
|
|
34
|
+
chains: [
|
|
35
|
+
withAdapterFallback(EthereumAdapter, MultiversxAdapter),
|
|
36
|
+
withAdapterFallback(BaseAdapter, MultiversxAdapter),
|
|
37
|
+
],
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Supported Chains
|
|
42
|
+
|
|
43
|
+
- **Ethereum** (mainnet, sepolia)
|
|
44
|
+
- **Base** (mainnet, sepolia)
|
|
45
|
+
- **Polygon** (mainnet, amoy)
|
|
46
|
+
- **Arbitrum** (mainnet, sepolia)
|
|
47
|
+
- **Optimism** (mainnet, sepolia)
|
|
48
|
+
- And other EVM-compatible networks
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- Transaction creation and execution
|
|
53
|
+
- Smart contract interaction
|
|
54
|
+
- Token transfers
|
|
55
|
+
- Query contract state
|
|
56
|
+
- Transaction signing and broadcasting
|
|
57
|
+
- Explorer integration
|
|
58
|
+
|
|
59
|
+
## Wallet Providers
|
|
60
|
+
|
|
61
|
+
Supports multiple wallet providers:
|
|
62
|
+
- Private key
|
|
63
|
+
- Mnemonic
|
|
64
|
+
- Read-only (for queries)
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChainName, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails, WarpWalletProvider } from '@joai/warps';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
|
|
4
|
+
declare const NativeTokenArb: WarpChainAsset;
|
|
5
|
+
declare const ArbitrumAdapter: ChainAdapterFactory;
|
|
6
|
+
|
|
7
|
+
declare const NativeTokenBase: WarpChainAsset;
|
|
8
|
+
declare const BaseAdapter: ChainAdapterFactory;
|
|
9
|
+
|
|
10
|
+
declare const getAllEvmChainNames: () => WarpChainName[];
|
|
11
|
+
|
|
12
|
+
declare const createEvmAdapter: (chainName: WarpChainName, chainInfos: Record<WarpChainEnv, WarpChainInfo>) => ChainAdapterFactory;
|
|
13
|
+
|
|
14
|
+
declare const NativeTokenEth: WarpChainAsset;
|
|
15
|
+
declare const EthereumAdapter: ChainAdapterFactory;
|
|
16
|
+
|
|
17
|
+
declare const NativeTokenPolygon: WarpChainAsset;
|
|
18
|
+
declare const PolygonAdapter: ChainAdapterFactory;
|
|
19
|
+
|
|
20
|
+
declare const WarpEvmConstants: {
|
|
21
|
+
GasLimit: {
|
|
22
|
+
Default: number;
|
|
23
|
+
ContractCall: number;
|
|
24
|
+
ContractDeploy: number;
|
|
25
|
+
Transfer: number;
|
|
26
|
+
TokenTransfer: number;
|
|
27
|
+
Approve: number;
|
|
28
|
+
Swap: number;
|
|
29
|
+
};
|
|
30
|
+
GasPrice: {
|
|
31
|
+
Default: string;
|
|
32
|
+
};
|
|
33
|
+
Validation: {
|
|
34
|
+
MinGasLimit: number;
|
|
35
|
+
MaxGasLimit: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
declare enum EthereumExplorers {
|
|
39
|
+
Etherscan = "etherscan",
|
|
40
|
+
EtherscanSepolia = "etherscan_sepolia",
|
|
41
|
+
Ethplorer = "ethplorer",
|
|
42
|
+
Blockscout = "blockscout",
|
|
43
|
+
BlockscoutSepolia = "blockscout_sepolia"
|
|
44
|
+
}
|
|
45
|
+
declare enum ArbitrumExplorers {
|
|
46
|
+
Arbiscan = "arbiscan",
|
|
47
|
+
ArbiscanSepolia = "arbiscan_sepolia",
|
|
48
|
+
BlockscoutArbitrum = "blockscout_arbitrum",
|
|
49
|
+
BlockscoutArbitrumSepolia = "blockscout_arbitrum_sepolia"
|
|
50
|
+
}
|
|
51
|
+
declare enum BaseExplorers {
|
|
52
|
+
Basescan = "basescan",
|
|
53
|
+
BasescanSepolia = "basescan_sepolia",
|
|
54
|
+
BlockscoutBase = "blockscout_base",
|
|
55
|
+
BlockscoutBaseSepolia = "blockscout_base_sepolia"
|
|
56
|
+
}
|
|
57
|
+
declare enum PolygonExplorers {
|
|
58
|
+
Polygonscan = "polygonscan",
|
|
59
|
+
PolygonscanMumbai = "polygonscan_mumbai",
|
|
60
|
+
BlockscoutPolygon = "blockscout_polygon",
|
|
61
|
+
BlockscoutPolygonMumbai = "blockscout_polygon_mumbai"
|
|
62
|
+
}
|
|
63
|
+
type ExplorerName = EthereumExplorers | ArbitrumExplorers | BaseExplorers | PolygonExplorers;
|
|
64
|
+
declare const EvmExplorers: {
|
|
65
|
+
readonly ethereum: {
|
|
66
|
+
readonly mainnet: readonly [EthereumExplorers.Etherscan, EthereumExplorers.Ethplorer, EthereumExplorers.Blockscout];
|
|
67
|
+
readonly testnet: readonly [EthereumExplorers.EtherscanSepolia, EthereumExplorers.BlockscoutSepolia];
|
|
68
|
+
readonly devnet: readonly [EthereumExplorers.EtherscanSepolia, EthereumExplorers.BlockscoutSepolia];
|
|
69
|
+
};
|
|
70
|
+
readonly arbitrum: {
|
|
71
|
+
readonly mainnet: readonly [ArbitrumExplorers.Arbiscan, ArbitrumExplorers.BlockscoutArbitrum];
|
|
72
|
+
readonly testnet: readonly [ArbitrumExplorers.ArbiscanSepolia, ArbitrumExplorers.BlockscoutArbitrumSepolia];
|
|
73
|
+
readonly devnet: readonly [ArbitrumExplorers.ArbiscanSepolia, ArbitrumExplorers.BlockscoutArbitrumSepolia];
|
|
74
|
+
};
|
|
75
|
+
readonly base: {
|
|
76
|
+
readonly mainnet: readonly [BaseExplorers.Basescan, BaseExplorers.BlockscoutBase];
|
|
77
|
+
readonly testnet: readonly [BaseExplorers.BasescanSepolia, BaseExplorers.BlockscoutBaseSepolia];
|
|
78
|
+
readonly devnet: readonly [BaseExplorers.BasescanSepolia, BaseExplorers.BlockscoutBaseSepolia];
|
|
79
|
+
};
|
|
80
|
+
readonly polygon: {
|
|
81
|
+
readonly mainnet: readonly [PolygonExplorers.Polygonscan, PolygonExplorers.BlockscoutPolygon];
|
|
82
|
+
readonly testnet: readonly [PolygonExplorers.PolygonscanMumbai, PolygonExplorers.BlockscoutPolygonMumbai];
|
|
83
|
+
readonly devnet: readonly [PolygonExplorers.PolygonscanMumbai, PolygonExplorers.BlockscoutPolygonMumbai];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
87
|
+
declare const EvmChainIds: {
|
|
88
|
+
readonly Ethereum: {
|
|
89
|
+
readonly Mainnet: 1;
|
|
90
|
+
readonly Goerli: 5;
|
|
91
|
+
readonly Sepolia: 11155111;
|
|
92
|
+
};
|
|
93
|
+
readonly Polygon: {
|
|
94
|
+
readonly Mainnet: 137;
|
|
95
|
+
readonly Mumbai: 80001;
|
|
96
|
+
};
|
|
97
|
+
readonly Arbitrum: {
|
|
98
|
+
readonly Mainnet: 42161;
|
|
99
|
+
readonly Sepolia: 421614;
|
|
100
|
+
};
|
|
101
|
+
readonly Base: {
|
|
102
|
+
readonly Mainnet: 8453;
|
|
103
|
+
readonly Sepolia: 84532;
|
|
104
|
+
};
|
|
105
|
+
readonly Optimism: {
|
|
106
|
+
readonly Mainnet: 10;
|
|
107
|
+
readonly Sepolia: 11155420;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
declare const EvmChainIdMap: Record<string, number>;
|
|
111
|
+
declare const SupportedEvmChainIds: number[];
|
|
112
|
+
|
|
113
|
+
declare const getAllEvmAdapters: (fallbackFactory: ChainAdapterFactory) => ChainAdapterFactory[];
|
|
114
|
+
|
|
115
|
+
declare const KnownTokens: Partial<Record<WarpChainName, Record<string, WarpChainAsset[]>>>;
|
|
116
|
+
declare const findKnownTokenById: (chain: WarpChainName, env: WarpChainEnv, id: string) => WarpChainAsset | null;
|
|
117
|
+
declare const getKnownTokensForChain: (chainName: WarpChainName, env?: string) => WarpChainAsset[];
|
|
118
|
+
|
|
119
|
+
interface TokenMetadata {
|
|
120
|
+
name: string;
|
|
121
|
+
symbol: string;
|
|
122
|
+
decimals: number;
|
|
123
|
+
logoUrl?: string;
|
|
124
|
+
}
|
|
125
|
+
interface TokenBalance {
|
|
126
|
+
tokenAddress: string;
|
|
127
|
+
balance: bigint;
|
|
128
|
+
metadata: TokenMetadata;
|
|
129
|
+
}
|
|
130
|
+
interface TokenInfo {
|
|
131
|
+
name?: string;
|
|
132
|
+
symbol?: string;
|
|
133
|
+
logoURI?: string;
|
|
134
|
+
decimals?: number;
|
|
135
|
+
}
|
|
136
|
+
interface UniswapToken {
|
|
137
|
+
chainId: number;
|
|
138
|
+
address: string;
|
|
139
|
+
name: string;
|
|
140
|
+
symbol: string;
|
|
141
|
+
decimals: number;
|
|
142
|
+
logoURI: string;
|
|
143
|
+
extensions?: {
|
|
144
|
+
bridgeInfo?: Record<string, {
|
|
145
|
+
tokenAddress: string;
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
interface UniswapTokenList {
|
|
150
|
+
name: string;
|
|
151
|
+
timestamp: string;
|
|
152
|
+
version: {
|
|
153
|
+
major: number;
|
|
154
|
+
minor: number;
|
|
155
|
+
patch: number;
|
|
156
|
+
};
|
|
157
|
+
tokens: UniswapToken[];
|
|
158
|
+
}
|
|
159
|
+
interface TokenListResponse {
|
|
160
|
+
tokens: Array<{
|
|
161
|
+
chainId: number;
|
|
162
|
+
address: string;
|
|
163
|
+
name: string;
|
|
164
|
+
symbol: string;
|
|
165
|
+
decimals: number;
|
|
166
|
+
logoURI?: string;
|
|
167
|
+
}>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class WarpEvmDataLoader implements AdapterWarpDataLoader {
|
|
171
|
+
private readonly config;
|
|
172
|
+
private readonly chain;
|
|
173
|
+
private provider;
|
|
174
|
+
private cache;
|
|
175
|
+
private uniswapService;
|
|
176
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
177
|
+
private getRequiredConfirmations;
|
|
178
|
+
getAccount(address: string): Promise<WarpChainAccount>;
|
|
179
|
+
getAccountAssets(address: string): Promise<WarpChainAsset[]>;
|
|
180
|
+
getAsset(identifier: string): Promise<WarpChainAsset | null>;
|
|
181
|
+
getAction(identifier: string, awaitCompleted?: boolean): Promise<WarpChainAction | null>;
|
|
182
|
+
getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
|
|
183
|
+
private getERC20TokenBalances;
|
|
184
|
+
private getTokenBalance;
|
|
185
|
+
private getTokenMetadata;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class WarpEvmExecutor implements AdapterWarpExecutor {
|
|
189
|
+
private readonly config;
|
|
190
|
+
private readonly chain;
|
|
191
|
+
private readonly serializer;
|
|
192
|
+
private readonly provider;
|
|
193
|
+
private readonly output;
|
|
194
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
195
|
+
createTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
196
|
+
createTransferTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
197
|
+
createContractCallTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
198
|
+
private createTokenTransferTransaction;
|
|
199
|
+
private createSingleTokenTransfer;
|
|
200
|
+
executeQuery(executable: WarpExecutable): Promise<WarpActionExecutionResult>;
|
|
201
|
+
private estimateGasAndSetDefaults;
|
|
202
|
+
verifyMessage(message: string, signature: string): Promise<string>;
|
|
203
|
+
private getPayableValue;
|
|
204
|
+
private findNativeTokenAsset;
|
|
205
|
+
private prepareNativeArgs;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare class WarpEvmExplorer implements AdapterWarpExplorer {
|
|
209
|
+
private readonly chain;
|
|
210
|
+
private readonly config;
|
|
211
|
+
constructor(chain: WarpChainInfo, config: WarpClientConfig);
|
|
212
|
+
private getExplorers;
|
|
213
|
+
private getPrimaryExplorer;
|
|
214
|
+
private getExplorerUrlByName;
|
|
215
|
+
getAccountUrl(address: string, explorer?: ExplorerName): string;
|
|
216
|
+
getTransactionUrl(hash: string, explorer?: ExplorerName): string;
|
|
217
|
+
getBlockUrl(blockNumber: string | number, explorer?: ExplorerName): string;
|
|
218
|
+
getAssetUrl(identifier: string, explorer?: ExplorerName): string;
|
|
219
|
+
getContractUrl(address: string, explorer?: ExplorerName): string;
|
|
220
|
+
getAllExplorers(): readonly ExplorerName[];
|
|
221
|
+
getExplorerByName(name: string): ExplorerName | undefined;
|
|
222
|
+
getAccountUrls(address: string): Record<ExplorerName, string>;
|
|
223
|
+
getTransactionUrls(hash: string): Record<ExplorerName, string>;
|
|
224
|
+
getAssetUrls(identifier: string): Record<ExplorerName, string>;
|
|
225
|
+
getContractUrls(address: string): Record<ExplorerName, string>;
|
|
226
|
+
getBlockUrls(blockNumber: string | number): Record<ExplorerName, string>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare class WarpEvmOutput implements AdapterWarpOutput {
|
|
230
|
+
private readonly config;
|
|
231
|
+
private readonly chain;
|
|
232
|
+
private readonly serializer;
|
|
233
|
+
private readonly provider;
|
|
234
|
+
private readonly cache;
|
|
235
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
236
|
+
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecutionResult>;
|
|
237
|
+
private createFailedExecution;
|
|
238
|
+
private handleWarpChainAction;
|
|
239
|
+
private handleTransactionReceipt;
|
|
240
|
+
extractQueryOutput(warp: Warp, typedValues: unknown[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
|
|
241
|
+
values: {
|
|
242
|
+
string: string[];
|
|
243
|
+
native: WarpNativeValue[];
|
|
244
|
+
mapped: Record<string, any>;
|
|
245
|
+
};
|
|
246
|
+
output: WarpExecutionOutput;
|
|
247
|
+
}>;
|
|
248
|
+
getTransactionStatus(txHash: string): Promise<{
|
|
249
|
+
status: 'pending' | 'confirmed' | 'failed';
|
|
250
|
+
blockNumber?: number;
|
|
251
|
+
gasUsed?: bigint;
|
|
252
|
+
}>;
|
|
253
|
+
getTransactionReceipt(txHash: string): Promise<ethers.TransactionReceipt | null>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare class WarpEvmSerializer implements AdapterWarpSerializer {
|
|
257
|
+
readonly coreSerializer: WarpSerializer;
|
|
258
|
+
constructor();
|
|
259
|
+
typedToString(value: any): string;
|
|
260
|
+
typedToNative(value: any): [WarpActionInputType, WarpNativeValue];
|
|
261
|
+
nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): any;
|
|
262
|
+
nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
|
|
263
|
+
stringToTyped(value: string): any;
|
|
264
|
+
private parseNativeValue;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
268
|
+
private config;
|
|
269
|
+
private chain;
|
|
270
|
+
private provider;
|
|
271
|
+
private walletProvider;
|
|
272
|
+
private cachedAddress;
|
|
273
|
+
private cachedPublicKey;
|
|
274
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
275
|
+
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
276
|
+
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
277
|
+
signMessage(message: string): Promise<string>;
|
|
278
|
+
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
279
|
+
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
280
|
+
importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
|
|
281
|
+
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
282
|
+
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
283
|
+
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
284
|
+
getAddress(): string | null;
|
|
285
|
+
getPublicKey(): string | null;
|
|
286
|
+
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
|
287
|
+
private createProvider;
|
|
288
|
+
private getAddressAsync;
|
|
289
|
+
private createProviderForOperation;
|
|
290
|
+
private normalizeFees;
|
|
291
|
+
private parseBigInt;
|
|
292
|
+
private adjustFeesForMultipleTransactions;
|
|
293
|
+
private normalizePriorityFee;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export { ArbitrumAdapter, ArbitrumExplorers, BaseAdapter, BaseExplorers, EthereumAdapter, EthereumExplorers, EvmChainIdMap, EvmChainIds, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, NativeTokenPolygon, PolygonAdapter, PolygonExplorers, SupportedEvmChainIds, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmOutput, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getKnownTokensForChain };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { WarpChainAsset, ChainAdapterFactory, WarpChainName, WarpChainEnv, WarpChainInfo, AdapterWarpDataLoader, WarpClientConfig, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpActionExecutionResult, AdapterWarpExplorer, AdapterWarpOutput, Warp, WarpActionIndex, WarpAdapterGenericRemoteTransaction, ResolvedInput, WarpNativeValue, WarpExecutionOutput, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, BaseWarpActionInputType, WarpAdapterGenericType, AdapterWarpWallet, WarpAdapterGenericTransaction, WarpWalletDetails, WarpWalletProvider } from '@joai/warps';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
|
|
4
|
+
declare const NativeTokenArb: WarpChainAsset;
|
|
5
|
+
declare const ArbitrumAdapter: ChainAdapterFactory;
|
|
6
|
+
|
|
7
|
+
declare const NativeTokenBase: WarpChainAsset;
|
|
8
|
+
declare const BaseAdapter: ChainAdapterFactory;
|
|
9
|
+
|
|
10
|
+
declare const getAllEvmChainNames: () => WarpChainName[];
|
|
11
|
+
|
|
12
|
+
declare const createEvmAdapter: (chainName: WarpChainName, chainInfos: Record<WarpChainEnv, WarpChainInfo>) => ChainAdapterFactory;
|
|
13
|
+
|
|
14
|
+
declare const NativeTokenEth: WarpChainAsset;
|
|
15
|
+
declare const EthereumAdapter: ChainAdapterFactory;
|
|
16
|
+
|
|
17
|
+
declare const NativeTokenPolygon: WarpChainAsset;
|
|
18
|
+
declare const PolygonAdapter: ChainAdapterFactory;
|
|
19
|
+
|
|
20
|
+
declare const WarpEvmConstants: {
|
|
21
|
+
GasLimit: {
|
|
22
|
+
Default: number;
|
|
23
|
+
ContractCall: number;
|
|
24
|
+
ContractDeploy: number;
|
|
25
|
+
Transfer: number;
|
|
26
|
+
TokenTransfer: number;
|
|
27
|
+
Approve: number;
|
|
28
|
+
Swap: number;
|
|
29
|
+
};
|
|
30
|
+
GasPrice: {
|
|
31
|
+
Default: string;
|
|
32
|
+
};
|
|
33
|
+
Validation: {
|
|
34
|
+
MinGasLimit: number;
|
|
35
|
+
MaxGasLimit: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
declare enum EthereumExplorers {
|
|
39
|
+
Etherscan = "etherscan",
|
|
40
|
+
EtherscanSepolia = "etherscan_sepolia",
|
|
41
|
+
Ethplorer = "ethplorer",
|
|
42
|
+
Blockscout = "blockscout",
|
|
43
|
+
BlockscoutSepolia = "blockscout_sepolia"
|
|
44
|
+
}
|
|
45
|
+
declare enum ArbitrumExplorers {
|
|
46
|
+
Arbiscan = "arbiscan",
|
|
47
|
+
ArbiscanSepolia = "arbiscan_sepolia",
|
|
48
|
+
BlockscoutArbitrum = "blockscout_arbitrum",
|
|
49
|
+
BlockscoutArbitrumSepolia = "blockscout_arbitrum_sepolia"
|
|
50
|
+
}
|
|
51
|
+
declare enum BaseExplorers {
|
|
52
|
+
Basescan = "basescan",
|
|
53
|
+
BasescanSepolia = "basescan_sepolia",
|
|
54
|
+
BlockscoutBase = "blockscout_base",
|
|
55
|
+
BlockscoutBaseSepolia = "blockscout_base_sepolia"
|
|
56
|
+
}
|
|
57
|
+
declare enum PolygonExplorers {
|
|
58
|
+
Polygonscan = "polygonscan",
|
|
59
|
+
PolygonscanMumbai = "polygonscan_mumbai",
|
|
60
|
+
BlockscoutPolygon = "blockscout_polygon",
|
|
61
|
+
BlockscoutPolygonMumbai = "blockscout_polygon_mumbai"
|
|
62
|
+
}
|
|
63
|
+
type ExplorerName = EthereumExplorers | ArbitrumExplorers | BaseExplorers | PolygonExplorers;
|
|
64
|
+
declare const EvmExplorers: {
|
|
65
|
+
readonly ethereum: {
|
|
66
|
+
readonly mainnet: readonly [EthereumExplorers.Etherscan, EthereumExplorers.Ethplorer, EthereumExplorers.Blockscout];
|
|
67
|
+
readonly testnet: readonly [EthereumExplorers.EtherscanSepolia, EthereumExplorers.BlockscoutSepolia];
|
|
68
|
+
readonly devnet: readonly [EthereumExplorers.EtherscanSepolia, EthereumExplorers.BlockscoutSepolia];
|
|
69
|
+
};
|
|
70
|
+
readonly arbitrum: {
|
|
71
|
+
readonly mainnet: readonly [ArbitrumExplorers.Arbiscan, ArbitrumExplorers.BlockscoutArbitrum];
|
|
72
|
+
readonly testnet: readonly [ArbitrumExplorers.ArbiscanSepolia, ArbitrumExplorers.BlockscoutArbitrumSepolia];
|
|
73
|
+
readonly devnet: readonly [ArbitrumExplorers.ArbiscanSepolia, ArbitrumExplorers.BlockscoutArbitrumSepolia];
|
|
74
|
+
};
|
|
75
|
+
readonly base: {
|
|
76
|
+
readonly mainnet: readonly [BaseExplorers.Basescan, BaseExplorers.BlockscoutBase];
|
|
77
|
+
readonly testnet: readonly [BaseExplorers.BasescanSepolia, BaseExplorers.BlockscoutBaseSepolia];
|
|
78
|
+
readonly devnet: readonly [BaseExplorers.BasescanSepolia, BaseExplorers.BlockscoutBaseSepolia];
|
|
79
|
+
};
|
|
80
|
+
readonly polygon: {
|
|
81
|
+
readonly mainnet: readonly [PolygonExplorers.Polygonscan, PolygonExplorers.BlockscoutPolygon];
|
|
82
|
+
readonly testnet: readonly [PolygonExplorers.PolygonscanMumbai, PolygonExplorers.BlockscoutPolygonMumbai];
|
|
83
|
+
readonly devnet: readonly [PolygonExplorers.PolygonscanMumbai, PolygonExplorers.BlockscoutPolygonMumbai];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
87
|
+
declare const EvmChainIds: {
|
|
88
|
+
readonly Ethereum: {
|
|
89
|
+
readonly Mainnet: 1;
|
|
90
|
+
readonly Goerli: 5;
|
|
91
|
+
readonly Sepolia: 11155111;
|
|
92
|
+
};
|
|
93
|
+
readonly Polygon: {
|
|
94
|
+
readonly Mainnet: 137;
|
|
95
|
+
readonly Mumbai: 80001;
|
|
96
|
+
};
|
|
97
|
+
readonly Arbitrum: {
|
|
98
|
+
readonly Mainnet: 42161;
|
|
99
|
+
readonly Sepolia: 421614;
|
|
100
|
+
};
|
|
101
|
+
readonly Base: {
|
|
102
|
+
readonly Mainnet: 8453;
|
|
103
|
+
readonly Sepolia: 84532;
|
|
104
|
+
};
|
|
105
|
+
readonly Optimism: {
|
|
106
|
+
readonly Mainnet: 10;
|
|
107
|
+
readonly Sepolia: 11155420;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
declare const EvmChainIdMap: Record<string, number>;
|
|
111
|
+
declare const SupportedEvmChainIds: number[];
|
|
112
|
+
|
|
113
|
+
declare const getAllEvmAdapters: (fallbackFactory: ChainAdapterFactory) => ChainAdapterFactory[];
|
|
114
|
+
|
|
115
|
+
declare const KnownTokens: Partial<Record<WarpChainName, Record<string, WarpChainAsset[]>>>;
|
|
116
|
+
declare const findKnownTokenById: (chain: WarpChainName, env: WarpChainEnv, id: string) => WarpChainAsset | null;
|
|
117
|
+
declare const getKnownTokensForChain: (chainName: WarpChainName, env?: string) => WarpChainAsset[];
|
|
118
|
+
|
|
119
|
+
interface TokenMetadata {
|
|
120
|
+
name: string;
|
|
121
|
+
symbol: string;
|
|
122
|
+
decimals: number;
|
|
123
|
+
logoUrl?: string;
|
|
124
|
+
}
|
|
125
|
+
interface TokenBalance {
|
|
126
|
+
tokenAddress: string;
|
|
127
|
+
balance: bigint;
|
|
128
|
+
metadata: TokenMetadata;
|
|
129
|
+
}
|
|
130
|
+
interface TokenInfo {
|
|
131
|
+
name?: string;
|
|
132
|
+
symbol?: string;
|
|
133
|
+
logoURI?: string;
|
|
134
|
+
decimals?: number;
|
|
135
|
+
}
|
|
136
|
+
interface UniswapToken {
|
|
137
|
+
chainId: number;
|
|
138
|
+
address: string;
|
|
139
|
+
name: string;
|
|
140
|
+
symbol: string;
|
|
141
|
+
decimals: number;
|
|
142
|
+
logoURI: string;
|
|
143
|
+
extensions?: {
|
|
144
|
+
bridgeInfo?: Record<string, {
|
|
145
|
+
tokenAddress: string;
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
interface UniswapTokenList {
|
|
150
|
+
name: string;
|
|
151
|
+
timestamp: string;
|
|
152
|
+
version: {
|
|
153
|
+
major: number;
|
|
154
|
+
minor: number;
|
|
155
|
+
patch: number;
|
|
156
|
+
};
|
|
157
|
+
tokens: UniswapToken[];
|
|
158
|
+
}
|
|
159
|
+
interface TokenListResponse {
|
|
160
|
+
tokens: Array<{
|
|
161
|
+
chainId: number;
|
|
162
|
+
address: string;
|
|
163
|
+
name: string;
|
|
164
|
+
symbol: string;
|
|
165
|
+
decimals: number;
|
|
166
|
+
logoURI?: string;
|
|
167
|
+
}>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class WarpEvmDataLoader implements AdapterWarpDataLoader {
|
|
171
|
+
private readonly config;
|
|
172
|
+
private readonly chain;
|
|
173
|
+
private provider;
|
|
174
|
+
private cache;
|
|
175
|
+
private uniswapService;
|
|
176
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
177
|
+
private getRequiredConfirmations;
|
|
178
|
+
getAccount(address: string): Promise<WarpChainAccount>;
|
|
179
|
+
getAccountAssets(address: string): Promise<WarpChainAsset[]>;
|
|
180
|
+
getAsset(identifier: string): Promise<WarpChainAsset | null>;
|
|
181
|
+
getAction(identifier: string, awaitCompleted?: boolean): Promise<WarpChainAction | null>;
|
|
182
|
+
getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
|
|
183
|
+
private getERC20TokenBalances;
|
|
184
|
+
private getTokenBalance;
|
|
185
|
+
private getTokenMetadata;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class WarpEvmExecutor implements AdapterWarpExecutor {
|
|
189
|
+
private readonly config;
|
|
190
|
+
private readonly chain;
|
|
191
|
+
private readonly serializer;
|
|
192
|
+
private readonly provider;
|
|
193
|
+
private readonly output;
|
|
194
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
195
|
+
createTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
196
|
+
createTransferTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
197
|
+
createContractCallTransaction(executable: WarpExecutable): Promise<ethers.TransactionRequest>;
|
|
198
|
+
private createTokenTransferTransaction;
|
|
199
|
+
private createSingleTokenTransfer;
|
|
200
|
+
executeQuery(executable: WarpExecutable): Promise<WarpActionExecutionResult>;
|
|
201
|
+
private estimateGasAndSetDefaults;
|
|
202
|
+
verifyMessage(message: string, signature: string): Promise<string>;
|
|
203
|
+
private getPayableValue;
|
|
204
|
+
private findNativeTokenAsset;
|
|
205
|
+
private prepareNativeArgs;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
declare class WarpEvmExplorer implements AdapterWarpExplorer {
|
|
209
|
+
private readonly chain;
|
|
210
|
+
private readonly config;
|
|
211
|
+
constructor(chain: WarpChainInfo, config: WarpClientConfig);
|
|
212
|
+
private getExplorers;
|
|
213
|
+
private getPrimaryExplorer;
|
|
214
|
+
private getExplorerUrlByName;
|
|
215
|
+
getAccountUrl(address: string, explorer?: ExplorerName): string;
|
|
216
|
+
getTransactionUrl(hash: string, explorer?: ExplorerName): string;
|
|
217
|
+
getBlockUrl(blockNumber: string | number, explorer?: ExplorerName): string;
|
|
218
|
+
getAssetUrl(identifier: string, explorer?: ExplorerName): string;
|
|
219
|
+
getContractUrl(address: string, explorer?: ExplorerName): string;
|
|
220
|
+
getAllExplorers(): readonly ExplorerName[];
|
|
221
|
+
getExplorerByName(name: string): ExplorerName | undefined;
|
|
222
|
+
getAccountUrls(address: string): Record<ExplorerName, string>;
|
|
223
|
+
getTransactionUrls(hash: string): Record<ExplorerName, string>;
|
|
224
|
+
getAssetUrls(identifier: string): Record<ExplorerName, string>;
|
|
225
|
+
getContractUrls(address: string): Record<ExplorerName, string>;
|
|
226
|
+
getBlockUrls(blockNumber: string | number): Record<ExplorerName, string>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare class WarpEvmOutput implements AdapterWarpOutput {
|
|
230
|
+
private readonly config;
|
|
231
|
+
private readonly chain;
|
|
232
|
+
private readonly serializer;
|
|
233
|
+
private readonly provider;
|
|
234
|
+
private readonly cache;
|
|
235
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
236
|
+
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecutionResult>;
|
|
237
|
+
private createFailedExecution;
|
|
238
|
+
private handleWarpChainAction;
|
|
239
|
+
private handleTransactionReceipt;
|
|
240
|
+
extractQueryOutput(warp: Warp, typedValues: unknown[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
|
|
241
|
+
values: {
|
|
242
|
+
string: string[];
|
|
243
|
+
native: WarpNativeValue[];
|
|
244
|
+
mapped: Record<string, any>;
|
|
245
|
+
};
|
|
246
|
+
output: WarpExecutionOutput;
|
|
247
|
+
}>;
|
|
248
|
+
getTransactionStatus(txHash: string): Promise<{
|
|
249
|
+
status: 'pending' | 'confirmed' | 'failed';
|
|
250
|
+
blockNumber?: number;
|
|
251
|
+
gasUsed?: bigint;
|
|
252
|
+
}>;
|
|
253
|
+
getTransactionReceipt(txHash: string): Promise<ethers.TransactionReceipt | null>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare class WarpEvmSerializer implements AdapterWarpSerializer {
|
|
257
|
+
readonly coreSerializer: WarpSerializer;
|
|
258
|
+
constructor();
|
|
259
|
+
typedToString(value: any): string;
|
|
260
|
+
typedToNative(value: any): [WarpActionInputType, WarpNativeValue];
|
|
261
|
+
nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): any;
|
|
262
|
+
nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
|
|
263
|
+
stringToTyped(value: string): any;
|
|
264
|
+
private parseNativeValue;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare class WarpEvmWallet implements AdapterWarpWallet {
|
|
268
|
+
private config;
|
|
269
|
+
private chain;
|
|
270
|
+
private provider;
|
|
271
|
+
private walletProvider;
|
|
272
|
+
private cachedAddress;
|
|
273
|
+
private cachedPublicKey;
|
|
274
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
275
|
+
signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction>;
|
|
276
|
+
signTransactions(txs: WarpAdapterGenericTransaction[]): Promise<WarpAdapterGenericTransaction[]>;
|
|
277
|
+
signMessage(message: string): Promise<string>;
|
|
278
|
+
sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
|
|
279
|
+
sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
|
|
280
|
+
importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails>;
|
|
281
|
+
importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails>;
|
|
282
|
+
export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
283
|
+
generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
|
|
284
|
+
getAddress(): string | null;
|
|
285
|
+
getPublicKey(): string | null;
|
|
286
|
+
registerX402Handlers(client: unknown): Promise<Record<string, () => void>>;
|
|
287
|
+
private createProvider;
|
|
288
|
+
private getAddressAsync;
|
|
289
|
+
private createProviderForOperation;
|
|
290
|
+
private normalizeFees;
|
|
291
|
+
private parseBigInt;
|
|
292
|
+
private adjustFeesForMultipleTransactions;
|
|
293
|
+
private normalizePriorityFee;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export { ArbitrumAdapter, ArbitrumExplorers, BaseAdapter, BaseExplorers, EthereumAdapter, EthereumExplorers, EvmChainIdMap, EvmChainIds, EvmExplorers, type ExplorerName, ExplorerUrls, KnownTokens, NativeTokenArb, NativeTokenBase, NativeTokenEth, NativeTokenPolygon, PolygonAdapter, PolygonExplorers, SupportedEvmChainIds, type TokenBalance, type TokenInfo, type TokenListResponse, type TokenMetadata, type UniswapToken, type UniswapTokenList, WarpEvmConstants, WarpEvmDataLoader, WarpEvmExecutor, WarpEvmExplorer, WarpEvmOutput, WarpEvmSerializer, WarpEvmWallet, createEvmAdapter, findKnownTokenById, getAllEvmAdapters, getAllEvmChainNames, getKnownTokensForChain };
|