@waiaas/adapter-evm 2.0.0-rc.1

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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * ERC-20 standard ABI for viem contract interactions.
3
+ *
4
+ * Includes: transfer, approve, balanceOf, allowance, decimals, symbol, name, totalSupply.
5
+ * Uses `as const` for viem type inference (abi parameter requires literal types).
6
+ */
7
+ export declare const ERC20_ABI: readonly [{
8
+ readonly type: "function";
9
+ readonly name: "name";
10
+ readonly stateMutability: "view";
11
+ readonly inputs: readonly [];
12
+ readonly outputs: readonly [{
13
+ readonly name: "";
14
+ readonly type: "string";
15
+ }];
16
+ }, {
17
+ readonly type: "function";
18
+ readonly name: "symbol";
19
+ readonly stateMutability: "view";
20
+ readonly inputs: readonly [];
21
+ readonly outputs: readonly [{
22
+ readonly name: "";
23
+ readonly type: "string";
24
+ }];
25
+ }, {
26
+ readonly type: "function";
27
+ readonly name: "decimals";
28
+ readonly stateMutability: "view";
29
+ readonly inputs: readonly [];
30
+ readonly outputs: readonly [{
31
+ readonly name: "";
32
+ readonly type: "uint8";
33
+ }];
34
+ }, {
35
+ readonly type: "function";
36
+ readonly name: "totalSupply";
37
+ readonly stateMutability: "view";
38
+ readonly inputs: readonly [];
39
+ readonly outputs: readonly [{
40
+ readonly name: "";
41
+ readonly type: "uint256";
42
+ }];
43
+ }, {
44
+ readonly type: "function";
45
+ readonly name: "balanceOf";
46
+ readonly stateMutability: "view";
47
+ readonly inputs: readonly [{
48
+ readonly name: "account";
49
+ readonly type: "address";
50
+ }];
51
+ readonly outputs: readonly [{
52
+ readonly name: "";
53
+ readonly type: "uint256";
54
+ }];
55
+ }, {
56
+ readonly type: "function";
57
+ readonly name: "transfer";
58
+ readonly stateMutability: "nonpayable";
59
+ readonly inputs: readonly [{
60
+ readonly name: "to";
61
+ readonly type: "address";
62
+ }, {
63
+ readonly name: "amount";
64
+ readonly type: "uint256";
65
+ }];
66
+ readonly outputs: readonly [{
67
+ readonly name: "";
68
+ readonly type: "bool";
69
+ }];
70
+ }, {
71
+ readonly type: "function";
72
+ readonly name: "approve";
73
+ readonly stateMutability: "nonpayable";
74
+ readonly inputs: readonly [{
75
+ readonly name: "spender";
76
+ readonly type: "address";
77
+ }, {
78
+ readonly name: "amount";
79
+ readonly type: "uint256";
80
+ }];
81
+ readonly outputs: readonly [{
82
+ readonly name: "";
83
+ readonly type: "bool";
84
+ }];
85
+ }, {
86
+ readonly type: "function";
87
+ readonly name: "allowance";
88
+ readonly stateMutability: "view";
89
+ readonly inputs: readonly [{
90
+ readonly name: "owner";
91
+ readonly type: "address";
92
+ }, {
93
+ readonly name: "spender";
94
+ readonly type: "address";
95
+ }];
96
+ readonly outputs: readonly [{
97
+ readonly name: "";
98
+ readonly type: "uint256";
99
+ }];
100
+ }];
101
+ //# sourceMappingURL=erc20.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../src/abi/erc20.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEZ,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * ERC-20 standard ABI for viem contract interactions.
3
+ *
4
+ * Includes: transfer, approve, balanceOf, allowance, decimals, symbol, name, totalSupply.
5
+ * Uses `as const` for viem type inference (abi parameter requires literal types).
6
+ */
7
+ export const ERC20_ABI = [
8
+ {
9
+ type: 'function',
10
+ name: 'name',
11
+ stateMutability: 'view',
12
+ inputs: [],
13
+ outputs: [{ name: '', type: 'string' }],
14
+ },
15
+ {
16
+ type: 'function',
17
+ name: 'symbol',
18
+ stateMutability: 'view',
19
+ inputs: [],
20
+ outputs: [{ name: '', type: 'string' }],
21
+ },
22
+ {
23
+ type: 'function',
24
+ name: 'decimals',
25
+ stateMutability: 'view',
26
+ inputs: [],
27
+ outputs: [{ name: '', type: 'uint8' }],
28
+ },
29
+ {
30
+ type: 'function',
31
+ name: 'totalSupply',
32
+ stateMutability: 'view',
33
+ inputs: [],
34
+ outputs: [{ name: '', type: 'uint256' }],
35
+ },
36
+ {
37
+ type: 'function',
38
+ name: 'balanceOf',
39
+ stateMutability: 'view',
40
+ inputs: [{ name: 'account', type: 'address' }],
41
+ outputs: [{ name: '', type: 'uint256' }],
42
+ },
43
+ {
44
+ type: 'function',
45
+ name: 'transfer',
46
+ stateMutability: 'nonpayable',
47
+ inputs: [
48
+ { name: 'to', type: 'address' },
49
+ { name: 'amount', type: 'uint256' },
50
+ ],
51
+ outputs: [{ name: '', type: 'bool' }],
52
+ },
53
+ {
54
+ type: 'function',
55
+ name: 'approve',
56
+ stateMutability: 'nonpayable',
57
+ inputs: [
58
+ { name: 'spender', type: 'address' },
59
+ { name: 'amount', type: 'uint256' },
60
+ ],
61
+ outputs: [{ name: '', type: 'bool' }],
62
+ },
63
+ {
64
+ type: 'function',
65
+ name: 'allowance',
66
+ stateMutability: 'view',
67
+ inputs: [
68
+ { name: 'owner', type: 'address' },
69
+ { name: 'spender', type: 'address' },
70
+ ],
71
+ outputs: [{ name: '', type: 'uint256' }],
72
+ },
73
+ ];
74
+ //# sourceMappingURL=erc20.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20.js","sourceRoot":"","sources":["../../src/abi/erc20.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KACxC;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ;QACd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,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KACtC;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;SACrC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACzC;CACO,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * EvmAdapter -- IChainAdapter implementation for EVM chains using viem 2.x.
3
+ *
4
+ * Phase 77-01: Scaffolding with 6 real implementations.
5
+ * Phase 77-02: 11 more real implementations (build/simulate/sign/submit/confirm/fee/nonce/assets/tokenInfo/approve/txFee).
6
+ * Phase 78-02: buildTokenTransfer real implementation + getAssets ERC-20 multicall expansion.
7
+ * Phase 79-01: buildContractCall real implementation.
8
+ *
9
+ * Real implementations (21):
10
+ * connect, disconnect, isConnected, getHealth, getBalance, getCurrentNonce,
11
+ * buildTransaction, simulateTransaction, signTransaction, submitTransaction,
12
+ * waitForConfirmation, estimateFee, getTransactionFee, getAssets, getTokenInfo,
13
+ * buildApprove, buildBatch (BATCH_NOT_SUPPORTED), buildTokenTransfer, buildContractCall,
14
+ * parseTransaction, signExternalTransaction
15
+ *
16
+ * Stubs for later phases (1):
17
+ * sweepAll (Phase 80)
18
+ */
19
+ import { type Chain } from 'viem';
20
+ import type { IChainAdapter, ChainType, NetworkType, TransferRequest, UnsignedTransaction, SimulationResult, SubmitResult, BalanceInfo, HealthInfo, AssetInfo, FeeEstimate, TokenInfo, SweepResult, TokenTransferParams, ContractCallParams, ApproveParams, BatchParams, ParsedTransaction, SignedTransaction } from '@waiaas/core';
21
+ /**
22
+ * EVM chain adapter implementing the 20-method IChainAdapter contract.
23
+ *
24
+ * Connection: connect, disconnect, isConnected, getHealth
25
+ * Balance: getBalance
26
+ * Pipeline: buildTransaction, simulateTransaction, signTransaction, submitTransaction
27
+ * Confirmation: waitForConfirmation
28
+ * Assets: getAssets
29
+ * Fee: estimateFee
30
+ * Token: buildTokenTransfer, getTokenInfo
31
+ * Contract: buildContractCall, buildApprove
32
+ * Batch: buildBatch
33
+ * Utility: getTransactionFee, getCurrentNonce, sweepAll
34
+ */
35
+ export declare class EvmAdapter implements IChainAdapter {
36
+ readonly chain: ChainType;
37
+ readonly network: NetworkType;
38
+ private _client;
39
+ private _connected;
40
+ private _chain;
41
+ private _nativeSymbol;
42
+ private _nativeName;
43
+ private _allowedTokens;
44
+ constructor(network: NetworkType, chain?: Chain, nativeSymbol?: string, nativeName?: string);
45
+ /** Set the allowed tokens list for getAssets ERC-20 queries. */
46
+ setAllowedTokens(tokens: Array<{
47
+ address: string;
48
+ symbol?: string;
49
+ name?: string;
50
+ decimals?: number;
51
+ }>): void;
52
+ connect(rpcUrl: string): Promise<void>;
53
+ disconnect(): Promise<void>;
54
+ isConnected(): boolean;
55
+ getHealth(): Promise<HealthInfo>;
56
+ getBalance(addr: string): Promise<BalanceInfo>;
57
+ getAssets(addr: string): Promise<AssetInfo[]>;
58
+ buildTransaction(request: TransferRequest): Promise<UnsignedTransaction>;
59
+ simulateTransaction(tx: UnsignedTransaction): Promise<SimulationResult>;
60
+ signTransaction(tx: UnsignedTransaction, privateKey: Uint8Array): Promise<Uint8Array>;
61
+ submitTransaction(signedTx: Uint8Array): Promise<SubmitResult>;
62
+ waitForConfirmation(txHash: string, timeoutMs?: number): Promise<SubmitResult>;
63
+ estimateFee(request: TransferRequest | TokenTransferParams): Promise<FeeEstimate>;
64
+ buildTokenTransfer(request: TokenTransferParams): Promise<UnsignedTransaction>;
65
+ getTokenInfo(tokenAddress: string): Promise<TokenInfo>;
66
+ buildContractCall(request: ContractCallParams): Promise<UnsignedTransaction>;
67
+ buildApprove(request: ApproveParams): Promise<UnsignedTransaction>;
68
+ buildBatch(_request: BatchParams): Promise<UnsignedTransaction>;
69
+ getTransactionFee(tx: UnsignedTransaction): Promise<bigint>;
70
+ getCurrentNonce(addr: string): Promise<number>;
71
+ sweepAll(_from: string, _to: string, _privateKey: Uint8Array): Promise<SweepResult>;
72
+ parseTransaction(rawTx: string): Promise<ParsedTransaction>;
73
+ signExternalTransaction(rawTx: string, privateKey: Uint8Array): Promise<SignedTransaction>;
74
+ private ensureConnected;
75
+ private getClient;
76
+ /**
77
+ * Map unknown errors to appropriate ChainError or WAIaaSError.
78
+ * Inspects error message for known patterns.
79
+ */
80
+ private mapError;
81
+ }
82
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EASL,KAAK,KAAK,EAGX,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAQtB;;;;;;;;;;;;;GAaG;AACH,qBAAa,UAAW,YAAW,aAAa;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAc;IACvC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAE9B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,aAAa,CAAS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