@chainlink/ccip-sdk 0.94.0 → 0.96.0
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 +2 -2
- package/dist/all-chains.d.ts +23 -0
- package/dist/all-chains.d.ts.map +1 -0
- package/dist/all-chains.js +24 -0
- package/dist/all-chains.js.map +1 -0
- package/dist/api/index.d.ts +86 -7
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +270 -10
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +134 -13
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/index.d.ts +38 -17
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +91 -61
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/logs.js +3 -3
- package/dist/aptos/logs.js.map +1 -1
- package/dist/chain.d.ts +300 -42
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +160 -9
- package/dist/chain.js.map +1 -1
- package/dist/errors/codes.d.ts +9 -3
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +10 -3
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +8 -8
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +8 -8
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +10 -4
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +62 -21
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +128 -41
- package/dist/errors/specialized.js.map +1 -1
- package/dist/evm/extra-args.d.ts +25 -0
- package/dist/evm/extra-args.d.ts.map +1 -0
- package/dist/evm/extra-args.js +328 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts +14 -0
- package/dist/evm/gas.d.ts.map +1 -0
- package/dist/evm/gas.js +92 -0
- package/dist/evm/gas.js.map +1 -0
- package/dist/evm/index.d.ts +76 -32
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +94 -104
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/offchain.d.ts.map +1 -1
- package/dist/evm/offchain.js +8 -8
- package/dist/evm/offchain.js.map +1 -1
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +24 -3
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +103 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +28 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +46 -19
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +56 -68
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +18 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/offchain.d.ts +5 -4
- package/dist/offchain.d.ts.map +1 -1
- package/dist/offchain.js +7 -6
- package/dist/offchain.js.map +1 -1
- package/dist/requests.d.ts +30 -20
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +86 -56
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts +2 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +625 -278
- package/dist/selectors.js.map +1 -1
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js +2 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +73 -22
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +91 -28
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/offchain.js +2 -2
- package/dist/solana/offchain.js.map +1 -1
- package/dist/solana/send.d.ts.map +1 -1
- package/dist/solana/send.js +6 -9
- package/dist/solana/send.js.map +1 -1
- package/dist/solana/utils.d.ts +29 -1
- package/dist/solana/utils.d.ts.map +1 -1
- package/dist/solana/utils.js +39 -1
- package/dist/solana/utils.js.map +1 -1
- package/dist/sui/discovery.d.ts +7 -4
- package/dist/sui/discovery.d.ts.map +1 -1
- package/dist/sui/discovery.js +66 -19
- package/dist/sui/discovery.js.map +1 -1
- package/dist/sui/events.d.ts +23 -12
- package/dist/sui/events.d.ts.map +1 -1
- package/dist/sui/events.js +267 -128
- package/dist/sui/events.js.map +1 -1
- package/dist/sui/index.d.ts +57 -41
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +286 -159
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/objects.d.ts +14 -4
- package/dist/sui/objects.d.ts.map +1 -1
- package/dist/sui/objects.js +61 -68
- package/dist/sui/objects.js.map +1 -1
- package/dist/sui/types.d.ts +33 -0
- package/dist/sui/types.d.ts.map +1 -1
- package/dist/sui/types.js.map +1 -1
- package/dist/ton/index.d.ts +67 -21
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +159 -30
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/send.d.ts +52 -0
- package/dist/ton/send.d.ts.map +1 -0
- package/dist/ton/send.js +166 -0
- package/dist/ton/send.js.map +1 -0
- package/dist/ton/utils.d.ts +3 -3
- package/dist/ton/utils.d.ts.map +1 -1
- package/dist/ton/utils.js +6 -5
- package/dist/ton/utils.js.map +1 -1
- package/dist/types.d.ts +126 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -5
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +67 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +126 -17
- package/dist/utils.js.map +1 -1
- package/package.json +14 -9
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +348 -13
- package/src/api/types.ts +160 -13
- package/src/aptos/index.ts +98 -76
- package/src/aptos/logs.ts +3 -3
- package/src/chain.ts +408 -51
- package/src/errors/codes.ts +10 -3
- package/src/errors/index.ts +8 -5
- package/src/errors/recovery.ts +18 -5
- package/src/errors/specialized.ts +168 -49
- package/src/evm/extra-args.ts +377 -0
- package/src/evm/gas.ts +150 -0
- package/src/evm/index.ts +123 -155
- package/src/evm/offchain.ts +15 -9
- package/src/execution.ts +26 -3
- package/src/extra-args.ts +108 -4
- package/src/gas.ts +101 -115
- package/src/index.ts +27 -14
- package/src/offchain.ts +12 -6
- package/src/requests.ts +117 -67
- package/src/selectors.ts +632 -280
- package/src/solana/exec.ts +3 -1
- package/src/solana/index.ts +97 -37
- package/src/solana/offchain.ts +2 -2
- package/src/solana/send.ts +5 -23
- package/src/solana/utils.ts +66 -0
- package/src/sui/discovery.ts +92 -31
- package/src/sui/events.ts +346 -239
- package/src/sui/index.ts +365 -212
- package/src/sui/objects.ts +74 -98
- package/src/sui/types.ts +35 -0
- package/src/ton/index.ts +199 -35
- package/src/ton/send.ts +222 -0
- package/src/ton/utils.ts +7 -6
- package/src/types.ts +128 -9
- package/src/utils.ts +169 -21
package/dist/api/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { MessageStatus, NetworkInfo } from '../types.ts';
|
|
1
2
|
/**
|
|
2
|
-
* Response from GET /
|
|
3
|
+
* Response from GET /v2/lanes/latency endpoint.
|
|
3
4
|
* Returns only the latency value - caller already knows source/dest chains.
|
|
4
5
|
*/
|
|
5
6
|
export type LaneLatencyResponse = {
|
|
@@ -9,18 +10,8 @@ export type LaneLatencyResponse = {
|
|
|
9
10
|
/** Raw API response (string selectors, before conversion) */
|
|
10
11
|
export type RawLaneLatencyResponse = {
|
|
11
12
|
lane: {
|
|
12
|
-
sourceNetworkInfo:
|
|
13
|
-
|
|
14
|
-
chainSelector: string;
|
|
15
|
-
chainId: string;
|
|
16
|
-
chainFamily: string;
|
|
17
|
-
};
|
|
18
|
-
destNetworkInfo: {
|
|
19
|
-
name: string;
|
|
20
|
-
chainSelector: string;
|
|
21
|
-
chainId: string;
|
|
22
|
-
chainFamily: string;
|
|
23
|
-
};
|
|
13
|
+
sourceNetworkInfo: RawNetworkInfo;
|
|
14
|
+
destNetworkInfo: RawNetworkInfo;
|
|
24
15
|
routerAddress: string;
|
|
25
16
|
};
|
|
26
17
|
totalMs: number;
|
|
@@ -35,4 +26,134 @@ export type APIErrorResponse = {
|
|
|
35
26
|
/** Human-readable error message with details */
|
|
36
27
|
message: string;
|
|
37
28
|
};
|
|
29
|
+
/** Network info from API response */
|
|
30
|
+
export type RawNetworkInfo = {
|
|
31
|
+
name: string;
|
|
32
|
+
chainSelector: string;
|
|
33
|
+
chainId: string;
|
|
34
|
+
chainFamily: string;
|
|
35
|
+
};
|
|
36
|
+
/** Token amount from API response */
|
|
37
|
+
export type RawTokenAmount = {
|
|
38
|
+
sourceTokenAddress: string;
|
|
39
|
+
destTokenAddress: string;
|
|
40
|
+
sourcePoolAddress: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
extraData?: string | null;
|
|
43
|
+
destGasAmount?: string | null;
|
|
44
|
+
};
|
|
45
|
+
/** EVM extra args from API (GenericExtraArgsV2) */
|
|
46
|
+
export type RawEVMExtraArgs = {
|
|
47
|
+
gasLimit: string;
|
|
48
|
+
allowOutOfOrderExecution: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** SVM extra args from API (SVMExtraArgsV1) */
|
|
51
|
+
export type RawSVMExtraArgs = {
|
|
52
|
+
computeUnits: bigint;
|
|
53
|
+
accountIsWritableBitmap: string;
|
|
54
|
+
allowOutOfOrderExecution: boolean;
|
|
55
|
+
tokenReceiver: string;
|
|
56
|
+
accounts: string[];
|
|
57
|
+
};
|
|
58
|
+
/** Fixed fee detail from API */
|
|
59
|
+
export type RawFixedFee = {
|
|
60
|
+
contractAddress: string;
|
|
61
|
+
feeType: string;
|
|
62
|
+
amount: string;
|
|
63
|
+
};
|
|
64
|
+
/** Fixed fees details wrapper from API response */
|
|
65
|
+
export type RawFixedFeesDetails = {
|
|
66
|
+
tokenAddress: string;
|
|
67
|
+
totalAmount: string;
|
|
68
|
+
items?: RawFixedFee[];
|
|
69
|
+
};
|
|
70
|
+
/** Fees from API response */
|
|
71
|
+
export type RawFees = {
|
|
72
|
+
fixedFeesDetails: RawFixedFeesDetails;
|
|
73
|
+
};
|
|
74
|
+
/** Raw API response from GET /v2/messages/:messageId */
|
|
75
|
+
export type RawMessageResponse = {
|
|
76
|
+
messageId: string;
|
|
77
|
+
sender: string;
|
|
78
|
+
receiver: string;
|
|
79
|
+
status: string;
|
|
80
|
+
sourceNetworkInfo: RawNetworkInfo;
|
|
81
|
+
destNetworkInfo: RawNetworkInfo;
|
|
82
|
+
sendTransactionHash: string;
|
|
83
|
+
sendTimestamp: string;
|
|
84
|
+
tokenAmounts: RawTokenAmount[];
|
|
85
|
+
extraArgs: RawEVMExtraArgs | RawSVMExtraArgs;
|
|
86
|
+
readyForManualExecution: boolean;
|
|
87
|
+
finality: bigint;
|
|
88
|
+
fees: RawFees;
|
|
89
|
+
origin: string;
|
|
90
|
+
sequenceNumber: string;
|
|
91
|
+
onramp: string;
|
|
92
|
+
sendBlockNumber: bigint;
|
|
93
|
+
sendLogIndex: bigint;
|
|
94
|
+
nonce?: string | null;
|
|
95
|
+
routerAddress?: string | null;
|
|
96
|
+
version?: string | null;
|
|
97
|
+
receiptTransactionHash?: string;
|
|
98
|
+
receiptTimestamp?: string;
|
|
99
|
+
deliveryTime?: bigint;
|
|
100
|
+
data?: string | null;
|
|
101
|
+
};
|
|
102
|
+
/** Message search result from /v2/messages search endpoint */
|
|
103
|
+
export type RawMessageSearchResult = {
|
|
104
|
+
messageId: string;
|
|
105
|
+
origin: string;
|
|
106
|
+
sender: string;
|
|
107
|
+
receiver: string;
|
|
108
|
+
status: string;
|
|
109
|
+
sourceNetworkInfo: RawNetworkInfo;
|
|
110
|
+
destNetworkInfo: RawNetworkInfo;
|
|
111
|
+
sendTransactionHash: string;
|
|
112
|
+
sendTimestamp: string;
|
|
113
|
+
};
|
|
114
|
+
/** Paginated response from /v2/messages search endpoint */
|
|
115
|
+
export type RawMessagesResponse = {
|
|
116
|
+
data: RawMessageSearchResult[];
|
|
117
|
+
pagination: {
|
|
118
|
+
limit: number;
|
|
119
|
+
hasNextPage: boolean;
|
|
120
|
+
cursor?: string | null;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* API-specific metadata fields for CCIP requests.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* These fields are only available when fetching via the CCIP API.
|
|
128
|
+
* This type is the value of the `metadata` field on {@link CCIPRequest}.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const request = await chain.getMessageById(messageId)
|
|
133
|
+
* if (request.metadata) {
|
|
134
|
+
* console.log(`Status: ${request.metadata.status}`)
|
|
135
|
+
* if (request.metadata.receiptTransactionHash) {
|
|
136
|
+
* console.log(`Executed in tx: ${request.metadata.receiptTransactionHash}`)
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export type APICCIPRequestMetadata = {
|
|
142
|
+
/** Message lifecycle status from API. */
|
|
143
|
+
status: MessageStatus;
|
|
144
|
+
/** Whether message is ready for manual execution. */
|
|
145
|
+
readyForManualExecution: boolean;
|
|
146
|
+
/** Number of block confirmations on source chain. */
|
|
147
|
+
finality: bigint;
|
|
148
|
+
/** Transaction hash of execution receipt (if executed). */
|
|
149
|
+
receiptTransactionHash?: string;
|
|
150
|
+
/** Unix timestamp of execution receipt (if executed). */
|
|
151
|
+
receiptTimestamp?: number;
|
|
152
|
+
/** End-to-end delivery time in milliseconds (if completed). */
|
|
153
|
+
deliveryTime?: bigint;
|
|
154
|
+
/** Source network metadata. */
|
|
155
|
+
sourceNetworkInfo: NetworkInfo;
|
|
156
|
+
/** Destination network metadata. */
|
|
157
|
+
destNetworkInfo: NetworkInfo;
|
|
158
|
+
};
|
|
38
159
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM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AAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,+BAA+B;IAC/B,iBAAiB,EAAE,WAAW,CAAA;IAC9B,oCAAoC;IACpC,eAAe,EAAE,WAAW,CAAA;CAC7B,CAAA"}
|
package/dist/aptos/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk';
|
|
2
2
|
import { type BytesLike } from 'ethers';
|
|
3
3
|
import type { PickDeep } from 'type-fest';
|
|
4
|
-
import { type ChainContext, type LogFilter, type TokenInfo, type TokenPoolRemote, Chain } from '../chain.ts';
|
|
4
|
+
import { type ChainContext, type GetBalanceOpts, type LogFilter, type TokenInfo, type TokenPoolRemote, Chain } from '../chain.ts';
|
|
5
5
|
import { type EVMExtraArgsV2, type ExtraArgs, type SVMExtraArgsV1 } from '../extra-args.ts';
|
|
6
6
|
import { type UnsignedAptosTx } from './types.ts';
|
|
7
7
|
import type { LeafHasher } from '../hasher/common.ts';
|
|
@@ -11,7 +11,7 @@ export type { UnsignedAptosTx };
|
|
|
11
11
|
* Aptos chain implementation supporting Aptos networks.
|
|
12
12
|
*/
|
|
13
13
|
export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
14
|
-
static readonly family: "
|
|
14
|
+
static readonly family: "APTOS";
|
|
15
15
|
static readonly decimals = 8;
|
|
16
16
|
readonly destroy$: Promise<void>;
|
|
17
17
|
provider: Aptos;
|
|
@@ -42,22 +42,21 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
42
42
|
* @param url - RPC URL, Aptos Network enum value or [fullNodeUrl, Network] tuple.
|
|
43
43
|
* @param ctx - context containing logger
|
|
44
44
|
* @returns A new AptosChain instance.
|
|
45
|
+
* @throws {@link CCIPAptosNetworkUnknownError} if network cannot be determined from URL
|
|
45
46
|
*/
|
|
46
47
|
static fromUrl(url: string | Network | readonly [string, Network], ctx?: ChainContext): Promise<AptosChain>;
|
|
47
48
|
/** {@inheritDoc Chain.getBlockTimestamp} */
|
|
48
49
|
getBlockTimestamp(version: number | 'finalized'): Promise<number>;
|
|
49
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritDoc Chain.getTransaction}
|
|
52
|
+
* @throws {@link CCIPAptosTransactionInvalidError} if hash/version format is invalid
|
|
53
|
+
* @throws {@link CCIPAptosTransactionTypeInvalidError} if transaction is not a user transaction
|
|
54
|
+
*/
|
|
50
55
|
getTransaction(hashOrVersion: string | number): Promise<ChainTransaction>;
|
|
51
56
|
/** {@inheritDoc Chain.getLogs} */
|
|
52
57
|
getLogs(opts: LogFilter & {
|
|
53
58
|
versionAsHash?: boolean;
|
|
54
59
|
}): AsyncIterableIterator<Log_>;
|
|
55
|
-
/** {@inheritDoc Chain.getMessagesInTx} */
|
|
56
|
-
getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
|
|
57
|
-
/** {@inheritDoc Chain.getMessageById} */
|
|
58
|
-
getMessageById(messageId: string, onRamp?: string, opts?: {
|
|
59
|
-
page?: number;
|
|
60
|
-
}): Promise<CCIPRequest>;
|
|
61
60
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
62
61
|
getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
|
|
63
62
|
page?: number;
|
|
@@ -80,12 +79,18 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
80
79
|
getCommitStoreForOffRamp(offRamp: string): Promise<string>;
|
|
81
80
|
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
82
81
|
getTokenForTokenPool(tokenPool: string): Promise<string>;
|
|
83
|
-
/** {@inheritDoc Chain.
|
|
82
|
+
/** {@inheritDoc Chain.getBalance} */
|
|
83
|
+
getBalance(opts: GetBalanceOpts): Promise<bigint>;
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
86
|
+
* @throws {@link CCIPAptosRegistryTypeInvalidError} if registry type is invalid
|
|
87
|
+
*/
|
|
84
88
|
getTokenAdminRegistryFor(address: string): Promise<string>;
|
|
85
89
|
/**
|
|
86
90
|
* Decodes a CCIP message from an Aptos log event.
|
|
87
91
|
* @param log - Log with data field.
|
|
88
92
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
93
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
89
94
|
*/
|
|
90
95
|
static decodeMessage(log: {
|
|
91
96
|
data: BytesLike | Record<string, unknown>;
|
|
@@ -104,6 +109,7 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
104
109
|
* Encodes extra arguments for Aptos CCIP messages.
|
|
105
110
|
* @param extraArgs - Extra arguments to encode.
|
|
106
111
|
* @returns Encoded extra arguments as hex string.
|
|
112
|
+
* @throws {@link CCIPAptosExtraArgsEncodingError} if extra args format is not supported
|
|
107
113
|
*/
|
|
108
114
|
static encodeExtraArgs(extraArgs: ExtraArgs): string;
|
|
109
115
|
/**
|
|
@@ -111,20 +117,23 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
111
117
|
* @param log - Log with data field.
|
|
112
118
|
* @param lane - Lane info for filtering.
|
|
113
119
|
* @returns Array of CommitReport or undefined if not valid.
|
|
120
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
114
121
|
*/
|
|
115
122
|
static decodeCommits({ data }: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined;
|
|
116
123
|
/**
|
|
117
124
|
* Decodes an execution receipt from an Aptos log event.
|
|
118
125
|
* @param log - Log with data field.
|
|
119
126
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
127
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
120
128
|
*/
|
|
121
129
|
static decodeReceipt({ data }: Pick<Log_, 'data'>): ExecutionReceipt | undefined;
|
|
122
130
|
/**
|
|
123
131
|
* Converts bytes to an Aptos address.
|
|
124
132
|
* @param bytes - Bytes to convert.
|
|
125
133
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
134
|
+
* @throws {@link CCIPAptosAddressInvalidError} if bytes length exceeds 32
|
|
126
135
|
*/
|
|
127
|
-
static getAddress(bytes: BytesLike): string;
|
|
136
|
+
static getAddress(bytes: BytesLike | readonly number[]): string;
|
|
128
137
|
/**
|
|
129
138
|
* Validates a transaction hash format for Aptos
|
|
130
139
|
*/
|
|
@@ -139,13 +148,22 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
139
148
|
getFee({ router, destChainSelector, message, }: Parameters<Chain['getFee']>[0]): Promise<bigint>;
|
|
140
149
|
/** {@inheritDoc Chain.generateUnsignedSendMessage} */
|
|
141
150
|
generateUnsignedSendMessage(opts: Parameters<Chain['generateUnsignedSendMessage']>[0]): Promise<UnsignedAptosTx>;
|
|
142
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* {@inheritDoc Chain.sendMessage}
|
|
153
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
154
|
+
*/
|
|
143
155
|
sendMessage(opts: Parameters<Chain['sendMessage']>[0]): Promise<CCIPRequest>;
|
|
144
156
|
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
145
157
|
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
|
|
146
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* {@inheritDoc Chain.generateUnsignedExecuteReport}
|
|
160
|
+
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
161
|
+
*/
|
|
147
162
|
generateUnsignedExecuteReport({ payer, offRamp, execReport, ...opts }: Parameters<Chain['generateUnsignedExecuteReport']>[0]): Promise<UnsignedAptosTx>;
|
|
148
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* {@inheritDoc Chain.executeReport}
|
|
165
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
166
|
+
*/
|
|
149
167
|
executeReport(opts: Parameters<Chain['executeReport']>[0]): Promise<CCIPExecution>;
|
|
150
168
|
/**
|
|
151
169
|
* Parses raw Aptos data into typed structures.
|
|
@@ -163,14 +181,17 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
163
181
|
getSupportedTokens(address: string, opts?: {
|
|
164
182
|
page?: number;
|
|
165
183
|
}): Promise<string[]>;
|
|
166
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
186
|
+
* @throws {@link CCIPAptosTokenNotRegisteredError} if token is not registered
|
|
187
|
+
*/
|
|
167
188
|
getRegistryTokenConfig(registry: string, token: string): Promise<{
|
|
168
189
|
administrator: string;
|
|
169
190
|
pendingAdministrator?: string;
|
|
170
191
|
tokenPool?: string;
|
|
171
192
|
}>;
|
|
172
|
-
/** {@inheritDoc Chain.
|
|
173
|
-
|
|
193
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
194
|
+
getTokenPoolConfig(tokenPool: string): Promise<{
|
|
174
195
|
token: string;
|
|
175
196
|
router: string;
|
|
176
197
|
typeAndVersion?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,WAAW,EAEX,OAAO,EAGR,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,KAAK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CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAavE"}
|
package/dist/aptos/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Aptos, AptosConfig, Deserializer, Network, SimpleTransaction, TransactionResponseType, } from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { concat,
|
|
1
|
+
import { Aptos, AptosApiError, AptosConfig, Deserializer, Network, SimpleTransaction, TransactionResponseType, } from '@aptos-labs/ts-sdk';
|
|
2
|
+
import { concat, dataSlice, getBytes, hexlify, isBytesLike, isHexString, zeroPadValue, } from 'ethers';
|
|
3
3
|
import { memoize } from 'micro-memoize';
|
|
4
4
|
import { Chain, } from "../chain.js";
|
|
5
5
|
import { generateUnsignedCcipSend, getFee } from "./send.js";
|
|
6
|
-
import { CCIPAptosAddressInvalidError, CCIPAptosExtraArgsEncodingError, CCIPAptosExtraArgsV2RequiredError, CCIPAptosLogInvalidError, CCIPAptosNetworkUnknownError, CCIPAptosRegistryTypeInvalidError, CCIPAptosTokenNotRegisteredError, CCIPAptosTransactionInvalidError, CCIPAptosTransactionTypeInvalidError, CCIPAptosWalletInvalidError, CCIPError,
|
|
6
|
+
import { CCIPAptosAddressInvalidError, CCIPAptosExtraArgsEncodingError, CCIPAptosExtraArgsV2RequiredError, CCIPAptosLogInvalidError, CCIPAptosNetworkUnknownError, CCIPAptosRegistryTypeInvalidError, CCIPAptosTokenNotRegisteredError, CCIPAptosTransactionInvalidError, CCIPAptosTransactionTypeInvalidError, CCIPAptosWalletInvalidError, CCIPError, CCIPTokenPoolChainConfigNotFoundError, } from "../errors/index.js";
|
|
7
7
|
import { EVMExtraArgsV2Tag, SVMExtraArgsV1Tag, } from "../extra-args.js";
|
|
8
8
|
import { EVMExtraArgsV2Codec, SVMExtraArgsV1Codec, isAptosAccount, } from "./types.js";
|
|
9
9
|
import { supportedChains } from "../supported-chains.js";
|
|
@@ -13,7 +13,7 @@ import { generateUnsignedExecuteReport } from "./exec.js";
|
|
|
13
13
|
import { getAptosLeafHasher } from "./hasher.js";
|
|
14
14
|
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from "./logs.js";
|
|
15
15
|
import { getTokenInfo } from "./token.js";
|
|
16
|
-
import { buildMessageForDest, decodeMessage,
|
|
16
|
+
import { buildMessageForDest, decodeMessage, getMessagesInBatch } from "../requests.js";
|
|
17
17
|
/**
|
|
18
18
|
* Aptos chain implementation supporting Aptos networks.
|
|
19
19
|
*/
|
|
@@ -86,6 +86,7 @@ export class AptosChain extends Chain {
|
|
|
86
86
|
* @param url - RPC URL, Aptos Network enum value or [fullNodeUrl, Network] tuple.
|
|
87
87
|
* @param ctx - context containing logger
|
|
88
88
|
* @returns A new AptosChain instance.
|
|
89
|
+
* @throws {@link CCIPAptosNetworkUnknownError} if network cannot be determined from URL
|
|
89
90
|
*/
|
|
90
91
|
static async fromUrl(url, ctx) {
|
|
91
92
|
let network;
|
|
@@ -114,7 +115,11 @@ export class AptosChain extends Chain {
|
|
|
114
115
|
async getBlockTimestamp(version) {
|
|
115
116
|
return getVersionTimestamp(this.provider, version);
|
|
116
117
|
}
|
|
117
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* {@inheritDoc Chain.getTransaction}
|
|
120
|
+
* @throws {@link CCIPAptosTransactionInvalidError} if hash/version format is invalid
|
|
121
|
+
* @throws {@link CCIPAptosTransactionTypeInvalidError} if transaction is not a user transaction
|
|
122
|
+
*/
|
|
118
123
|
async getTransaction(hashOrVersion) {
|
|
119
124
|
let tx;
|
|
120
125
|
if (isHexString(hashOrVersion, 32)) {
|
|
@@ -149,19 +154,6 @@ export class AptosChain extends Chain {
|
|
|
149
154
|
async *getLogs(opts) {
|
|
150
155
|
yield* streamAptosLogs(this, opts);
|
|
151
156
|
}
|
|
152
|
-
/** {@inheritDoc Chain.getMessagesInTx} */
|
|
153
|
-
async getMessagesInTx(tx) {
|
|
154
|
-
return getMessagesInTx(this, typeof tx === 'string' ? await this.getTransaction(tx) : tx);
|
|
155
|
-
}
|
|
156
|
-
/** {@inheritDoc Chain.getMessageById} */
|
|
157
|
-
async getMessageById(messageId, onRamp, opts) {
|
|
158
|
-
if (!onRamp)
|
|
159
|
-
throw new CCIPOnRampRequiredError();
|
|
160
|
-
return getMessageById(this, messageId, {
|
|
161
|
-
address: await this.getOnRampForRouter(onRamp, 0n),
|
|
162
|
-
...opts,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
157
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
166
158
|
async getMessagesInBatch(request, commit, opts) {
|
|
167
159
|
return getMessagesInBatch(this, request, commit, opts);
|
|
@@ -232,7 +224,20 @@ export class AptosChain extends Chain {
|
|
|
232
224
|
}
|
|
233
225
|
throw CCIPError.from(firstErr ?? `Could not view 'get_token' in ${tokenPool}`, 'UNKNOWN');
|
|
234
226
|
}
|
|
235
|
-
/** {@inheritDoc Chain.
|
|
227
|
+
/** {@inheritDoc Chain.getBalance} */
|
|
228
|
+
async getBalance(opts) {
|
|
229
|
+
const { holder, token } = opts;
|
|
230
|
+
const asset = token ?? '0x1::aptos_coin::AptosCoin';
|
|
231
|
+
const balance = await this.provider.getBalance({
|
|
232
|
+
accountAddress: holder,
|
|
233
|
+
asset,
|
|
234
|
+
});
|
|
235
|
+
return BigInt(balance);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
239
|
+
* @throws {@link CCIPAptosRegistryTypeInvalidError} if registry type is invalid
|
|
240
|
+
*/
|
|
236
241
|
async getTokenAdminRegistryFor(address) {
|
|
237
242
|
const registry = address.split('::')[0] + '::token_admin_registry';
|
|
238
243
|
const [type] = await this.typeAndVersion(registry);
|
|
@@ -245,6 +250,7 @@ export class AptosChain extends Chain {
|
|
|
245
250
|
* Decodes a CCIP message from an Aptos log event.
|
|
246
251
|
* @param log - Log with data field.
|
|
247
252
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
253
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
248
254
|
*/
|
|
249
255
|
static decodeMessage(log) {
|
|
250
256
|
const { data } = log;
|
|
@@ -294,6 +300,7 @@ export class AptosChain extends Chain {
|
|
|
294
300
|
* Encodes extra arguments for Aptos CCIP messages.
|
|
295
301
|
* @param extraArgs - Extra arguments to encode.
|
|
296
302
|
* @returns Encoded extra arguments as hex string.
|
|
303
|
+
* @throws {@link CCIPAptosExtraArgsEncodingError} if extra args format is not supported
|
|
297
304
|
*/
|
|
298
305
|
static encodeExtraArgs(extraArgs) {
|
|
299
306
|
if ('gasLimit' in extraArgs && 'allowOutOfOrderExecution' in extraArgs)
|
|
@@ -315,6 +322,7 @@ export class AptosChain extends Chain {
|
|
|
315
322
|
* @param log - Log with data field.
|
|
316
323
|
* @param lane - Lane info for filtering.
|
|
317
324
|
* @returns Array of CommitReport or undefined if not valid.
|
|
325
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
318
326
|
*/
|
|
319
327
|
static decodeCommits({ data }, lane) {
|
|
320
328
|
if (!data || typeof data != 'object')
|
|
@@ -335,6 +343,7 @@ export class AptosChain extends Chain {
|
|
|
335
343
|
* Decodes an execution receipt from an Aptos log event.
|
|
336
344
|
* @param log - Log with data field.
|
|
337
345
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
346
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
338
347
|
*/
|
|
339
348
|
static decodeReceipt({ data }) {
|
|
340
349
|
if (!data || typeof data != 'object')
|
|
@@ -348,20 +357,21 @@ export class AptosChain extends Chain {
|
|
|
348
357
|
* Converts bytes to an Aptos address.
|
|
349
358
|
* @param bytes - Bytes to convert.
|
|
350
359
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
360
|
+
* @throws {@link CCIPAptosAddressInvalidError} if bytes length exceeds 32
|
|
351
361
|
*/
|
|
352
362
|
static getAddress(bytes) {
|
|
353
363
|
let suffix = '';
|
|
354
|
-
if (
|
|
355
|
-
bytes =
|
|
356
|
-
|
|
357
|
-
else if (typeof bytes === 'string') {
|
|
364
|
+
if (Array.isArray(bytes))
|
|
365
|
+
bytes = new Uint8Array(bytes);
|
|
366
|
+
if (typeof bytes === 'string' && bytes.startsWith('0x')) {
|
|
358
367
|
const idx = bytes.indexOf('::');
|
|
359
368
|
if (idx > 0) {
|
|
360
369
|
suffix = bytes.slice(idx);
|
|
361
370
|
bytes = bytes.slice(0, idx);
|
|
362
371
|
}
|
|
363
372
|
}
|
|
364
|
-
|
|
373
|
+
bytes = getDataBytes(bytes);
|
|
374
|
+
if (bytes.length > 32)
|
|
365
375
|
throw new CCIPAptosAddressInvalidError(hexlify(bytes));
|
|
366
376
|
return zeroPadValue(bytes, 32) + suffix;
|
|
367
377
|
}
|
|
@@ -398,7 +408,10 @@ export class AptosChain extends Chain {
|
|
|
398
408
|
transactions: [tx],
|
|
399
409
|
};
|
|
400
410
|
}
|
|
401
|
-
/**
|
|
411
|
+
/**
|
|
412
|
+
* {@inheritDoc Chain.sendMessage}
|
|
413
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
414
|
+
*/
|
|
402
415
|
async sendMessage(opts) {
|
|
403
416
|
const account = opts.wallet;
|
|
404
417
|
if (!isAptosAccount(account)) {
|
|
@@ -427,7 +440,10 @@ export class AptosChain extends Chain {
|
|
|
427
440
|
// default offchain token data
|
|
428
441
|
return Promise.resolve(request.message.tokenAmounts.map(() => undefined));
|
|
429
442
|
}
|
|
430
|
-
/**
|
|
443
|
+
/**
|
|
444
|
+
* {@inheritDoc Chain.generateUnsignedExecuteReport}
|
|
445
|
+
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
446
|
+
*/
|
|
431
447
|
async generateUnsignedExecuteReport({ payer, offRamp, execReport, ...opts }) {
|
|
432
448
|
if (!('allowOutOfOrderExecution' in execReport.message && 'gasLimit' in execReport.message)) {
|
|
433
449
|
throw new CCIPAptosExtraArgsV2RequiredError();
|
|
@@ -438,7 +454,10 @@ export class AptosChain extends Chain {
|
|
|
438
454
|
transactions: [tx],
|
|
439
455
|
};
|
|
440
456
|
}
|
|
441
|
-
/**
|
|
457
|
+
/**
|
|
458
|
+
* {@inheritDoc Chain.executeReport}
|
|
459
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
460
|
+
*/
|
|
442
461
|
async executeReport(opts) {
|
|
443
462
|
const account = opts.wallet;
|
|
444
463
|
if (!isAptosAccount(account)) {
|
|
@@ -490,7 +509,10 @@ export class AptosChain extends Chain {
|
|
|
490
509
|
} while (hasMore);
|
|
491
510
|
return page;
|
|
492
511
|
}
|
|
493
|
-
/**
|
|
512
|
+
/**
|
|
513
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
514
|
+
* @throws {@link CCIPAptosTokenNotRegisteredError} if token is not registered
|
|
515
|
+
*/
|
|
494
516
|
async getRegistryTokenConfig(registry, token) {
|
|
495
517
|
const [tokenPool, administrator, pendingAdministrator] = await this.provider.view({
|
|
496
518
|
payload: {
|
|
@@ -506,8 +528,8 @@ export class AptosChain extends Chain {
|
|
|
506
528
|
...(!tokenPool.match(/^0x0*$/) && { tokenPool }),
|
|
507
529
|
};
|
|
508
530
|
}
|
|
509
|
-
/** {@inheritDoc Chain.
|
|
510
|
-
async
|
|
531
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
532
|
+
async getTokenPoolConfig(tokenPool) {
|
|
511
533
|
const modulesNames = (await this._getAccountModulesNames(tokenPool))
|
|
512
534
|
.reverse()
|
|
513
535
|
.filter((name) => name.endsWith('token_pool'));
|
|
@@ -544,8 +566,8 @@ export class AptosChain extends Chain {
|
|
|
544
566
|
/** {@inheritDoc Chain.getTokenPoolRemotes} */
|
|
545
567
|
async getTokenPoolRemotes(tokenPool, remoteChainSelector) {
|
|
546
568
|
const modulesNames = (await this._getAccountModulesNames(tokenPool))
|
|
547
|
-
.
|
|
548
|
-
.
|
|
569
|
+
.filter((name) => name.endsWith('token_pool'))
|
|
570
|
+
.sort((a, b) => b.length - a.length);
|
|
549
571
|
let firstErr;
|
|
550
572
|
for (const name of modulesNames) {
|
|
551
573
|
try {
|
|
@@ -582,35 +604,43 @@ export class AptosChain extends Chain {
|
|
|
582
604
|
functionArguments: [chain.chainSelector],
|
|
583
605
|
},
|
|
584
606
|
});
|
|
585
|
-
|
|
586
|
-
remoteToken
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
607
|
+
try {
|
|
608
|
+
const [[remoteToken], [remotePools], [inboundRateLimiterState], [outboundRateLimiterState],] = await Promise.all([
|
|
609
|
+
remoteToken$,
|
|
610
|
+
remotePools$,
|
|
611
|
+
inboundRateLimiterState$,
|
|
612
|
+
outboundRateLimiterState$,
|
|
613
|
+
]);
|
|
614
|
+
return [
|
|
615
|
+
chain.name,
|
|
616
|
+
{
|
|
617
|
+
remoteToken: decodeAddress(remoteToken, chain.family),
|
|
618
|
+
remotePools: remotePools.map((pool) => decodeAddress(pool, chain.family)),
|
|
619
|
+
inboundRateLimiterState: inboundRateLimiterState.is_enabled
|
|
620
|
+
? {
|
|
621
|
+
capacity: BigInt(inboundRateLimiterState.capacity),
|
|
622
|
+
lastUpdated: Number(inboundRateLimiterState.last_updated),
|
|
623
|
+
rate: BigInt(inboundRateLimiterState.rate),
|
|
624
|
+
tokens: BigInt(inboundRateLimiterState.tokens),
|
|
625
|
+
}
|
|
626
|
+
: null,
|
|
627
|
+
outboundRateLimiterState: outboundRateLimiterState.is_enabled
|
|
628
|
+
? {
|
|
629
|
+
capacity: BigInt(outboundRateLimiterState.capacity),
|
|
630
|
+
lastUpdated: Number(outboundRateLimiterState.last_updated),
|
|
631
|
+
rate: BigInt(outboundRateLimiterState.rate),
|
|
632
|
+
tokens: BigInt(outboundRateLimiterState.tokens),
|
|
633
|
+
}
|
|
634
|
+
: null,
|
|
635
|
+
},
|
|
636
|
+
];
|
|
637
|
+
}
|
|
638
|
+
catch (err) {
|
|
639
|
+
if (err instanceof AptosApiError &&
|
|
640
|
+
err.message.includes('Key not found in the smart table'))
|
|
641
|
+
throw new CCIPTokenPoolChainConfigNotFoundError(tokenPool, tokenPool, chain.name);
|
|
642
|
+
throw err;
|
|
643
|
+
}
|
|
614
644
|
})));
|
|
615
645
|
}
|
|
616
646
|
catch (err) {
|