@chainlink/ccip-sdk 0.90.2 → 0.91.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.
Files changed (202) hide show
  1. package/README.md +35 -26
  2. package/dist/aptos/exec.d.ts +4 -5
  3. package/dist/aptos/exec.d.ts.map +1 -1
  4. package/dist/aptos/exec.js +5 -14
  5. package/dist/aptos/exec.js.map +1 -1
  6. package/dist/aptos/hasher.d.ts +18 -0
  7. package/dist/aptos/hasher.d.ts.map +1 -1
  8. package/dist/aptos/hasher.js +18 -0
  9. package/dist/aptos/hasher.js.map +1 -1
  10. package/dist/aptos/index.d.ts +127 -28
  11. package/dist/aptos/index.d.ts.map +1 -1
  12. package/dist/aptos/index.js +199 -70
  13. package/dist/aptos/index.js.map +1 -1
  14. package/dist/aptos/logs.d.ts +18 -0
  15. package/dist/aptos/logs.d.ts.map +1 -1
  16. package/dist/aptos/logs.js +21 -3
  17. package/dist/aptos/logs.js.map +1 -1
  18. package/dist/aptos/send.d.ts +22 -5
  19. package/dist/aptos/send.d.ts.map +1 -1
  20. package/dist/aptos/send.js +23 -15
  21. package/dist/aptos/send.js.map +1 -1
  22. package/dist/aptos/token.d.ts +6 -0
  23. package/dist/aptos/token.d.ts.map +1 -1
  24. package/dist/aptos/token.js +6 -0
  25. package/dist/aptos/token.js.map +1 -1
  26. package/dist/aptos/types.d.ts +16 -1
  27. package/dist/aptos/types.d.ts.map +1 -1
  28. package/dist/aptos/types.js +13 -0
  29. package/dist/aptos/types.js.map +1 -1
  30. package/dist/aptos/utils.d.ts +1 -1
  31. package/dist/aptos/utils.js +1 -1
  32. package/dist/chain.d.ts +185 -99
  33. package/dist/chain.d.ts.map +1 -1
  34. package/dist/chain.js +38 -15
  35. package/dist/chain.js.map +1 -1
  36. package/dist/commits.d.ts +4 -10
  37. package/dist/commits.d.ts.map +1 -1
  38. package/dist/commits.js +2 -1
  39. package/dist/commits.js.map +1 -1
  40. package/dist/evm/const.d.ts +5 -0
  41. package/dist/evm/const.d.ts.map +1 -1
  42. package/dist/evm/const.js +5 -0
  43. package/dist/evm/const.js.map +1 -1
  44. package/dist/evm/errors.d.ts +5 -0
  45. package/dist/evm/errors.d.ts.map +1 -1
  46. package/dist/evm/errors.js +6 -1
  47. package/dist/evm/errors.js.map +1 -1
  48. package/dist/evm/hasher.d.ts +16 -2
  49. package/dist/evm/hasher.d.ts.map +1 -1
  50. package/dist/evm/hasher.js +17 -3
  51. package/dist/evm/hasher.js.map +1 -1
  52. package/dist/evm/index.d.ts +176 -31
  53. package/dist/evm/index.d.ts.map +1 -1
  54. package/dist/evm/index.js +312 -154
  55. package/dist/evm/index.js.map +1 -1
  56. package/dist/evm/logs.d.ts +20 -0
  57. package/dist/evm/logs.d.ts.map +1 -0
  58. package/dist/evm/logs.js +194 -0
  59. package/dist/evm/logs.js.map +1 -0
  60. package/dist/evm/messages.d.ts +11 -2
  61. package/dist/evm/messages.d.ts.map +1 -1
  62. package/dist/evm/messages.js +4 -2
  63. package/dist/evm/messages.js.map +1 -1
  64. package/dist/evm/offchain.d.ts +7 -2
  65. package/dist/evm/offchain.d.ts.map +1 -1
  66. package/dist/evm/offchain.js +12 -7
  67. package/dist/evm/offchain.js.map +1 -1
  68. package/dist/execution.d.ts +19 -62
  69. package/dist/execution.d.ts.map +1 -1
  70. package/dist/execution.js +28 -31
  71. package/dist/execution.js.map +1 -1
  72. package/dist/extra-args.d.ts +35 -5
  73. package/dist/extra-args.d.ts.map +1 -1
  74. package/dist/extra-args.js +10 -5
  75. package/dist/extra-args.js.map +1 -1
  76. package/dist/gas.d.ts +6 -8
  77. package/dist/gas.d.ts.map +1 -1
  78. package/dist/gas.js +7 -9
  79. package/dist/gas.js.map +1 -1
  80. package/dist/hasher/common.d.ts +3 -2
  81. package/dist/hasher/common.d.ts.map +1 -1
  82. package/dist/hasher/common.js +2 -2
  83. package/dist/hasher/common.js.map +1 -1
  84. package/dist/hasher/hasher.d.ts +8 -2
  85. package/dist/hasher/hasher.d.ts.map +1 -1
  86. package/dist/hasher/hasher.js +8 -3
  87. package/dist/hasher/hasher.js.map +1 -1
  88. package/dist/hasher/merklemulti.d.ts +11 -9
  89. package/dist/hasher/merklemulti.d.ts.map +1 -1
  90. package/dist/hasher/merklemulti.js +17 -16
  91. package/dist/hasher/merklemulti.js.map +1 -1
  92. package/dist/index.d.ts +16 -8
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +17 -7
  95. package/dist/index.js.map +1 -1
  96. package/dist/requests.d.ts +39 -25
  97. package/dist/requests.d.ts.map +1 -1
  98. package/dist/requests.js +42 -35
  99. package/dist/requests.js.map +1 -1
  100. package/dist/selectors.d.ts +1 -1
  101. package/dist/solana/cleanup.d.ts +14 -10
  102. package/dist/solana/cleanup.d.ts.map +1 -1
  103. package/dist/solana/cleanup.js +35 -33
  104. package/dist/solana/cleanup.js.map +1 -1
  105. package/dist/solana/exec.d.ts +19 -11
  106. package/dist/solana/exec.d.ts.map +1 -1
  107. package/dist/solana/exec.js +86 -163
  108. package/dist/solana/exec.js.map +1 -1
  109. package/dist/solana/hasher.d.ts +7 -2
  110. package/dist/solana/hasher.d.ts.map +1 -1
  111. package/dist/solana/hasher.js +7 -2
  112. package/dist/solana/hasher.js.map +1 -1
  113. package/dist/solana/index.d.ts +202 -84
  114. package/dist/solana/index.d.ts.map +1 -1
  115. package/dist/solana/index.js +367 -252
  116. package/dist/solana/index.js.map +1 -1
  117. package/dist/solana/offchain.d.ts +8 -18
  118. package/dist/solana/offchain.d.ts.map +1 -1
  119. package/dist/solana/offchain.js +29 -83
  120. package/dist/solana/offchain.js.map +1 -1
  121. package/dist/solana/patchBorsh.d.ts +5 -1
  122. package/dist/solana/patchBorsh.d.ts.map +1 -1
  123. package/dist/solana/patchBorsh.js +57 -46
  124. package/dist/solana/patchBorsh.js.map +1 -1
  125. package/dist/solana/send.d.ts +28 -10
  126. package/dist/solana/send.d.ts.map +1 -1
  127. package/dist/solana/send.js +44 -77
  128. package/dist/solana/send.js.map +1 -1
  129. package/dist/solana/types.d.ts +22 -1
  130. package/dist/solana/types.d.ts.map +1 -1
  131. package/dist/solana/types.js +12 -1
  132. package/dist/solana/types.js.map +1 -1
  133. package/dist/solana/utils.d.ts +58 -4
  134. package/dist/solana/utils.d.ts.map +1 -1
  135. package/dist/solana/utils.js +110 -7
  136. package/dist/solana/utils.js.map +1 -1
  137. package/dist/sui/hasher.d.ts +18 -0
  138. package/dist/sui/hasher.d.ts.map +1 -1
  139. package/dist/sui/hasher.js +18 -0
  140. package/dist/sui/hasher.js.map +1 -1
  141. package/dist/sui/index.d.ts +99 -12
  142. package/dist/sui/index.d.ts.map +1 -1
  143. package/dist/sui/index.js +108 -19
  144. package/dist/sui/index.js.map +1 -1
  145. package/dist/sui/types.d.ts +6 -0
  146. package/dist/sui/types.d.ts.map +1 -1
  147. package/dist/sui/types.js +5 -0
  148. package/dist/sui/types.js.map +1 -1
  149. package/dist/supported-chains.d.ts +2 -1
  150. package/dist/supported-chains.d.ts.map +1 -1
  151. package/dist/supported-chains.js.map +1 -1
  152. package/dist/types.d.ts +127 -16
  153. package/dist/types.d.ts.map +1 -1
  154. package/dist/types.js +18 -0
  155. package/dist/types.js.map +1 -1
  156. package/dist/utils.d.ts +67 -46
  157. package/dist/utils.d.ts.map +1 -1
  158. package/dist/utils.js +143 -21
  159. package/dist/utils.js.map +1 -1
  160. package/package.json +13 -9
  161. package/src/aptos/exec.ts +7 -18
  162. package/src/aptos/hasher.ts +18 -0
  163. package/src/aptos/index.ts +288 -110
  164. package/src/aptos/logs.ts +21 -3
  165. package/src/aptos/send.ts +25 -22
  166. package/src/aptos/token.ts +6 -0
  167. package/src/aptos/types.ts +26 -2
  168. package/src/aptos/utils.ts +1 -1
  169. package/src/chain.ts +243 -108
  170. package/src/commits.ts +6 -7
  171. package/src/evm/const.ts +5 -0
  172. package/src/evm/errors.ts +6 -1
  173. package/src/evm/hasher.ts +20 -4
  174. package/src/evm/index.ts +416 -214
  175. package/src/evm/logs.ts +255 -0
  176. package/src/evm/messages.ts +11 -5
  177. package/src/evm/offchain.ts +13 -4
  178. package/src/execution.ts +40 -32
  179. package/src/extra-args.ts +38 -6
  180. package/src/gas.ts +7 -9
  181. package/src/hasher/common.ts +3 -2
  182. package/src/hasher/hasher.ts +12 -4
  183. package/src/hasher/merklemulti.ts +17 -16
  184. package/src/index.ts +29 -23
  185. package/src/requests.ts +64 -46
  186. package/src/selectors.ts +1 -1
  187. package/src/solana/cleanup.ts +49 -34
  188. package/src/solana/exec.ts +128 -272
  189. package/src/solana/hasher.ts +13 -4
  190. package/src/solana/index.ts +483 -356
  191. package/src/solana/offchain.ts +32 -102
  192. package/src/solana/patchBorsh.ts +65 -50
  193. package/src/solana/send.ts +52 -111
  194. package/src/solana/types.ts +44 -3
  195. package/src/solana/utils.ts +143 -19
  196. package/src/sui/hasher.ts +18 -0
  197. package/src/sui/index.ts +143 -31
  198. package/src/sui/types.ts +6 -0
  199. package/src/supported-chains.ts +2 -1
  200. package/src/types.ts +130 -18
  201. package/src/utils.ts +168 -26
  202. package/tsconfig.json +2 -1
@@ -1,26 +1,26 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { AddressLookupTableProgram, PublicKey, SystemProgram } from '@solana/web3.js';
1
+ import { Buffer } from 'buffer';
2
+ import { AnchorProvider, Program } from '@coral-xyz/anchor';
3
+ import { AddressLookupTableProgram, PublicKey, SystemProgram, } from '@solana/web3.js';
3
4
  import { dataSlice, hexlify } from 'ethers';
4
- import moize from 'moize';
5
+ import { memoize } from 'micro-memoize';
5
6
  import { sleep } from "../utils.js";
6
7
  import { IDL as CCIP_OFFRAMP_IDL } from "./idl/1.6.0/CCIP_OFFRAMP.js";
7
- import { simulateAndSendTxs } from "./send.js";
8
+ import { simulateAndSendTxs } from "./utils.js";
8
9
  /**
9
- * Clean up and recycle buffers and address lookup tables owned by wallet
10
- * CAUTION: this will close ANY lookup table owned by this wallet
11
- * @param provider - AnchorProvider with connection and wallet
12
- * @param getLogs - SolanaChain-compatible getLogs function (to scan for Buffers and ALTs)
13
- * @param opts.dontWait - Whether to skip waiting for lookup table deactivation cool down period
14
- * (513 slots) to pass before closing; by default, we deactivate (if needed) and wait to close
15
- * before returning from this method
10
+ * Clean up and recycle buffers and Address Lookup Tables owned by wallet.
11
+ * @param ctx - Context object containing the Solana connection instance and logger.
12
+ * @param wallet - Wallet instance to sign txs.
13
+ * @param getLogs - SolanaChain-compatible getLogs function (to scan for Buffers and ALTs).
14
+ * @param opts - Optional parameters. Set `waitDeactivation` to wait for lookup table deactivation
15
+ * cool down period (513 slots) to pass before closing; by default, we deactivate (if needed)
16
+ * and leave close to be done in the future.
16
17
  */
17
- export async function cleanUpBuffers(provider, getLogs, opts) {
18
- const connection = provider.connection;
19
- const wallet = provider.wallet;
20
- console.debug('Starting cleaning up buffers and lookup tables for account', wallet.publicKey.toString());
18
+ export async function cleanUpBuffers(ctx, wallet, getLogs, opts) {
19
+ const { connection, logger = console } = ctx;
20
+ logger.debug('Starting cleaning up buffers and lookup tables for account', wallet.publicKey.toString());
21
21
  const seenAccs = new Set();
22
22
  const pendingPromises = [];
23
- const getCurrentSlot = moize.default(async () => {
23
+ const getCurrentSlot = memoize(async () => {
24
24
  let lastErr;
25
25
  for (let i = 0; i < 10; i++) {
26
26
  try {
@@ -28,23 +28,23 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
28
28
  }
29
29
  catch (err) {
30
30
  lastErr = err;
31
- console.warn('Failed to get current slot', i, err);
31
+ logger.warn('Failed to get current slot', i, err);
32
32
  await sleep(500);
33
33
  }
34
34
  }
35
35
  throw lastErr;
36
- }, { maxAge: 1000, isPromise: true });
36
+ }, { maxAge: 1000, async: true });
37
37
  const closeAlt = async (lookupTable, deactivationSlot) => {
38
38
  const altAddr = lookupTable.toBase58();
39
39
  let sig;
40
40
  while (!sig) {
41
41
  const delta = deactivationSlot + 513 - (await getCurrentSlot());
42
42
  if (delta > 0) {
43
- if (opts?.dontWait) {
44
- console.warn('Skipping: lookup table', altAddr, 'not yet ready for close until', 0.4 * delta, 'seconds');
43
+ if (!opts?.waitDeactivation) {
44
+ logger.warn('Skipping: lookup table', altAddr, 'not yet ready for close until', 0.4 * delta, 'seconds');
45
45
  return;
46
46
  }
47
- console.debug('Waiting for slot', deactivationSlot + 513, 'to be reached in', 0.4 * delta, 'seconds before closing lookup table', altAddr);
47
+ logger.debug('Waiting for slot', deactivationSlot + 513, 'to be reached in', 0.4 * delta, 'seconds before closing lookup table', altAddr);
48
48
  await sleep(400 * delta);
49
49
  }
50
50
  const closeIx = AddressLookupTableProgram.closeLookupTable({
@@ -53,8 +53,8 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
53
53
  lookupTable,
54
54
  });
55
55
  try {
56
- sig = await simulateAndSendTxs(connection, wallet, [closeIx]);
57
- console.info('🗑️ Closed lookup table', altAddr, ': tx =>', sig);
56
+ sig = await simulateAndSendTxs(ctx, wallet, { instructions: [closeIx] });
57
+ logger.info('🗑️ Closed lookup table', altAddr, ': tx =>', sig);
58
58
  }
59
59
  catch (err) {
60
60
  const info = await connection.getAddressLookupTable(lookupTable);
@@ -62,7 +62,7 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
62
62
  break;
63
63
  else if (info.value.state.deactivationSlot < 2n ** 63n)
64
64
  deactivationSlot = Number(info.value.state.deactivationSlot);
65
- console.warn('Failed to close lookup table', altAddr, err);
65
+ logger.warn('Failed to close lookup table', altAddr, err);
66
66
  }
67
67
  }
68
68
  };
@@ -85,14 +85,14 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
85
85
  ({ data }) => dataSlice(data, 0, 8 + 4) === '0x23cafcdc0252bd1720000000')
86
86
  .map(({ data }) => Buffer.from(data.subarray(8 + 4, 8 + 4 + 32)));
87
87
  for (const bufferId of bufferIds) {
88
- const offrampProgram = new Program(CCIP_OFFRAMP_IDL, new PublicKey(log.address), provider);
88
+ const offrampProgram = new Program(CCIP_OFFRAMP_IDL, new PublicKey(log.address), new AnchorProvider(connection, wallet, { commitment: 'confirmed' }));
89
89
  const [executionReportBuffer] = PublicKey.findProgramAddressSync([Buffer.from('execution_report_buffer'), bufferId, wallet.publicKey.toBuffer()], offrampProgram.programId);
90
90
  if (seenAccs.has(executionReportBuffer.toBase58()))
91
91
  continue;
92
92
  seenAccs.add(executionReportBuffer.toBase58());
93
93
  const accInfo = await connection.getAccountInfo(executionReportBuffer);
94
94
  if (!accInfo) {
95
- console.debug('Buffer with bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), 'already closed');
95
+ logger.debug('Buffer with bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), 'already closed');
96
96
  continue;
97
97
  }
98
98
  const bufferingAccounts = {
@@ -106,10 +106,10 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
106
106
  .closeExecutionReportBuffer(bufferId)
107
107
  .accounts(bufferingAccounts)
108
108
  .rpc();
109
- console.info('🗑️ Closed bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), ': tx =>', sig);
109
+ logger.info('🗑️ Closed bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), ': tx =>', sig);
110
110
  }
111
111
  catch (err) {
112
- console.warn('Failed to close bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), err);
112
+ logger.warn('Failed to close bufferId', hexlify(bufferId), 'at', executionReportBuffer.toBase58(), err);
113
113
  }
114
114
  }
115
115
  break;
@@ -123,10 +123,10 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
123
123
  const info = await connection.getAddressLookupTable(lookupTable);
124
124
  if (!info?.value) {
125
125
  alreadyClosed++; // assume we're done when we hit Nth closed ALT; maybe add an option to keep going?
126
- console.debug('Lookup table', lookupTable.toBase58(), 'already closed');
126
+ logger.debug('Lookup table', lookupTable.toBase58(), 'already closed');
127
127
  }
128
128
  else if (info.value.state.authority?.toBase58() !== wallet.publicKey.toBase58()) {
129
- console.debug('Lookup table', lookupTable.toBase58(), 'not owned by us, but by', info.value.state.authority?.toBase58());
129
+ logger.debug('Lookup table', lookupTable.toBase58(), 'not owned by us, but by', info.value.state.authority?.toBase58());
130
130
  }
131
131
  else if (info.value.state.deactivationSlot < 2n ** 63n) {
132
132
  // non-deactivated have deactivationSlot=MAX_UINT64
@@ -140,12 +140,14 @@ export async function cleanUpBuffers(provider, getLogs, opts) {
140
140
  lookupTable: lookupTable,
141
141
  });
142
142
  try {
143
- const sig = await simulateAndSendTxs(connection, wallet, [deactivateIx]);
144
- console.info('⤵️ Deactivated lookup table', lookupTable.toBase58(), ': tx =>', sig);
143
+ const sig = await simulateAndSendTxs(ctx, wallet, {
144
+ instructions: [deactivateIx],
145
+ });
146
+ logger.info('⤵️ Deactivated lookup table', lookupTable.toBase58(), ': tx =>', sig);
145
147
  pendingPromises.push(closeAlt(lookupTable, await getCurrentSlot()));
146
148
  }
147
149
  catch (err) {
148
- console.warn('Failed to deactivate lookup table', lookupTable.toBase58(), err);
150
+ logger.warn('Failed to deactivate lookup table', lookupTable.toBase58(), err);
149
151
  }
150
152
  }
151
153
  break; // case
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/solana/cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACrF,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,GAAG,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,OAA+B,EAC/B,IAA6B;IAE7B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port } from '../types.ts';
3
- import { IDL as CCIP_OFFRAMP_IDL } from './idl/1.6.0/CCIP_OFFRAMP.ts';
4
- import type { CCIPMessage_V1_6_Solana } from './types.ts';
5
- import type { ChainTransaction } from '../chain.ts';
6
- import './patchBorsh.ts';
7
- export declare function executeReport({ offrampProgram, execReport, ...opts }: {
8
- offrampProgram: Program<typeof CCIP_OFFRAMP_IDL>;
9
- execReport: ExecutionReport<CCIPMessage_V1_6_Solana>;
10
- gasLimit?: number;
1
+ import { type Connection, PublicKey } from '@solana/web3.js';
2
+ import { type ExecutionReport, type WithLogger } from '../types.ts';
3
+ import type { CCIPMessage_V1_6_Solana, UnsignedSolanaTx } from './types.ts';
4
+ /**
5
+ * Generate unsigned tx to execute a CCIP report on Solana.
6
+ * @param ctx - Context containing connection and logger
7
+ * @param payer - Payer of the transaction.
8
+ * @param offramp - Address of the OffRamp contract.
9
+ * @param execReport - Execution report.
10
+ * @param opts - Options for txs to be generated
11
+ * - forceBuffer - Sends report in chunks for buffering in offRamp before execution
12
+ * - forceLookupTable - Creates lookup table for execution transaction, and deactivates in the end
13
+ * - clearLeftoverAccounts - Resets buffer before filling it in
14
+ * @returns Transaction hash of the execution.
15
+ */
16
+ export declare function generateUnsignedExecuteReport(ctx: {
17
+ connection: Connection;
18
+ } & WithLogger, payer: PublicKey, offramp: PublicKey, execReport: ExecutionReport<CCIPMessage_V1_6_Solana>, opts?: {
11
19
  forceLookupTable?: boolean;
12
20
  forceBuffer?: boolean;
13
21
  clearLeftoverAccounts?: boolean;
14
- }): Promise<Pick<ChainTransaction, 'hash'>>;
22
+ }): Promise<UnsignedSolanaTx>;
15
23
  //# sourceMappingURL=exec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/solana/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAkB/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CA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AAC,EAAE,OAAO,CAAA;CAAE,GAC5F,OAAO,CAAC,gBAAgB,CAAC,CA8F3B"}
@@ -1,97 +1,64 @@
1
+ import { Buffer } from 'buffer';
1
2
  import { Program } from '@coral-xyz/anchor';
2
- import { AddressLookupTableAccount, AddressLookupTableProgram, ComputeBudgetProgram, PublicKey, SendTransactionError, SystemProgram, TransactionExpiredBlockheightExceededError, TransactionMessage, VersionedTransaction, } from '@solana/web3.js';
3
+ import { AddressLookupTableAccount, AddressLookupTableProgram, PublicKey, SystemProgram, } from '@solana/web3.js';
3
4
  import BN from 'bn.js';
4
5
  import { hexlify } from 'ethers';
6
+ import { ChainFamily } from "../types.js";
5
7
  import { IDL as CCIP_OFFRAMP_IDL } from "./idl/1.6.0/CCIP_OFFRAMP.js";
6
8
  import { encodeSolanaOffchainTokenData } from "./offchain.js";
7
- import { getDataBytes, sleep, toLeArray } from "../utils.js";
8
- import { bytesToBuffer, simulateTransaction, simulationProvider } from "./utils.js";
9
- import "./patchBorsh.js";
10
- export async function executeReport({ offrampProgram, execReport, ...opts }) {
11
- const provider = offrampProgram.provider;
12
- const wallet = provider.wallet;
13
- const connection = provider.connection;
14
- const execTxs = await buildExecTxToSolana(offrampProgram, execReport, opts?.gasLimit, opts);
15
- let execTxSignature, signature;
16
- for (const [i, [reason, transaction]] of execTxs.entries()) {
17
- // Refresh the blockhash for each transaction, as the blockhash is only valid for a short time
18
- // and we spend a lot of time waiting for finalization of the previous transactions.
19
- transaction.message.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
20
- const signed = await wallet.signTransaction(transaction);
21
- try {
22
- signature = await connection.sendTransaction(signed);
23
- if (reason === 'exec')
24
- execTxSignature = signature;
25
- }
26
- catch (e) {
27
- if (e instanceof SendTransactionError &&
28
- e.logs?.some((log) => log.includes('Error Code: ExecutionReportBufferAlreadyContainsChunk.'))) {
29
- console.warn(`Skipping tx ${i + 1} of ${execTxs.length} because a chunk is already in the buffer.`);
30
- continue;
31
- }
32
- else {
33
- throw e;
34
- }
35
- }
36
- console.debug(`Confirming tx #${i + 1} of ${execTxs.length}: ${signature} (${reason})...`);
37
- for (let currentAttempt = 0;; currentAttempt++) {
38
- try {
39
- const latestBlockhash = await connection.getLatestBlockhash();
40
- await connection.confirmTransaction({
41
- signature,
42
- blockhash: latestBlockhash.blockhash,
43
- lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
44
- }, 'confirmed');
45
- break;
46
- }
47
- catch (e) {
48
- if (currentAttempt < 5 && e instanceof TransactionExpiredBlockheightExceededError) {
49
- await sleep(1000);
50
- }
51
- else {
52
- throw e;
53
- }
54
- }
55
- }
56
- }
57
- return { hash: execTxSignature };
58
- }
59
- async function buildExecTxToSolana(offrampProgram, execReport, computeUnitsOverride, opts) {
60
- const provider = offrampProgram.provider;
61
- offrampProgram = new Program(CCIP_OFFRAMP_IDL, offrampProgram.programId, provider);
62
- const payerAddress = provider.wallet.publicKey;
9
+ import { getDataBytes, toLeArray } from "../utils.js";
10
+ import { bytesToBuffer } from "./utils.js";
11
+ /**
12
+ * Generate unsigned tx to execute a CCIP report on Solana.
13
+ * @param ctx - Context containing connection and logger
14
+ * @param payer - Payer of the transaction.
15
+ * @param offramp - Address of the OffRamp contract.
16
+ * @param execReport - Execution report.
17
+ * @param opts - Options for txs to be generated
18
+ * - forceBuffer - Sends report in chunks for buffering in offRamp before execution
19
+ * - forceLookupTable - Creates lookup table for execution transaction, and deactivates in the end
20
+ * - clearLeftoverAccounts - Resets buffer before filling it in
21
+ * @returns Transaction hash of the execution.
22
+ */
23
+ export async function generateUnsignedExecuteReport(ctx, payer, offramp, execReport, opts) {
24
+ const { connection, logger = console } = ctx;
25
+ const program = new Program(CCIP_OFFRAMP_IDL, offramp, ctx);
63
26
  let bufferId;
64
27
  if (opts?.forceBuffer) {
65
28
  // Use messageId for bufferId. This is arbitrary, but easy to track.
66
29
  bufferId = bytesToBuffer(execReport.message.header.messageId);
67
30
  }
68
31
  const { executionReport: preparedReport, tokenIndexes, accounts, addressLookupTables, } = await getManuallyExecuteInputs({
32
+ payer,
33
+ offramp: program,
69
34
  execReport,
70
- offrampProgram,
71
- transmitter: payerAddress.toBase58(),
72
35
  bufferId,
36
+ logger,
73
37
  });
74
38
  const addressLookupTableAccounts = await Promise.all(addressLookupTables.map(async (acc) => {
75
- const lookupTableAccountInfo = await provider.connection.getAddressLookupTable(acc);
39
+ const lookupTableAccountInfo = await connection.getAddressLookupTable(acc);
76
40
  if (!lookupTableAccountInfo.value) {
77
41
  throw new Error(`Lookup table account not found: ${acc.toBase58()}`);
78
42
  }
79
43
  return lookupTableAccountInfo.value;
80
44
  }));
81
- let serializedReport = offrampProgram.coder.types.encode('ExecutionReportSingleChain', preparedReport);
82
- const { blockhash: recentBlockhash } = await provider.connection.getLatestBlockhash();
45
+ let serializedReport = program.coder.types.encode('ExecutionReportSingleChain', preparedReport);
83
46
  let alt;
84
47
  if (opts?.forceLookupTable) {
85
- alt = await buildLookupTableTxs(provider, accounts);
86
- addressLookupTableAccounts.push(alt.addressLookupTableAccount);
48
+ alt = await buildLookupTableIxs(ctx, payer, accounts.map((acc) => acc.pubkey));
49
+ addressLookupTableAccounts.push(alt.lookupTable);
87
50
  }
88
- const transactions = [];
51
+ const instructions = [];
89
52
  if (bufferId) {
90
- console.log(`Execute report will be pre-buffered through the offramp. This may take some time.`);
91
- transactions.push(...(await bufferedTransactionData(offrampProgram, serializedReport, recentBlockhash, bufferId, opts)));
53
+ logger.info(`Execute report will be pre-buffered through the offramp. This may take some time.`);
54
+ const bufferingIxs = await bufferedTransactionData(payer, program, serializedReport, bufferId, {
55
+ logger,
56
+ ...opts,
57
+ });
58
+ instructions.push(...bufferingIxs);
92
59
  serializedReport = Buffer.from([]); // clear 1st param to manuallyExecute method if buffered
93
60
  }
94
- const execTx = await offrampProgram.methods
61
+ const execIx = await program.methods
95
62
  .manuallyExecute(serializedReport, tokenIndexes)
96
63
  .accounts({
97
64
  config: accounts[0].pubkey,
@@ -108,39 +75,31 @@ async function buildExecTxToSolana(offrampProgram, execReport, computeUnitsOverr
108
75
  rmnRemoteConfig: accounts[11].pubkey,
109
76
  })
110
77
  .remainingAccounts(accounts.slice(12))
111
- .transaction();
112
- computeUnitsOverride ||= Math.ceil(1.1 *
113
- ((await simulateTransaction({
114
- instructions: execTx.instructions,
115
- connection: provider.connection,
116
- payerKey: provider.wallet.publicKey,
117
- addressLookupTableAccounts,
118
- computeUnitsOverride,
119
- })).unitsConsumed || 0));
120
- // Add compute budget instruction at the beginning of instructions
121
- execTx.instructions.unshift(ComputeBudgetProgram.setComputeUnitLimit({
122
- units: computeUnitsOverride,
123
- }));
78
+ .instruction();
124
79
  // actual exec tx
125
- transactions.push([
126
- 'exec',
127
- toVersionedTransaction(execTx.instructions, provider.wallet.publicKey, recentBlockhash, addressLookupTableAccounts),
128
- ]);
80
+ let execIndex = instructions.length;
81
+ instructions.push(execIx);
82
+ // "sandwich" instructions with ALT create+extend, then deactivate
129
83
  if (alt) {
130
- transactions.unshift(...alt.initialTxs);
131
- transactions.push(...alt.finalTxs);
84
+ instructions.unshift(...alt.initialIxs);
85
+ execIndex += alt.initialIxs.length;
86
+ instructions.push(...alt.finalIxs);
132
87
  }
133
- return transactions;
88
+ return {
89
+ family: ChainFamily.Solana,
90
+ instructions,
91
+ lookupTables: addressLookupTableAccounts,
92
+ mainIndex: execIndex,
93
+ };
134
94
  }
135
- async function buildLookupTableTxs(provider, accounts) {
136
- const recentSlot = await provider.connection.getSlot('finalized');
95
+ async function buildLookupTableIxs({ connection, logger = console }, authority, addresses) {
96
+ const recentSlot = await connection.getSlot('confirmed');
137
97
  const [createIx, altAddr] = AddressLookupTableProgram.createLookupTable({
138
- authority: provider.wallet.publicKey,
139
- payer: provider.wallet.publicKey,
98
+ authority,
99
+ payer: authority,
140
100
  recentSlot,
141
101
  });
142
- console.log('Using Address Lookup Table', altAddr.toBase58());
143
- const addresses = accounts.map((a) => a.pubkey);
102
+ logger.info('Using Address Lookup Table', altAddr.toBase58());
144
103
  if (addresses.length > 256) {
145
104
  throw new Error(`The number of addresses (${addresses.length}) exceeds the maximum limit imposed by Solana of 256 for Address Lookup Tables`);
146
105
  }
@@ -149,21 +108,19 @@ async function buildLookupTableTxs(provider, accounts) {
149
108
  const firstChunkLength = 28;
150
109
  const maxAddressesPerTx = 35;
151
110
  const extendIxs = [];
152
- const ranges = [];
153
111
  for (let [start, end] = [0, firstChunkLength]; start < addresses.length; [start, end] = [end, end + maxAddressesPerTx]) {
154
112
  const addressesChunk = addresses.slice(start, end);
155
113
  const extendIx = AddressLookupTableProgram.extendLookupTable({
156
- payer: provider.wallet.publicKey,
157
- authority: provider.wallet.publicKey,
114
+ authority,
115
+ payer: authority,
158
116
  lookupTable: altAddr,
159
117
  addresses: addressesChunk,
160
118
  });
161
119
  extendIxs.push(extendIx);
162
- ranges.push([start, start + addressesChunk.length - 1]);
163
120
  }
164
121
  const deactivateIx = AddressLookupTableProgram.deactivateLookupTable({
165
122
  lookupTable: altAddr,
166
- authority: provider.wallet.publicKey,
123
+ authority,
167
124
  });
168
125
  // disable closeTx, to be cleaned in SolanaChain.cleanUpBuffers
169
126
  // const closeIx = AddressLookupTableProgram.closeLookupTable({
@@ -171,82 +128,50 @@ async function buildLookupTableTxs(provider, accounts) {
171
128
  // recipient: provider.wallet.publicKey,
172
129
  // lookupTable: altAddr,
173
130
  // })
174
- const { blockhash: recentBlockhash } = await provider.connection.getLatestBlockhash();
175
131
  return {
176
- addressLookupTableAccount: new AddressLookupTableAccount({
132
+ lookupTable: new AddressLookupTableAccount({
177
133
  key: altAddr,
178
134
  state: {
179
- deactivationSlot: BigInt(0),
135
+ deactivationSlot: 2n ** 64n - 1n,
180
136
  lastExtendedSlot: recentSlot,
181
137
  lastExtendedSlotStartIndex: 0,
182
138
  addresses,
183
139
  },
184
140
  }),
185
- initialTxs: [
186
- // first extendIx fits in create tx
187
- [
188
- `lookup[create + 0..${ranges[0][1]}]`,
189
- toVersionedTransaction([createIx, extendIxs[0]], provider.wallet.publicKey, recentBlockhash),
190
- ],
191
- ...extendIxs
192
- .slice(1)
193
- .map((ix, i) => [
194
- `lookup[${ranges[i + 1][0]}..${ranges[i + 1][1]}]`,
195
- toVersionedTransaction([ix], provider.wallet.publicKey, recentBlockhash),
196
- ]),
197
- ],
198
- finalTxs: [
199
- [
200
- `lookup[deactivate]`,
201
- toVersionedTransaction([deactivateIx], provider.wallet.publicKey, recentBlockhash),
202
- ],
203
- ],
141
+ initialIxs: [createIx, ...extendIxs],
142
+ finalIxs: [deactivateIx],
204
143
  };
205
144
  }
206
- async function bufferedTransactionData(offrampProgram, serializedReport, recentBlockhash, bufferId, opts) {
207
- const provider = offrampProgram.provider;
208
- const [bufferAddress] = PublicKey.findProgramAddressSync([Buffer.from('execution_report_buffer'), bufferId, provider.wallet.publicKey.toBuffer()], offrampProgram.programId);
209
- const [configPDA] = PublicKey.findProgramAddressSync([Buffer.from('config')], offrampProgram.programId);
210
- console.log(`The bufferID is ${hexlify(bufferId)}, and the PDA address for the buffer is ${bufferAddress.toString()}\nIf this buffering process is aborted, remember to cleanUp the account to recover locked rent.`);
145
+ async function bufferedTransactionData(payer, offramp, serializedReport, bufferId, { logger = console, clearLeftoverAccounts, } = {}) {
146
+ const [bufferAddress] = PublicKey.findProgramAddressSync([Buffer.from('execution_report_buffer'), bufferId, payer.toBuffer()], offramp.programId);
147
+ const [configPDA] = PublicKey.findProgramAddressSync([Buffer.from('config')], offramp.programId);
148
+ logger.info(`The bufferID is ${hexlify(bufferId)}, and the PDA address for the buffer is ${bufferAddress.toString()}\nIf this buffering process is aborted, remember to cleanUp the account to recover locked rent.`);
211
149
  const chunkSize = 800;
212
- const bufferedExecTxs = [];
150
+ const bufferedExecIxs = [];
213
151
  const bufferingAccounts = {
214
152
  executionReportBuffer: bufferAddress,
215
153
  config: configPDA,
216
- authority: provider.wallet.publicKey,
154
+ authority: payer,
217
155
  systemProgram: SystemProgram.programId,
218
156
  };
219
- if (opts?.clearLeftoverAccounts) {
220
- const clearTx = await offrampProgram.methods
157
+ if (clearLeftoverAccounts) {
158
+ bufferedExecIxs.push(await offramp.methods
221
159
  .closeExecutionReportBuffer(bufferId)
222
160
  .accounts(bufferingAccounts)
223
- .transaction();
224
- bufferedExecTxs.push([
225
- 'buffering[clear]',
226
- toVersionedTransaction(clearTx, provider.wallet.publicKey, recentBlockhash),
227
- ]);
161
+ .instruction());
228
162
  }
229
163
  const numChunks = Math.ceil(serializedReport.length / chunkSize);
230
164
  for (let i = 0; i < serializedReport.length; i += chunkSize) {
231
165
  const end = Math.min(i + chunkSize, serializedReport.length);
232
166
  const chunk = serializedReport.subarray(i, end);
233
- const appendTx = await offrampProgram.methods
167
+ bufferedExecIxs.push(await offramp.methods
234
168
  .bufferExecutionReport(bufferId, serializedReport.length, chunk, i / chunkSize, numChunks)
235
169
  .accounts(bufferingAccounts)
236
- .transaction();
237
- bufferedExecTxs.push([
238
- `buffering[${i / chunkSize}=${end - i}B]`,
239
- toVersionedTransaction(appendTx, provider.wallet.publicKey, recentBlockhash),
240
- ]);
170
+ .instruction());
241
171
  }
242
- return bufferedExecTxs;
243
- }
244
- function toVersionedTransaction(input, payerKey, recentBlockhash, addressLookupTableAccounts) {
245
- const instructions = Array.isArray(input) ? input : input.instructions;
246
- const message = new TransactionMessage({ payerKey, recentBlockhash, instructions });
247
- return new VersionedTransaction(message.compileToV0Message(addressLookupTableAccounts));
172
+ return bufferedExecIxs;
248
173
  }
249
- async function getManuallyExecuteInputs({ execReport, offrampProgram, transmitter, bufferId, }) {
174
+ async function getManuallyExecuteInputs({ payer, offramp, execReport, bufferId, ...ctx }) {
250
175
  const executionReport = prepareExecutionReport(execReport);
251
176
  const messageAccountMetas = execReport.message.accounts.map((acc, index) => {
252
177
  const bitmap = BigInt(execReport.message.accountIsWritableBitmap);
@@ -263,7 +188,6 @@ async function getManuallyExecuteInputs({ execReport, offrampProgram, transmitte
263
188
  isSigner: false,
264
189
  isWritable: false,
265
190
  };
266
- console.debug('Message receiver:', execReport.message.receiver);
267
191
  // Prepend receiver to messaging accounts
268
192
  const messagingAccounts = execReport.message.receiver !== PublicKey.default.toBase58()
269
193
  ? [receiverAccountMeta, ...messageAccountMetas]
@@ -281,15 +205,16 @@ async function getManuallyExecuteInputs({ execReport, offrampProgram, transmitte
281
205
  },
282
206
  }));
283
207
  const { accounts, addressLookupTableAccounts: addressLookupTables, tokenIndexes, } = await autoDeriveExecutionAccounts({
284
- offrampProgram,
208
+ offramp,
285
209
  originalSender: bytesToBuffer(execReport.message.sender),
286
- transmitter: new PublicKey(transmitter),
210
+ payer,
287
211
  messagingAccounts,
288
212
  sourceChainSelector: execReport.message.header.sourceChainSelector,
289
213
  tokenTransferAndOffchainData,
290
214
  merkleRoot: bytesToBuffer(execReport.merkleRoot),
291
215
  bufferId,
292
216
  tokenReceiver: new PublicKey(execReport.message.tokenReceiver),
217
+ ...ctx,
293
218
  });
294
219
  return {
295
220
  executionReport,
@@ -330,17 +255,17 @@ function prepareExecutionReport({ message, offchainTokenData, proofs, }) {
330
255
  proofs: proofs.map((p) => Array.from(getDataBytes(p))),
331
256
  };
332
257
  }
333
- async function autoDeriveExecutionAccounts({ offrampProgram, originalSender, transmitter, messagingAccounts, sourceChainSelector, tokenTransferAndOffchainData, merkleRoot, tokenReceiver, bufferId, }) {
258
+ async function autoDeriveExecutionAccounts({ offramp, originalSender, payer, messagingAccounts, sourceChainSelector, tokenTransferAndOffchainData, merkleRoot, tokenReceiver, bufferId, logger = console, }) {
334
259
  const derivedAccounts = [];
335
260
  const lookupTables = [];
336
261
  const tokenIndices = [];
337
262
  let askWith = [];
338
263
  let stage = 'Start';
339
264
  let tokenIndex = 0;
340
- const [configPDA] = PublicKey.findProgramAddressSync([Buffer.from('config')], offrampProgram.programId);
265
+ const [configPDA] = PublicKey.findProgramAddressSync([Buffer.from('config')], offramp.programId);
341
266
  while (true) {
342
267
  const params = {
343
- executeCaller: transmitter,
268
+ executeCaller: payer,
344
269
  messageAccounts: messagingAccounts,
345
270
  sourceChainSelector: new BN(sourceChainSelector.toString()),
346
271
  originalSender: originalSender,
@@ -359,10 +284,8 @@ async function autoDeriveExecutionAccounts({ offrampProgram, originalSender, tra
359
284
  data: Buffer.from([]), // omit offchain token data
360
285
  }));
361
286
  }
362
- // copy of Program which avoids signing every simulation
363
- const readOnlyProgram = new Program(offrampProgram.idl, offrampProgram.programId, simulationProvider(offrampProgram.provider.connection, transmitter));
364
287
  // Execute as a view call to get the response
365
- const response = (await readOnlyProgram.methods
288
+ const response = (await offramp.methods
366
289
  .deriveAccountsExecute(params, stage)
367
290
  .accounts({
368
291
  config: configPDA,
@@ -370,8 +293,8 @@ async function autoDeriveExecutionAccounts({ offrampProgram, originalSender, tra
370
293
  .remainingAccounts(askWith)
371
294
  .view()
372
295
  .catch((error) => {
373
- console.error('Error deriving accounts:', error);
374
- console.error('Params:', params);
296
+ logger.error('Error deriving accounts:', error);
297
+ logger.error('Params:', params);
375
298
  throw error;
376
299
  }));
377
300
  // Check if we're at the start of a token transfer
@@ -382,7 +305,7 @@ async function autoDeriveExecutionAccounts({ offrampProgram, originalSender, tra
382
305
  }
383
306
  // Update token index
384
307
  tokenIndex += response.accountsToSave.length;
385
- console.debug('After stage', stage, 'tokenIndices', tokenIndices, 'nextTokenIndex', tokenIndex);
308
+ logger.debug('After stage', stage, 'tokenIndices', tokenIndices, 'nextTokenIndex', tokenIndex);
386
309
  // Collect the derived accounts
387
310
  for (const meta of response.accountsToSave) {
388
311
  derivedAccounts.push({
@@ -405,9 +328,9 @@ async function autoDeriveExecutionAccounts({ offrampProgram, originalSender, tra
405
328
  }
406
329
  stage = response.nextStage;
407
330
  }
408
- console.debug('Resulting derived accounts:', derivedAccounts);
409
- console.debug('Resulting derived address lookup tables:', lookupTables);
410
- console.debug('Resulting derived token indexes:', tokenIndices);
331
+ logger.debug('Resulting derived accounts:', derivedAccounts);
332
+ logger.debug('Resulting derived address lookup tables:', lookupTables);
333
+ logger.debug('Resulting derived token indexes:', tokenIndices);
411
334
  return {
412
335
  accounts: derivedAccounts,
413
336
  addressLookupTableAccounts: lookupTables,