@across-protocol/sdk 4.3.69 → 4.3.71

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.
Files changed (63) hide show
  1. package/dist/cjs/arch/evm/MessageUtils.d.ts +3 -0
  2. package/dist/cjs/arch/evm/MessageUtils.js +8 -0
  3. package/dist/cjs/arch/evm/MessageUtils.js.map +1 -0
  4. package/dist/cjs/arch/evm/index.d.ts +1 -0
  5. package/dist/cjs/arch/evm/index.js +1 -0
  6. package/dist/cjs/arch/evm/index.js.map +1 -1
  7. package/dist/cjs/arch/svm/MessageUtils.d.ts +3 -0
  8. package/dist/cjs/arch/svm/MessageUtils.js +9 -0
  9. package/dist/cjs/arch/svm/MessageUtils.js.map +1 -0
  10. package/dist/cjs/arch/svm/SpokeUtils.d.ts +1 -1
  11. package/dist/cjs/arch/svm/SpokeUtils.js +21 -49
  12. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
  13. package/dist/cjs/arch/svm/index.d.ts +1 -0
  14. package/dist/cjs/arch/svm/index.js +1 -0
  15. package/dist/cjs/arch/svm/index.js.map +1 -1
  16. package/dist/cjs/gasPriceOracle/oracle.js +1 -0
  17. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  18. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
  19. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  20. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +2 -1
  21. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  22. package/dist/esm/arch/evm/MessageUtils.d.ts +9 -0
  23. package/dist/esm/arch/evm/MessageUtils.js +11 -0
  24. package/dist/esm/arch/evm/MessageUtils.js.map +1 -0
  25. package/dist/esm/arch/evm/index.d.ts +1 -0
  26. package/dist/esm/arch/evm/index.js +1 -0
  27. package/dist/esm/arch/evm/index.js.map +1 -1
  28. package/dist/esm/arch/svm/MessageUtils.d.ts +9 -0
  29. package/dist/esm/arch/svm/MessageUtils.js +15 -0
  30. package/dist/esm/arch/svm/MessageUtils.js.map +1 -0
  31. package/dist/esm/arch/svm/SpokeUtils.d.ts +4 -1
  32. package/dist/esm/arch/svm/SpokeUtils.js +25 -50
  33. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
  34. package/dist/esm/arch/svm/index.d.ts +1 -0
  35. package/dist/esm/arch/svm/index.js +1 -0
  36. package/dist/esm/arch/svm/index.js.map +1 -1
  37. package/dist/esm/gasPriceOracle/oracle.js +1 -1
  38. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  39. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
  40. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  41. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +4 -6
  42. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
  43. package/dist/types/arch/evm/MessageUtils.d.ts +10 -0
  44. package/dist/types/arch/evm/MessageUtils.d.ts.map +1 -0
  45. package/dist/types/arch/evm/index.d.ts +1 -0
  46. package/dist/types/arch/evm/index.d.ts.map +1 -1
  47. package/dist/types/arch/svm/MessageUtils.d.ts +10 -0
  48. package/dist/types/arch/svm/MessageUtils.d.ts.map +1 -0
  49. package/dist/types/arch/svm/SpokeUtils.d.ts +4 -1
  50. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
  51. package/dist/types/arch/svm/index.d.ts +1 -0
  52. package/dist/types/arch/svm/index.d.ts.map +1 -1
  53. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  54. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/arch/evm/MessageUtils.ts +12 -0
  57. package/src/arch/evm/index.ts +1 -0
  58. package/src/arch/svm/MessageUtils.ts +16 -0
  59. package/src/arch/svm/SpokeUtils.ts +6 -23
  60. package/src/arch/svm/index.ts +1 -0
  61. package/src/gasPriceOracle/oracle.ts +1 -1
  62. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +2 -1
  63. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +4 -22
@@ -1,3 +1,4 @@
1
1
  export * from "./SpokeUtils";
2
2
  export * from "./BlockUtils";
3
3
  export * from "./utils";
4
+ export * from "./MessageUtils";
@@ -0,0 +1,16 @@
1
+ import { deserializeMessage } from ".";
2
+ import { RelayData } from "../../interfaces";
3
+ import { BigNumber, bnZero, isMessageEmpty } from "../../utils";
4
+
5
+ /**
6
+ * @notice Return the native token cost of filling a deposit beyond gas cost. We're not using msg.value in our fills,
7
+ * so return zero for EVM side
8
+ * @param deposit RelayData associated with Deposit we're estimating for
9
+ * @returns Native token cost
10
+ */
11
+ export function getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
12
+ // Notice. We return `message.value_amount` here instead of simulating the Transaction. The reason is, we choose to
13
+ // rely hard on Solana program to protect us from not taking more than `value_amount` rather than relying on
14
+ // simulation. Chain state may change between simulation and execution, so simulation alone is unreliable
15
+ return isMessageEmpty(deposit.message) ? bnZero : BigNumber.from(deserializeMessage(deposit.message).value_amount);
16
+ }
@@ -58,7 +58,6 @@ import {
58
58
  chainIsProd,
59
59
  chainIsSvm,
60
60
  chunk,
61
- delay,
62
61
  getMessageHash,
63
62
  isDefined,
64
63
  isUnsafeDepositId,
@@ -1261,21 +1260,17 @@ export async function getFillRelayDelegatePda(
1261
1260
  * @param nonce The nonce to check.
1262
1261
  * @param sourceDomain The source domain.
1263
1262
  * @returns True if the message has been processed, false otherwise.
1263
+ * @dev This function intentionally does not have error handling for `getCCTPNoncePda` nor `simulateAndDecode` since
1264
+ * the error handling would have to account for the asynchronous opening/closing of PDAs, which is better handled downstream,
1265
+ * where the caller of this function has more context.
1264
1266
  */
1265
1267
  export const hasCCTPV1MessageBeenProcessed = async (
1266
1268
  solanaClient: SVMProvider,
1267
1269
  signer: KeyPairSigner,
1268
1270
  nonce: number,
1269
- sourceDomain: number,
1270
- nRetries: number = 0,
1271
- maxRetries: number = 2
1271
+ sourceDomain: number
1272
1272
  ): Promise<boolean> => {
1273
- let noncePda: Address;
1274
- try {
1275
- noncePda = await getCCTPNoncePda(solanaClient, signer, nonce, sourceDomain);
1276
- } catch (e) {
1277
- return false;
1278
- }
1273
+ const noncePda = await getCCTPNoncePda(solanaClient, signer, nonce, sourceDomain);
1279
1274
  const isNonceUsedIx = MessageTransmitterClient.getIsNonceUsedInstruction({
1280
1275
  nonce: nonce,
1281
1276
  usedNonces: noncePda,
@@ -1286,19 +1281,7 @@ export const hasCCTPV1MessageBeenProcessed = async (
1286
1281
  }
1287
1282
  return Boolean(buf[0]);
1288
1283
  };
1289
- // If the nonce PDA was found, we should be able to query the isNonceUsed parameter. If we can't then assume it is a transient RPC error
1290
- // and retry, and throw if the error persists.
1291
- try {
1292
- return await simulateAndDecode(solanaClient, isNonceUsedIx, signer, parserFunction);
1293
- } catch (e) {
1294
- if (nRetries < maxRetries) {
1295
- const delaySeconds = 2 ** nRetries + Math.random();
1296
- await delay(delaySeconds);
1297
-
1298
- return hasCCTPV1MessageBeenProcessed(solanaClient, signer, nonce, sourceDomain, ++nRetries);
1299
- }
1300
- throw e;
1301
- }
1284
+ return await simulateAndDecode(solanaClient, isNonceUsedIx, signer, parserFunction);
1302
1285
  };
1303
1286
 
1304
1287
  /**
@@ -6,3 +6,4 @@ export * from "./constants";
6
6
  export * from "./BlockUtils";
7
7
  export * from "./provider";
8
8
  export * from "./encoders";
9
+ export * from "./MessageUtils";
@@ -108,7 +108,7 @@ function _getEthersGasPriceEstimate(
108
108
  [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
109
109
  [CHAIN_IDs.BSC]: ethereum.legacy,
110
110
  [CHAIN_IDs.MAINNET]: ethereum.eip1559,
111
- // [CHAIN_IDs.PLASMA]: ethereum.eip1559, @todo: Pending RPC support
111
+ [CHAIN_IDs.PLASMA]: ethereum.eip1559,
112
112
  [CHAIN_IDs.POLYGON]: polygon.gasStation,
113
113
  [CHAIN_IDs.SCROLL]: ethereum.legacy,
114
114
  [CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
@@ -22,6 +22,7 @@ import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator
22
22
  import { Transport } from "viem";
23
23
  import { getGasPriceEstimate } from "../../gasPriceOracle";
24
24
  import { EvmProvider } from "../../arch/evm/types";
25
+ import { arch } from "../..";
25
26
 
26
27
  export type SymbolMappingType = Record<
27
28
  string,
@@ -167,7 +168,7 @@ export class QueryBase implements QueryInterface {
167
168
  * @returns Native token cost
168
169
  */
169
170
  getAuxiliaryNativeTokenCost(_deposit: RelayData): BigNumber {
170
- return bnZero;
171
+ return arch.evm.getAuxiliaryNativeTokenCost(_deposit);
171
172
  }
172
173
 
173
174
  /**
@@ -5,32 +5,17 @@ import {
5
5
  fetchEncodedAccount,
6
6
  isSome,
7
7
  } from "@solana/kit";
8
- import {
9
- SVMProvider,
10
- SolanaVoidSigner,
11
- getFillRelayTx,
12
- toAddress,
13
- getAssociatedTokenAddress,
14
- deserializeMessage,
15
- } from "../../arch/svm";
8
+ import { SVMProvider, SolanaVoidSigner, getFillRelayTx, toAddress, getAssociatedTokenAddress } from "../../arch/svm";
16
9
  import { Coingecko } from "../../coingecko";
17
10
  import { CHAIN_IDs } from "../../constants";
18
11
  import { getGasPriceEstimate } from "../../gasPriceOracle";
19
12
  import { RelayData } from "../../interfaces";
20
- import {
21
- Address,
22
- BigNumber,
23
- BigNumberish,
24
- SvmAddress,
25
- TransactionCostEstimate,
26
- bnZero,
27
- isMessageEmpty,
28
- toBN,
29
- } from "../../utils";
13
+ import { Address, BigNumber, BigNumberish, SvmAddress, TransactionCostEstimate, toBN } from "../../utils";
30
14
  import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
31
15
  import { SymbolMappingType } from "./";
32
16
  import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
33
17
  import { TOKEN_2022_PROGRAM_ADDRESS, getTokenSize, fetchMint, Extension } from "@solana-program/token-2022";
18
+ import { arch } from "../..";
34
19
 
35
20
  /**
36
21
  * A special QueryBase implementation for SVM used for querying gas costs, token prices, and decimals of various tokens
@@ -180,10 +165,7 @@ export class SvmQuery implements QueryInterface {
180
165
  * @returns Native token cost
181
166
  */
182
167
  getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
183
- // Notice. We return `message.value_amount` here instead of simulating the Transaction. The reason is, we choose to
184
- // rely hard on Solana program to protect us from not taking more than `value_amount` rather than relying on
185
- // simulation. Chain state may change between simulation and execution, so simulation alone is unreliable
186
- return isMessageEmpty(deposit.message) ? bnZero : BigNumber.from(deserializeMessage(deposit.message).value_amount);
168
+ return arch.svm.getAuxiliaryNativeTokenCost(deposit);
187
169
  }
188
170
 
189
171
  /**