@across-protocol/sdk 4.3.75 → 4.3.76
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/cjs/utils/CCTPUtils.d.ts +74 -0
- package/dist/cjs/utils/CCTPUtils.js +199 -0
- package/dist/cjs/utils/CCTPUtils.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +2 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.js +2 -2
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/pool/uma/utils.js +1 -1
- package/dist/esm/pool/uma/utils.js.map +1 -1
- package/dist/esm/providers/types.js +1 -1
- package/dist/esm/providers/types.js.map +1 -1
- package/dist/esm/utils/CCTPUtils.d.ts +169 -0
- package/dist/esm/utils/CCTPUtils.js +270 -0
- package/dist/esm/utils/CCTPUtils.js.map +1 -0
- package/dist/esm/utils/DepositUtils.js +1 -1
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/utils/CCTPUtils.d.ts +170 -0
- package/dist/types/utils/CCTPUtils.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
- package/src/clients/HubPoolClient.ts +2 -2
- package/src/clients/SpokePoolClient/index.ts +2 -2
- package/src/pool/uma/clients/erc20/README.md +1 -1
- package/src/pool/uma/utils.ts +1 -1
- package/src/providers/cachedProvider.ts +1 -1
- package/src/providers/types.ts +1 -1
- package/src/utils/CCTPUtils.ts +329 -0
- package/src/utils/DepositUtils.ts +1 -1
- package/src/utils/index.ts +1 -0
|
@@ -40,7 +40,7 @@ export function Balances(balances) {
|
|
|
40
40
|
return { create: create, add: add, sub: sub, get: get, balances: balances, set: set, has: has, getOrCreate: getOrCreate };
|
|
41
41
|
}
|
|
42
42
|
// Loop forever but wait until execution is finished before starting next timer. Throw an error to break this
|
|
43
|
-
// or add another
|
|
43
|
+
// or add another utility function if you need it to end on condition.
|
|
44
44
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
45
|
export function loop(fn, delay) {
|
|
46
46
|
var args = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/pool/uma/utils.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAgB,KAAK,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,kFAAkF;AAClF,sGAAsG;AACtG,2DAA2D;AAC3D,MAAM,UAAU,MAAM,CAAI,KAA2B;IACnD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAID,MAAM,UAAU,QAAQ,CAAC,QAAuB;IAAvB,yBAAA,EAAA,aAAuB;IAC9C,SAAS,MAAM,CAAC,EAAU,EAAE,MAAY;QAAZ,uBAAA,EAAA,YAAY;QACtC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC3C,OAAO,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,SAAS,GAAG,CAAC,EAAU;QACrB,OAAO,MAAM,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,CAAC,EAAU;QACrB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,SAAS,WAAW,CAAC,EAAU;QAC7B,IAAI,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,MAAM,QAAA,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,QAAQ,UAAA,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,WAAW,aAAA,EAAE,CAAC;AACpE,CAAC;AAED,6GAA6G;AAC7G,sEAAsE;AACtE,8DAA8D;AAC9D,MAAM,UAAgB,IAAI,CAAC,EAA2B,EAAE,KAAa;IAAE,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,6BAAc;;;;;wBAEjF,qBAAM,EAAE,eAAI,IAAI,GAAC;;oBAAjB,SAAiB,CAAC;oBAClB,qBAAM,KAAK,CAAC,KAAK,CAAC,EAAA;;oBAAlB,SAAkB,CAAC;;;wBAEZ,IAAI;;;;;;CACd"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { any, literal, nullable, number, string, type, union } from "superstruct";
|
|
2
2
|
// JSON-RPC 2.0 Error object
|
|
3
|
-
// See JSON-RPC 2.0 Specification section 5
|
|
3
|
+
// See JSON-RPC 2.0 Specification section 5 Response object
|
|
4
4
|
// https://www.jsonrpc.org/specification
|
|
5
5
|
export var JsonRpcError = type({
|
|
6
6
|
jsonrpc: literal("2.0"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKlF,4BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKlF,4BAA4B;AAC5B,2DAA2D;AAC3D,wCAAwC;AACxC,MAAM,CAAC,IAAM,YAAY,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;IACvB,EAAE,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,KAAK,EAAE,IAAI,CAAC;QACV,IAAI,EAAE,MAAM,EAAE;QACd,OAAO,EAAE,MAAM,EAAE;QACjB,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;KACtB,CAAC;CACH,CAAC,CAAC;AAEH,wDAAwD;AACxD,MAAM,CAAC,IAAM,QAAQ,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE;IAChB,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { BigNumber, ethers } from "ethers";
|
|
2
|
+
import { Log } from "@ethersproject/abstract-provider";
|
|
3
|
+
/** ********************************************************************************************************************
|
|
4
|
+
*
|
|
5
|
+
* CONSTANTS
|
|
6
|
+
*
|
|
7
|
+
******************************************************************************************************************* **/
|
|
8
|
+
export type CCTPMessageStatus = "finalized" | "ready" | "pending";
|
|
9
|
+
export declare const CCTPV2_FINALITY_THRESHOLD_STANDARD = 2000;
|
|
10
|
+
export declare const CCTPV2_FINALITY_THRESHOLD_FAST = 1000;
|
|
11
|
+
/** ********************************************************************************************************************
|
|
12
|
+
*
|
|
13
|
+
* CCTP SMART CONTRACT EVENT TYPES
|
|
14
|
+
*
|
|
15
|
+
******************************************************************************************************************* **/
|
|
16
|
+
type CommonMessageData = {
|
|
17
|
+
cctpVersion: number;
|
|
18
|
+
sourceDomain: number;
|
|
19
|
+
destinationDomain: number;
|
|
20
|
+
sender: string;
|
|
21
|
+
recipient: string;
|
|
22
|
+
messageHash: string;
|
|
23
|
+
messageBytes: string;
|
|
24
|
+
nonce: number;
|
|
25
|
+
nonceHash: string;
|
|
26
|
+
};
|
|
27
|
+
type DepositForBurnMessageData = CommonMessageData & {
|
|
28
|
+
amount: string;
|
|
29
|
+
mintRecipient: string;
|
|
30
|
+
burnToken: string;
|
|
31
|
+
};
|
|
32
|
+
type CommonMessageEvent = CommonMessageData & {
|
|
33
|
+
log: Log;
|
|
34
|
+
};
|
|
35
|
+
type DepositForBurnMessageEvent = DepositForBurnMessageData & {
|
|
36
|
+
log: Log;
|
|
37
|
+
};
|
|
38
|
+
type CCTPMessageEvent = CommonMessageEvent | DepositForBurnMessageEvent;
|
|
39
|
+
type CCTPV2APIAttestation = {
|
|
40
|
+
status: string;
|
|
41
|
+
attestation: string;
|
|
42
|
+
message: string;
|
|
43
|
+
eventNonce: string;
|
|
44
|
+
cctpVersion: number;
|
|
45
|
+
decodedMessage: {
|
|
46
|
+
recipient: string;
|
|
47
|
+
destinationDomain: number;
|
|
48
|
+
decodedMessageBody: {
|
|
49
|
+
amount: string;
|
|
50
|
+
mintRecipient: string;
|
|
51
|
+
messageSender: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type CCTPV2APIGetAttestationResponse = {
|
|
56
|
+
messages: CCTPV2APIAttestation[];
|
|
57
|
+
};
|
|
58
|
+
/** ********************************************************************************************************************
|
|
59
|
+
*
|
|
60
|
+
* Exported functions and constants:
|
|
61
|
+
*
|
|
62
|
+
******************************************************************************************************************* **/
|
|
63
|
+
export type AttestedCCTPMessage = CCTPMessageEvent & {
|
|
64
|
+
status: CCTPMessageStatus;
|
|
65
|
+
attestation?: string;
|
|
66
|
+
};
|
|
67
|
+
export type AttestedCCTPDeposit = DepositForBurnMessageEvent & {
|
|
68
|
+
status: CCTPMessageStatus;
|
|
69
|
+
attestation?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @notice Converts an ETH Address string to a 32-byte hex string.
|
|
73
|
+
* @param address The address to convert.
|
|
74
|
+
* @returns The 32-byte hex string representation of the address - required for CCTP messages.
|
|
75
|
+
*/
|
|
76
|
+
export declare function cctpAddressToBytes32(address: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Converts a 32-byte hex string with padding to a standard ETH address.
|
|
79
|
+
* @param bytes32 The 32-byte hex string to convert.
|
|
80
|
+
* @returns The ETH address representation of the 32-byte hex string.
|
|
81
|
+
*/
|
|
82
|
+
export declare function cctpBytes32ToAddress(bytes32: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* @notice Returns the CCTP domain for a given chain ID. Throws if the chain ID is not a CCTP domain.
|
|
85
|
+
* @param chainId
|
|
86
|
+
* @returns CCTP Domain ID
|
|
87
|
+
*/
|
|
88
|
+
export declare function getCctpDomainForChainId(chainId: number): number;
|
|
89
|
+
/**
|
|
90
|
+
* @notice Returns the chain ID for a given CCTP domain. Inverse functionof `getCctpDomainForChainId()`. However,
|
|
91
|
+
* since CCTP Domains are shared between production and test networks, we need to use the `productionNetworks` flag
|
|
92
|
+
* to determine whether to return the production or test network chain ID.
|
|
93
|
+
* @param domain CCTP domain ID.
|
|
94
|
+
* @param productionNetworks Whether to return the production or test network chain ID.
|
|
95
|
+
* @returns Chain ID.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getCctpDestinationChainFromDomain(domain: number, productionNetworks: boolean): number;
|
|
98
|
+
/**
|
|
99
|
+
* @notice Typeguard. Returns whether the event is a CCTP deposit for burn event. Should work for V1 and V2
|
|
100
|
+
* @param event CCTP message event.
|
|
101
|
+
* @returns True if the event is a CCTP deposit for burn event.
|
|
102
|
+
*/
|
|
103
|
+
export declare function isDepositForBurnEvent(event: CCTPMessageEvent): event is DepositForBurnMessageEvent;
|
|
104
|
+
/**
|
|
105
|
+
* @notice Fetches CCTP V2 attestations for a given list of transaction hashes. If a transaction hash
|
|
106
|
+
* contains multiple CCTP messages, this will return an object where each key is a transaction hash and
|
|
107
|
+
* a value is an array of attestations.
|
|
108
|
+
* @param depositForBurnTxnHashes List of transaction hashes to fetch attestations for.
|
|
109
|
+
* @param sourceChainId Source chain ID of the transaction hashes.
|
|
110
|
+
* @returns Object with transaction hashes as keys and CCTP V2 attestations as values.
|
|
111
|
+
*/
|
|
112
|
+
export declare function fetchCctpV2Attestations(depositForBurnTxnHashes: string[], sourceChainId: number): Promise<{
|
|
113
|
+
[sourceTxnHash: string]: CCTPV2APIGetAttestationResponse;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* @notice Returns the status of a CCTP attestation.
|
|
117
|
+
* @param attestation Attestation to get the status of.
|
|
118
|
+
* @returns "finalized","pending" or "ready".
|
|
119
|
+
*/
|
|
120
|
+
export declare function getPendingAttestationStatus(attestation: CCTPV2APIAttestation): CCTPMessageStatus;
|
|
121
|
+
/**
|
|
122
|
+
* @notice Checks if a CCTP message has been processed by a given contract.
|
|
123
|
+
* @param nonceHash Nonce hash to check.
|
|
124
|
+
* @param contract
|
|
125
|
+
* @returns True if the message has been processed, false otherwise.
|
|
126
|
+
*/
|
|
127
|
+
export declare function hasCCTPMessageBeenProcessedEvm(nonceHash: string, contract: ethers.Contract): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* @notice The maximum amount of USDC that can be sent using a fast transfer.
|
|
130
|
+
* @param isMainnet Toggles whether to call CCTP API on mainnet or sandbox environment.
|
|
131
|
+
* @returns USDC amount in units of USDC.
|
|
132
|
+
* @link https://developers.circle.com/api-reference/cctp/all/get-fast-burn-usdc-allowance
|
|
133
|
+
*/
|
|
134
|
+
export declare function getV2FastBurnAllowance(isMainnet: boolean): Promise<string>;
|
|
135
|
+
/**
|
|
136
|
+
* Returns the minimum transfer fees required for a transfer to be relayed. When calling depositForBurn(), the maxFee
|
|
137
|
+
* parameter must be greater than or equal to the minimum fee.
|
|
138
|
+
* @param sourceChainId The source chain ID of the transfer.
|
|
139
|
+
* @param destinationChainId The destination chain ID of the transfer.
|
|
140
|
+
* @param isMainnet Toggles whether to call CCTP API on mainnet or sandbox environment.
|
|
141
|
+
* @returns The standard and fast transfer fees for the given source and destination chains.
|
|
142
|
+
* @link https://developers.circle.com/api-reference/cctp/all/get-burn-usdc-fees
|
|
143
|
+
*/
|
|
144
|
+
export declare function getV2MinTransferFees(sourceChainId: number, destinationChainId: number): Promise<{
|
|
145
|
+
standard: BigNumber;
|
|
146
|
+
fast: BigNumber;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* @notice Fetches attestations for a given transaction hash. If transaction hash contains multiple CCTP
|
|
150
|
+
* messages, this will return an array of attestations. Should work for both v1 and v2.
|
|
151
|
+
* @param sourceDomainId
|
|
152
|
+
* @param transactionHash
|
|
153
|
+
* @param isMainnet
|
|
154
|
+
* @returns Attestation response, list of messages with attestations.
|
|
155
|
+
*/
|
|
156
|
+
export declare function fetchAttestationsForTxn(sourceDomainId: number, transactionHash: string, isMainnet: boolean): Promise<CCTPV2APIGetAttestationResponse>;
|
|
157
|
+
/**
|
|
158
|
+
* @notice Returns the CCTP version of the `MessageSent` event.
|
|
159
|
+
* @param log CCTP event log.
|
|
160
|
+
* @returns 0 for v1 `MessageSent` event, 1 for v2, -1 for other events
|
|
161
|
+
*/
|
|
162
|
+
export declare function getMessageSentVersion(log: ethers.providers.Log): number;
|
|
163
|
+
/**
|
|
164
|
+
* @notice Returns the CCTP version of the `DepositForBurn` event.
|
|
165
|
+
* @param log CCTP event log.
|
|
166
|
+
* @returns 0 for v1 `DepositForBurn` event, 1 for v2, -1 for other events
|
|
167
|
+
*/
|
|
168
|
+
export declare function getDepositForBurnVersion(log: ethers.providers.Log): number;
|
|
169
|
+
export {};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { PUBLIC_NETWORKS, CCTP_NO_DOMAIN, PRODUCTION_NETWORKS, TEST_NETWORKS } from "@across-protocol/constants";
|
|
3
|
+
import { BigNumber, ethers } from "ethers";
|
|
4
|
+
import { isDefined } from "./TypeGuards";
|
|
5
|
+
import axios from "axios";
|
|
6
|
+
import { chainIsProd } from "./NetworkUtils";
|
|
7
|
+
import assert from "assert";
|
|
8
|
+
import { bnZero } from "./BigNumberUtils";
|
|
9
|
+
export var CCTPV2_FINALITY_THRESHOLD_STANDARD = 2000;
|
|
10
|
+
export var CCTPV2_FINALITY_THRESHOLD_FAST = 1000;
|
|
11
|
+
var CCTP_MESSAGE_SENT_TOPIC_HASH = ethers.utils.id("MessageSent(bytes)");
|
|
12
|
+
var CCTP_DEPOSIT_FOR_BURN_TOPIC_HASH_V1 = ethers.utils.id("DepositForBurn(uint64,address,uint256,address,bytes32,uint32,bytes32,bytes32)");
|
|
13
|
+
var CCTP_DEPOSIT_FOR_BURN_TOPIC_HASH_V2 = ethers.utils.id("DepositForBurn(address,uint256,address,bytes32,uint32,bytes32,bytes32,uint256,uint32,bytes)");
|
|
14
|
+
/**
|
|
15
|
+
* @notice Converts an ETH Address string to a 32-byte hex string.
|
|
16
|
+
* @param address The address to convert.
|
|
17
|
+
* @returns The 32-byte hex string representation of the address - required for CCTP messages.
|
|
18
|
+
*/
|
|
19
|
+
export function cctpAddressToBytes32(address) {
|
|
20
|
+
return ethers.utils.hexZeroPad(address, 32);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Converts a 32-byte hex string with padding to a standard ETH address.
|
|
24
|
+
* @param bytes32 The 32-byte hex string to convert.
|
|
25
|
+
* @returns The ETH address representation of the 32-byte hex string.
|
|
26
|
+
*/
|
|
27
|
+
export function cctpBytes32ToAddress(bytes32) {
|
|
28
|
+
// Grab the last 20 bytes of the 32-byte hex string
|
|
29
|
+
return ethers.utils.getAddress(ethers.utils.hexDataSlice(bytes32, 12));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @notice Returns the CCTP domain for a given chain ID. Throws if the chain ID is not a CCTP domain.
|
|
33
|
+
* @param chainId
|
|
34
|
+
* @returns CCTP Domain ID
|
|
35
|
+
*/
|
|
36
|
+
export function getCctpDomainForChainId(chainId) {
|
|
37
|
+
var _a;
|
|
38
|
+
var cctpDomain = (_a = PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.cctpDomain;
|
|
39
|
+
if (!isDefined(cctpDomain) || cctpDomain === CCTP_NO_DOMAIN) {
|
|
40
|
+
throw new Error("No CCTP domain found for chainId: ".concat(chainId));
|
|
41
|
+
}
|
|
42
|
+
return cctpDomain;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @notice Returns the chain ID for a given CCTP domain. Inverse functionof `getCctpDomainForChainId()`. However,
|
|
46
|
+
* since CCTP Domains are shared between production and test networks, we need to use the `productionNetworks` flag
|
|
47
|
+
* to determine whether to return the production or test network chain ID.
|
|
48
|
+
* @param domain CCTP domain ID.
|
|
49
|
+
* @param productionNetworks Whether to return the production or test network chain ID.
|
|
50
|
+
* @returns Chain ID.
|
|
51
|
+
*/
|
|
52
|
+
export function getCctpDestinationChainFromDomain(domain, productionNetworks) {
|
|
53
|
+
if (domain === CCTP_NO_DOMAIN) {
|
|
54
|
+
throw new Error("Cannot input CCTP_NO_DOMAIN to getCctpDestinationChainFromDomain");
|
|
55
|
+
}
|
|
56
|
+
// Test and Production networks use the same CCTP domain, so we need to use the flag passed in to
|
|
57
|
+
// determine whether to use the Test or Production networks.
|
|
58
|
+
var networks = productionNetworks ? PRODUCTION_NETWORKS : TEST_NETWORKS;
|
|
59
|
+
var otherNetworks = productionNetworks ? TEST_NETWORKS : PRODUCTION_NETWORKS;
|
|
60
|
+
var chainId = Object.keys(networks).find(function (key) { return networks[Number(key)].cctpDomain.toString() === domain.toString(); });
|
|
61
|
+
if (!isDefined(chainId)) {
|
|
62
|
+
var chainId_1 = Object.keys(otherNetworks).find(function (key) { return otherNetworks[Number(key)].cctpDomain.toString() === domain.toString(); });
|
|
63
|
+
if (!isDefined(chainId_1)) {
|
|
64
|
+
throw new Error("No chainId found for domain: ".concat(domain));
|
|
65
|
+
}
|
|
66
|
+
return parseInt(chainId_1);
|
|
67
|
+
}
|
|
68
|
+
return parseInt(chainId);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @notice Typeguard. Returns whether the event is a CCTP deposit for burn event. Should work for V1 and V2
|
|
72
|
+
* @param event CCTP message event.
|
|
73
|
+
* @returns True if the event is a CCTP deposit for burn event.
|
|
74
|
+
*/
|
|
75
|
+
export function isDepositForBurnEvent(event) {
|
|
76
|
+
return "amount" in event && "mintRecipient" in event && "burnToken" in event;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @notice Fetches CCTP V2 attestations for a given list of transaction hashes. If a transaction hash
|
|
80
|
+
* contains multiple CCTP messages, this will return an object where each key is a transaction hash and
|
|
81
|
+
* a value is an array of attestations.
|
|
82
|
+
* @param depositForBurnTxnHashes List of transaction hashes to fetch attestations for.
|
|
83
|
+
* @param sourceChainId Source chain ID of the transaction hashes.
|
|
84
|
+
* @returns Object with transaction hashes as keys and CCTP V2 attestations as values.
|
|
85
|
+
*/
|
|
86
|
+
export function fetchCctpV2Attestations(depositForBurnTxnHashes, sourceChainId) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var sourceDomainId, isMainnet, attestationResponses, chunkSize, i, chunk;
|
|
89
|
+
var _this = this;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
sourceDomainId = getCctpDomainForChainId(sourceChainId);
|
|
94
|
+
isMainnet = chainIsProd(sourceChainId);
|
|
95
|
+
attestationResponses = {};
|
|
96
|
+
chunkSize = process.env.CCTP_API_REQUEST_CHUNK_SIZE ? parseInt(process.env.CCTP_API_REQUEST_CHUNK_SIZE) : 8;
|
|
97
|
+
i = 0;
|
|
98
|
+
_a.label = 1;
|
|
99
|
+
case 1:
|
|
100
|
+
if (!(i < depositForBurnTxnHashes.length)) return [3 /*break*/, 5];
|
|
101
|
+
chunk = depositForBurnTxnHashes.slice(i, i + chunkSize);
|
|
102
|
+
return [4 /*yield*/, Promise.all(chunk.map(function (txHash) { return __awaiter(_this, void 0, void 0, function () {
|
|
103
|
+
var attestations;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, fetchAttestationsForTxn(sourceDomainId, txHash, isMainnet)];
|
|
107
|
+
case 1:
|
|
108
|
+
attestations = _a.sent();
|
|
109
|
+
// If multiple deposit for burn events, there will be multiple attestations.
|
|
110
|
+
attestationResponses[txHash] = attestations;
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); }))];
|
|
115
|
+
case 2:
|
|
116
|
+
_a.sent();
|
|
117
|
+
if (!(i + chunkSize < depositForBurnTxnHashes.length)) return [3 /*break*/, 4];
|
|
118
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
|
|
119
|
+
case 3:
|
|
120
|
+
_a.sent();
|
|
121
|
+
_a.label = 4;
|
|
122
|
+
case 4:
|
|
123
|
+
i += chunkSize;
|
|
124
|
+
return [3 /*break*/, 1];
|
|
125
|
+
case 5: return [2 /*return*/, attestationResponses];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @notice Returns the status of a CCTP attestation.
|
|
132
|
+
* @param attestation Attestation to get the status of.
|
|
133
|
+
* @returns "finalized","pending" or "ready".
|
|
134
|
+
*/
|
|
135
|
+
export function getPendingAttestationStatus(attestation) {
|
|
136
|
+
if (!isDefined(attestation.attestation)) {
|
|
137
|
+
return "pending";
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return attestation.status === "pending_confirmations" || attestation.attestation === "PENDING"
|
|
141
|
+
? "pending"
|
|
142
|
+
: "ready";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @notice Checks if a CCTP message has been processed by a given contract.
|
|
147
|
+
* @param nonceHash Nonce hash to check.
|
|
148
|
+
* @param contract
|
|
149
|
+
* @returns True if the message has been processed, false otherwise.
|
|
150
|
+
*/
|
|
151
|
+
export function hasCCTPMessageBeenProcessedEvm(nonceHash, contract) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var resultingCall;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0: return [4 /*yield*/, contract.callStatic.usedNonces(nonceHash)];
|
|
157
|
+
case 1:
|
|
158
|
+
resultingCall = _a.sent();
|
|
159
|
+
// If the resulting call is 1, the message has been processed. If it is 0, the message has not been processed.
|
|
160
|
+
return [2 /*return*/, (resultingCall !== null && resultingCall !== void 0 ? resultingCall : bnZero).toNumber() === 1];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @notice The maximum amount of USDC that can be sent using a fast transfer.
|
|
167
|
+
* @param isMainnet Toggles whether to call CCTP API on mainnet or sandbox environment.
|
|
168
|
+
* @returns USDC amount in units of USDC.
|
|
169
|
+
* @link https://developers.circle.com/api-reference/cctp/all/get-fast-burn-usdc-allowance
|
|
170
|
+
*/
|
|
171
|
+
export function getV2FastBurnAllowance(isMainnet) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
var httpResponse;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0: return [4 /*yield*/, axios.get("https://iris-api".concat(isMainnet ? "" : "-sandbox", ".circle.com/v2/fastBurn/USDC/allowance"))];
|
|
177
|
+
case 1:
|
|
178
|
+
httpResponse = _a.sent();
|
|
179
|
+
return [2 /*return*/, httpResponse.data.allowance.toString()];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Returns the minimum transfer fees required for a transfer to be relayed. When calling depositForBurn(), the maxFee
|
|
186
|
+
* parameter must be greater than or equal to the minimum fee.
|
|
187
|
+
* @param sourceChainId The source chain ID of the transfer.
|
|
188
|
+
* @param destinationChainId The destination chain ID of the transfer.
|
|
189
|
+
* @param isMainnet Toggles whether to call CCTP API on mainnet or sandbox environment.
|
|
190
|
+
* @returns The standard and fast transfer fees for the given source and destination chains.
|
|
191
|
+
* @link https://developers.circle.com/api-reference/cctp/all/get-burn-usdc-fees
|
|
192
|
+
*/
|
|
193
|
+
export function getV2MinTransferFees(sourceChainId, destinationChainId) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var isMainnet, sourceDomain, destinationDomain, endpoint, httpResponse, standardFee, fastFee;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
isMainnet = chainIsProd(destinationChainId);
|
|
200
|
+
sourceDomain = getCctpDomainForChainId(sourceChainId);
|
|
201
|
+
destinationDomain = getCctpDomainForChainId(destinationChainId);
|
|
202
|
+
endpoint = "https://iris-api".concat(isMainnet ? "" : "-sandbox", ".circle.com/v2/burn/USDC/fees/").concat(sourceDomain, "/").concat(destinationDomain);
|
|
203
|
+
return [4 /*yield*/, axios.get(endpoint)];
|
|
204
|
+
case 1:
|
|
205
|
+
httpResponse = _a.sent();
|
|
206
|
+
standardFee = httpResponse.data.find(function (fee) { return fee.finalityThreshold === CCTPV2_FINALITY_THRESHOLD_STANDARD; });
|
|
207
|
+
assert(isDefined(standardFee === null || standardFee === void 0 ? void 0 : standardFee.minimumFee), "CCTPUtils#getTransferFees: Standard fee not found in API response: ".concat(endpoint));
|
|
208
|
+
fastFee = httpResponse.data.find(function (fee) { return fee.finalityThreshold === CCTPV2_FINALITY_THRESHOLD_FAST; });
|
|
209
|
+
assert(isDefined(fastFee === null || fastFee === void 0 ? void 0 : fastFee.minimumFee), "CCTPUtils#getTransferFees: Fast fee not found in API response: ".concat(endpoint));
|
|
210
|
+
return [2 /*return*/, {
|
|
211
|
+
standard: BigNumber.from(standardFee.minimumFee),
|
|
212
|
+
fast: BigNumber.from(fastFee.minimumFee),
|
|
213
|
+
}];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @notice Fetches attestations for a given transaction hash. If transaction hash contains multiple CCTP
|
|
220
|
+
* messages, this will return an array of attestations. Should work for both v1 and v2.
|
|
221
|
+
* @param sourceDomainId
|
|
222
|
+
* @param transactionHash
|
|
223
|
+
* @param isMainnet
|
|
224
|
+
* @returns Attestation response, list of messages with attestations.
|
|
225
|
+
*/
|
|
226
|
+
export function fetchAttestationsForTxn(sourceDomainId, transactionHash, isMainnet) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
+
var httpResponse;
|
|
229
|
+
return __generator(this, function (_a) {
|
|
230
|
+
switch (_a.label) {
|
|
231
|
+
case 0: return [4 /*yield*/, axios.get("https://iris-api".concat(isMainnet ? "" : "-sandbox", ".circle.com/v2/messages/").concat(sourceDomainId, "?transactionHash=").concat(transactionHash))];
|
|
232
|
+
case 1:
|
|
233
|
+
httpResponse = _a.sent();
|
|
234
|
+
return [2 /*return*/, httpResponse.data];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @notice Returns the CCTP version of the `MessageSent` event.
|
|
241
|
+
* @param log CCTP event log.
|
|
242
|
+
* @returns 0 for v1 `MessageSent` event, 1 for v2, -1 for other events
|
|
243
|
+
*/
|
|
244
|
+
export function getMessageSentVersion(log) {
|
|
245
|
+
if (log.topics[0] !== CCTP_MESSAGE_SENT_TOPIC_HASH) {
|
|
246
|
+
return -1;
|
|
247
|
+
}
|
|
248
|
+
// v1 and v2 have the same topic hash, so we have to do a bit of decoding here to understand the version
|
|
249
|
+
var messageBytes = ethers.utils.defaultAbiCoder.decode(["bytes"], log.data)[0];
|
|
250
|
+
// Source: https://developers.circle.com/stablecoins/message-format
|
|
251
|
+
var version = parseInt(messageBytes.slice(2, 10), 16); // read version: first 4 bytes (skipping '0x')
|
|
252
|
+
return version;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @notice Returns the CCTP version of the `DepositForBurn` event.
|
|
256
|
+
* @param log CCTP event log.
|
|
257
|
+
* @returns 0 for v1 `DepositForBurn` event, 1 for v2, -1 for other events
|
|
258
|
+
*/
|
|
259
|
+
export function getDepositForBurnVersion(log) {
|
|
260
|
+
var topic = log.topics[0];
|
|
261
|
+
switch (topic) {
|
|
262
|
+
case CCTP_DEPOSIT_FOR_BURN_TOPIC_HASH_V1:
|
|
263
|
+
return 0;
|
|
264
|
+
case CCTP_DEPOSIT_FOR_BURN_TOPIC_HASH_V2:
|
|
265
|
+
return 1;
|
|
266
|
+
default:
|
|
267
|
+
return -1;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=CCTPUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CCTPUtils.js","sourceRoot":"","sources":["../../../src/utils/CCTPUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,E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M,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,mEAAmE;IACnE,IAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,8CAA8C;IACvG,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAyB;IAChE,IAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5B,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,mCAAmC;YACtC,OAAO,CAAC,CAAC;QACX,KAAK,mCAAmC;YACtC,OAAO,CAAC,CAAC;QACX;YACE,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -168,7 +168,7 @@ export function validateFillForDeposit(relayData, deposit) {
|
|
|
168
168
|
}
|
|
169
169
|
// Note: this short circuits when a key is found where the comparison doesn't match.
|
|
170
170
|
// TODO: if we turn on "strict" in the tsconfig, the elements of FILL_DEPOSIT_COMPARISON_KEYS will be automatically
|
|
171
|
-
// validated against the fields in Fill and Deposit, generating an error if there is a
|
|
171
|
+
// validated against the fields in Fill and Deposit, generating an error if there is a discrepancy.
|
|
172
172
|
var invalidKey = RELAYDATA_KEYS.find(function (key) { return relayData[key].toString() !== deposit[key].toString(); });
|
|
173
173
|
// There should be no paths for `messageHash` to be unset, but mask it off anyway.
|
|
174
174
|
if (!isDefined(invalidKey) && [relayData.messageHash, deposit.messageHash].includes(UNDEFINED_MESSAGE_HASH)) {
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,O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