@chainlink/ccip-sdk 0.91.0 → 0.92.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 (273) hide show
  1. package/README.md +127 -80
  2. package/dist/aptos/hasher.d.ts.map +1 -1
  3. package/dist/aptos/hasher.js +7 -6
  4. package/dist/aptos/hasher.js.map +1 -1
  5. package/dist/aptos/index.d.ts +7 -2
  6. package/dist/aptos/index.d.ts.map +1 -1
  7. package/dist/aptos/index.js +29 -20
  8. package/dist/aptos/index.js.map +1 -1
  9. package/dist/aptos/logs.d.ts +5 -3
  10. package/dist/aptos/logs.d.ts.map +1 -1
  11. package/dist/aptos/logs.js +64 -27
  12. package/dist/aptos/logs.js.map +1 -1
  13. package/dist/aptos/token.d.ts.map +1 -1
  14. package/dist/aptos/token.js +2 -1
  15. package/dist/aptos/token.js.map +1 -1
  16. package/dist/aptos/types.js +6 -6
  17. package/dist/aptos/types.js.map +1 -1
  18. package/dist/chain.d.ts +36 -11
  19. package/dist/chain.d.ts.map +1 -1
  20. package/dist/chain.js +34 -2
  21. package/dist/chain.js.map +1 -1
  22. package/dist/commits.d.ts +2 -3
  23. package/dist/commits.d.ts.map +1 -1
  24. package/dist/commits.js +19 -8
  25. package/dist/commits.js.map +1 -1
  26. package/dist/errors/CCIPError.d.ts +48 -0
  27. package/dist/errors/CCIPError.d.ts.map +1 -0
  28. package/dist/errors/CCIPError.js +65 -0
  29. package/dist/errors/CCIPError.js.map +1 -0
  30. package/dist/errors/codes.d.ts +120 -0
  31. package/dist/errors/codes.d.ts.map +1 -0
  32. package/dist/errors/codes.js +156 -0
  33. package/dist/errors/codes.js.map +1 -0
  34. package/dist/errors/index.d.ts +26 -0
  35. package/dist/errors/index.d.ts.map +1 -0
  36. package/dist/errors/index.js +51 -0
  37. package/dist/errors/index.js.map +1 -0
  38. package/dist/errors/recovery.d.ts +6 -0
  39. package/dist/errors/recovery.d.ts.map +1 -0
  40. package/dist/errors/recovery.js +118 -0
  41. package/dist/errors/recovery.js.map +1 -0
  42. package/dist/errors/specialized.d.ts +637 -0
  43. package/dist/errors/specialized.d.ts.map +1 -0
  44. package/dist/errors/specialized.js +1298 -0
  45. package/dist/errors/specialized.js.map +1 -0
  46. package/dist/errors/utils.d.ts +11 -0
  47. package/dist/errors/utils.d.ts.map +1 -0
  48. package/dist/errors/utils.js +61 -0
  49. package/dist/errors/utils.js.map +1 -0
  50. package/dist/evm/abi/CommitStore_1_5.js +1 -1
  51. package/dist/evm/abi/LockReleaseTokenPool_1_5.js +1 -1
  52. package/dist/evm/abi/OffRamp_1_5.js +1 -1
  53. package/dist/evm/abi/OnRamp_1_5.js +1 -1
  54. package/dist/evm/abi/PriceRegistry_1_2.d.ts +443 -0
  55. package/dist/evm/abi/PriceRegistry_1_2.d.ts.map +1 -0
  56. package/dist/evm/abi/PriceRegistry_1_2.js +439 -0
  57. package/dist/evm/abi/PriceRegistry_1_2.js.map +1 -0
  58. package/dist/evm/const.d.ts +1 -0
  59. package/dist/evm/const.d.ts.map +1 -1
  60. package/dist/evm/const.js +2 -0
  61. package/dist/evm/const.js.map +1 -1
  62. package/dist/evm/hasher.d.ts.map +1 -1
  63. package/dist/evm/hasher.js +7 -6
  64. package/dist/evm/hasher.js.map +1 -1
  65. package/dist/evm/index.d.ts +9 -13
  66. package/dist/evm/index.d.ts.map +1 -1
  67. package/dist/evm/index.js +85 -68
  68. package/dist/evm/index.js.map +1 -1
  69. package/dist/evm/logs.d.ts.map +1 -1
  70. package/dist/evm/logs.js +47 -16
  71. package/dist/evm/logs.js.map +1 -1
  72. package/dist/evm/messages.d.ts +7 -6
  73. package/dist/evm/messages.d.ts.map +1 -1
  74. package/dist/evm/offchain.js +1 -1
  75. package/dist/evm/offchain.js.map +1 -1
  76. package/dist/evm/types.d.ts +10 -0
  77. package/dist/evm/types.d.ts.map +1 -0
  78. package/dist/evm/types.js +2 -0
  79. package/dist/evm/types.js.map +1 -0
  80. package/dist/execution.d.ts.map +1 -1
  81. package/dist/execution.js +9 -5
  82. package/dist/execution.js.map +1 -1
  83. package/dist/extra-args.d.ts.map +1 -1
  84. package/dist/extra-args.js +4 -3
  85. package/dist/extra-args.js.map +1 -1
  86. package/dist/gas.d.ts.map +1 -1
  87. package/dist/gas.js +3 -2
  88. package/dist/gas.js.map +1 -1
  89. package/dist/hasher/hasher.d.ts.map +1 -1
  90. package/dist/hasher/hasher.js +2 -1
  91. package/dist/hasher/hasher.js.map +1 -1
  92. package/dist/hasher/merklemulti.d.ts.map +1 -1
  93. package/dist/hasher/merklemulti.js +9 -8
  94. package/dist/hasher/merklemulti.js.map +1 -1
  95. package/dist/index.d.ts +5 -2
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +6 -2
  98. package/dist/index.js.map +1 -1
  99. package/dist/offchain.d.ts.map +1 -1
  100. package/dist/offchain.js +5 -8
  101. package/dist/offchain.js.map +1 -1
  102. package/dist/requests.d.ts +1 -1
  103. package/dist/requests.d.ts.map +1 -1
  104. package/dist/requests.js +37 -43
  105. package/dist/requests.js.map +1 -1
  106. package/dist/selectors.d.ts.map +1 -1
  107. package/dist/selectors.js +22 -0
  108. package/dist/selectors.js.map +1 -1
  109. package/dist/solana/cleanup.d.ts +2 -2
  110. package/dist/solana/cleanup.d.ts.map +1 -1
  111. package/dist/solana/cleanup.js +2 -3
  112. package/dist/solana/cleanup.js.map +1 -1
  113. package/dist/solana/exec.d.ts.map +1 -1
  114. package/dist/solana/exec.js +12 -12
  115. package/dist/solana/exec.js.map +1 -1
  116. package/dist/solana/hasher.d.ts.map +1 -1
  117. package/dist/solana/hasher.js +6 -5
  118. package/dist/solana/hasher.js.map +1 -1
  119. package/dist/solana/index.d.ts +30 -13
  120. package/dist/solana/index.d.ts.map +1 -1
  121. package/dist/solana/index.js +96 -143
  122. package/dist/solana/index.js.map +1 -1
  123. package/dist/solana/logs.d.ts +15 -0
  124. package/dist/solana/logs.d.ts.map +1 -0
  125. package/dist/solana/logs.js +106 -0
  126. package/dist/solana/logs.js.map +1 -0
  127. package/dist/solana/offchain.d.ts.map +1 -1
  128. package/dist/solana/offchain.js +6 -5
  129. package/dist/solana/offchain.js.map +1 -1
  130. package/dist/solana/patchBorsh.d.ts.map +1 -1
  131. package/dist/solana/patchBorsh.js +3 -2
  132. package/dist/solana/patchBorsh.js.map +1 -1
  133. package/dist/solana/send.d.ts.map +1 -1
  134. package/dist/solana/send.js +8 -7
  135. package/dist/solana/send.js.map +1 -1
  136. package/dist/solana/utils.d.ts +7 -8
  137. package/dist/solana/utils.d.ts.map +1 -1
  138. package/dist/solana/utils.js +23 -11
  139. package/dist/solana/utils.js.map +1 -1
  140. package/dist/sui/discovery.d.ts +18 -0
  141. package/dist/sui/discovery.d.ts.map +1 -0
  142. package/dist/sui/discovery.js +116 -0
  143. package/dist/sui/discovery.js.map +1 -0
  144. package/dist/sui/events.d.ts +36 -0
  145. package/dist/sui/events.d.ts.map +1 -0
  146. package/dist/sui/events.js +179 -0
  147. package/dist/sui/events.js.map +1 -0
  148. package/dist/sui/hasher.d.ts.map +1 -1
  149. package/dist/sui/hasher.js +6 -5
  150. package/dist/sui/hasher.js.map +1 -1
  151. package/dist/sui/index.d.ts +69 -41
  152. package/dist/sui/index.d.ts.map +1 -1
  153. package/dist/sui/index.js +402 -65
  154. package/dist/sui/index.js.map +1 -1
  155. package/dist/sui/manuallyExec/encoder.d.ts +8 -0
  156. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -0
  157. package/dist/sui/manuallyExec/encoder.js +76 -0
  158. package/dist/sui/manuallyExec/encoder.js.map +1 -0
  159. package/dist/sui/manuallyExec/index.d.ts +37 -0
  160. package/dist/sui/manuallyExec/index.d.ts.map +1 -0
  161. package/dist/sui/manuallyExec/index.js +81 -0
  162. package/dist/sui/manuallyExec/index.js.map +1 -0
  163. package/dist/sui/objects.d.ts +46 -0
  164. package/dist/sui/objects.d.ts.map +1 -0
  165. package/dist/sui/objects.js +259 -0
  166. package/dist/sui/objects.js.map +1 -0
  167. package/dist/ton/bindings/offramp.d.ts +48 -0
  168. package/dist/ton/bindings/offramp.d.ts.map +1 -0
  169. package/dist/ton/bindings/offramp.js +63 -0
  170. package/dist/ton/bindings/offramp.js.map +1 -0
  171. package/dist/ton/bindings/onramp.d.ts +40 -0
  172. package/dist/ton/bindings/onramp.d.ts.map +1 -0
  173. package/dist/ton/bindings/onramp.js +51 -0
  174. package/dist/ton/bindings/onramp.js.map +1 -0
  175. package/dist/ton/bindings/router.d.ts +47 -0
  176. package/dist/ton/bindings/router.d.ts.map +1 -0
  177. package/dist/ton/bindings/router.js +51 -0
  178. package/dist/ton/bindings/router.js.map +1 -0
  179. package/dist/ton/exec.d.ts +18 -0
  180. package/dist/ton/exec.d.ts.map +1 -0
  181. package/dist/ton/exec.js +28 -0
  182. package/dist/ton/exec.js.map +1 -0
  183. package/dist/ton/hasher.d.ts +27 -0
  184. package/dist/ton/hasher.d.ts.map +1 -0
  185. package/dist/ton/hasher.js +134 -0
  186. package/dist/ton/hasher.js.map +1 -0
  187. package/dist/ton/index.d.ts +247 -0
  188. package/dist/ton/index.d.ts.map +1 -0
  189. package/dist/ton/index.js +781 -0
  190. package/dist/ton/index.js.map +1 -0
  191. package/dist/ton/logs.d.ts +26 -0
  192. package/dist/ton/logs.d.ts.map +1 -0
  193. package/dist/ton/logs.js +126 -0
  194. package/dist/ton/logs.js.map +1 -0
  195. package/dist/ton/types.d.ts +37 -0
  196. package/dist/ton/types.d.ts.map +1 -0
  197. package/dist/ton/types.js +92 -0
  198. package/dist/ton/types.js.map +1 -0
  199. package/dist/ton/utils.d.ts +67 -0
  200. package/dist/ton/utils.d.ts.map +1 -0
  201. package/dist/ton/utils.js +425 -0
  202. package/dist/ton/utils.js.map +1 -0
  203. package/dist/types.d.ts +4 -2
  204. package/dist/types.d.ts.map +1 -1
  205. package/dist/types.js +1 -0
  206. package/dist/types.js.map +1 -1
  207. package/dist/utils.d.ts +10 -0
  208. package/dist/utils.d.ts.map +1 -1
  209. package/dist/utils.js +52 -17
  210. package/dist/utils.js.map +1 -1
  211. package/package.json +12 -10
  212. package/src/aptos/hasher.ts +10 -6
  213. package/src/aptos/index.ts +50 -31
  214. package/src/aptos/logs.ts +85 -29
  215. package/src/aptos/token.ts +5 -1
  216. package/src/aptos/types.ts +6 -6
  217. package/src/chain.ts +83 -12
  218. package/src/commits.ts +23 -11
  219. package/src/errors/CCIPError.ts +86 -0
  220. package/src/errors/codes.ts +179 -0
  221. package/src/errors/index.ts +175 -0
  222. package/src/errors/recovery.ts +170 -0
  223. package/src/errors/specialized.ts +1655 -0
  224. package/src/errors/utils.ts +73 -0
  225. package/src/evm/abi/CommitStore_1_5.ts +1 -1
  226. package/src/evm/abi/LockReleaseTokenPool_1_5.ts +1 -1
  227. package/src/evm/abi/OffRamp_1_5.ts +1 -1
  228. package/src/evm/abi/OnRamp_1_5.ts +1 -1
  229. package/src/evm/abi/PriceRegistry_1_2.ts +438 -0
  230. package/src/evm/const.ts +2 -0
  231. package/src/evm/hasher.ts +7 -6
  232. package/src/evm/index.ts +104 -86
  233. package/src/evm/logs.ts +64 -16
  234. package/src/evm/messages.ts +14 -14
  235. package/src/evm/offchain.ts +1 -1
  236. package/src/evm/types.ts +11 -0
  237. package/src/execution.ts +13 -9
  238. package/src/extra-args.ts +4 -3
  239. package/src/gas.ts +10 -3
  240. package/src/hasher/hasher.ts +2 -1
  241. package/src/hasher/merklemulti.ts +18 -8
  242. package/src/index.ts +14 -2
  243. package/src/offchain.ts +10 -14
  244. package/src/requests.ts +51 -53
  245. package/src/selectors.ts +23 -0
  246. package/src/solana/cleanup.ts +2 -4
  247. package/src/solana/exec.ts +13 -13
  248. package/src/solana/hasher.ts +9 -5
  249. package/src/solana/index.ts +126 -200
  250. package/src/solana/logs.ts +155 -0
  251. package/src/solana/offchain.ts +10 -7
  252. package/src/solana/patchBorsh.ts +3 -2
  253. package/src/solana/send.ts +14 -7
  254. package/src/solana/utils.ts +31 -17
  255. package/src/sui/discovery.ts +163 -0
  256. package/src/sui/events.ts +328 -0
  257. package/src/sui/hasher.ts +6 -5
  258. package/src/sui/index.ts +528 -80
  259. package/src/sui/manuallyExec/encoder.ts +88 -0
  260. package/src/sui/manuallyExec/index.ts +137 -0
  261. package/src/sui/objects.ts +358 -0
  262. package/src/ton/bindings/offramp.ts +96 -0
  263. package/src/ton/bindings/onramp.ts +72 -0
  264. package/src/ton/bindings/router.ts +65 -0
  265. package/src/ton/exec.ts +44 -0
  266. package/src/ton/hasher.ts +184 -0
  267. package/src/ton/index.ts +989 -0
  268. package/src/ton/logs.ts +157 -0
  269. package/src/ton/types.ts +143 -0
  270. package/src/ton/utils.ts +514 -0
  271. package/src/types.ts +6 -2
  272. package/src/utils.ts +58 -23
  273. package/tsconfig.json +2 -1
@@ -0,0 +1,8 @@
1
+ import type { CCIPMessage, CCIPVersion, ExecutionReport } from '../../types.ts';
2
+ /**
3
+ * Serializes an execution report for Sui manual execution.
4
+ * @param executionReport - The execution report to serialize.
5
+ * @returns Serialized execution report as Uint8Array.
6
+ */
7
+ export declare function serializeExecutionReport(executionReport: ExecutionReport<CCIPMessage<typeof CCIPVersion.V1_6>>): Uint8Array;
8
+ //# sourceMappingURL=encoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../src/sui/manuallyExec/encoder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AA4B/E;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,CAAC,WAAW,CAAC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,GACrE,UAAU,CA+CZ"}
@@ -0,0 +1,76 @@
1
+ import { bcs } from '@mysten/sui/bcs';
2
+ import { CCIPMessageInvalidError } from "../../errors/specialized.js";
3
+ import { decodeExtraArgs } from "../../extra-args.js";
4
+ import { bytesToBuffer, getAddressBytes, getDataBytes, networkInfo } from "../../utils.js";
5
+ const Any2SuiTokenTransferBCS = bcs.struct('Any2SuiTokenTransfer', {
6
+ source_pool_address: bcs.vector(bcs.u8()),
7
+ dest_token_address: bcs.Address,
8
+ dest_gas_amount: bcs.u32(),
9
+ extra_data: bcs.vector(bcs.u8()),
10
+ amount: bcs.u256(),
11
+ });
12
+ const ExecutionReportBCS = bcs.struct('ExecutionReport', {
13
+ source_chain_selector: bcs.u64(),
14
+ message_id: bcs.fixedArray(32, bcs.u8()),
15
+ header_source_chain_selector: bcs.u64(),
16
+ dest_chain_selector: bcs.u64(),
17
+ sequence_number: bcs.u64(),
18
+ nonce: bcs.u64(),
19
+ sender: bcs.vector(bcs.u8()),
20
+ data: bcs.vector(bcs.u8()),
21
+ receiver: bcs.Address,
22
+ gas_limit: bcs.u256(),
23
+ token_receiver: bcs.Address,
24
+ token_amounts: bcs.vector(Any2SuiTokenTransferBCS),
25
+ offchain_token_data: bcs.vector(bcs.vector(bcs.u8())),
26
+ proofs: bcs.vector(bcs.fixedArray(32, bcs.u8())),
27
+ });
28
+ /**
29
+ * Serializes an execution report for Sui manual execution.
30
+ * @param executionReport - The execution report to serialize.
31
+ * @returns Serialized execution report as Uint8Array.
32
+ */
33
+ export function serializeExecutionReport(executionReport) {
34
+ const { message, offchainTokenData, proofs } = executionReport;
35
+ if (!message) {
36
+ throw new CCIPMessageInvalidError('Message is undefined in execution report');
37
+ }
38
+ let gasLimit, tokenReceiver;
39
+ if ('receiverObjectIds' in message) {
40
+ ;
41
+ ({ gasLimit, tokenReceiver } = message);
42
+ }
43
+ else {
44
+ const decodedExtraArgs = decodeExtraArgs(message.extraArgs, networkInfo(message.sourceChainSelector).family);
45
+ if (decodedExtraArgs?._tag !== 'SuiExtraArgsV1')
46
+ throw new CCIPMessageInvalidError('Expected Sui extra args');
47
+ ({ gasLimit, tokenReceiver } = decodedExtraArgs);
48
+ }
49
+ const reportData = {
50
+ source_chain_selector: message.sourceChainSelector,
51
+ message_id: Array.from(bytesToBuffer(message.messageId)),
52
+ header_source_chain_selector: message.sourceChainSelector,
53
+ dest_chain_selector: message.destChainSelector,
54
+ sequence_number: message.sequenceNumber,
55
+ nonce: message.nonce,
56
+ sender: Array.from(bytesToBuffer(message.sender)),
57
+ data: Array.from(bytesToBuffer(message.data)),
58
+ receiver: message.receiver,
59
+ gas_limit: gasLimit,
60
+ token_receiver: tokenReceiver,
61
+ token_amounts: message.tokenAmounts.map((token) => ({
62
+ source_pool_address: Array.from(getAddressBytes(token.sourcePoolAddress)),
63
+ dest_token_address: token.destTokenAddress,
64
+ dest_gas_amount: Number(token.destGasAmount || 0n), // Use actual destGasAmount from token data
65
+ extra_data: Array.from(getDataBytes(token.extraData)),
66
+ amount: BigInt(token.amount),
67
+ })),
68
+ // TODO: encode as per CCTP/LBTC TPs, when available
69
+ offchain_token_data: offchainTokenData.map(() => Buffer.from([])),
70
+ proofs: proofs.map((proof) => {
71
+ return Array.from(getDataBytes(proof));
72
+ }),
73
+ };
74
+ return ExecutionReportBCS.serialize(reportData).toBytes();
75
+ }
76
+ //# sourceMappingURL=encoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../src/sui/manuallyExec/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAGrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE1F,MAAM,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC,sBAAsB,EAAE;IACjE,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;IACzC,kBAAkB,EAAE,GAAG,CAAC,OAAO;IAC/B,eAAe,EAAE,GAAG,CAAC,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,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACzE,kBAAkB,EAAE,KAAK,CAAC,gBAAgB;YAC1C,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,2CAA2C;YAC/F,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACrD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;SAC7B,CAAC,CAAC;QACH,oDAAoD;QACpD,mBAAmB,EAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE;YACtC,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;QACxC,CAAC,CAAC;KACH,CAAA;IAED,OAAO,kBAAkB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAA;AAC3D,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import type { ExecutionReport } from '../../types.ts';
3
+ import type { CCIPMessage_V1_6_Sui } from '../types.ts';
4
+ /** Configuration for manually executing a Sui receiver module. */
5
+ export type ManuallyExecuteSuiReceiverConfig = {
6
+ moduleName: string;
7
+ packageId: string;
8
+ };
9
+ /** Configuration for a token pool in manual execution. */
10
+ export type TokenConfig = {
11
+ tokenPoolPackageId: string;
12
+ tokenPoolModule: string;
13
+ tokenType: string;
14
+ administrator: string;
15
+ pendingAdministrator: string;
16
+ tokenPoolTypeProof: string;
17
+ lockOrBurnParams: string[];
18
+ releaseOrMintParams: string[];
19
+ };
20
+ /** Input parameters for building a Sui manual execution transaction. */
21
+ export type SuiManuallyExecuteInput = {
22
+ offrampAddress: string;
23
+ executionReport: ExecutionReport<CCIPMessage_V1_6_Sui>;
24
+ ccipAddress: string;
25
+ ccipObjectRef: string;
26
+ offrampStateObject: string;
27
+ receiverConfig: ManuallyExecuteSuiReceiverConfig;
28
+ tokenConfigs?: TokenConfig[];
29
+ overrideReceiverObjectIds?: string[];
30
+ };
31
+ /**
32
+ * Builds a Sui Programmable Transaction Block for manual CCIP message execution.
33
+ * @param params - Input parameters for building the manual execution transaction.
34
+ * @returns A Transaction object ready to be signed and executed.
35
+ */
36
+ export declare function buildManualExecutionPTB({ offrampAddress, executionReport, ccipAddress, ccipObjectRef, offrampStateObject, receiverConfig, tokenConfigs, overrideReceiverObjectIds, }: SuiManuallyExecuteInput): Transaction;
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sui/manuallyExec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAKtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,kEAAkE;AAClE,MAAM,MAAM,gCAAgC,GAAG;IAC7C,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG;IACxB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAA;CAC9B,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAA;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,cAAc,EAAE,gCAAgC,CAAA;IAChD,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;CACrC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,cAAc,EACd,eAAe,EACf,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,yBAAyB,GAC1B,EAAE,uBAAuB,GAAG,WAAW,CAmFvC"}
@@ -0,0 +1,81 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { serializeExecutionReport } from "./encoder.js";
3
+ import { CCIPMessageInvalidError } from "../../errors/specialized.js";
4
+ import { decodeExtraArgs } from "../../extra-args.js";
5
+ import { networkInfo } from "../../utils.js";
6
+ /**
7
+ * Builds a Sui Programmable Transaction Block for manual CCIP message execution.
8
+ * @param params - Input parameters for building the manual execution transaction.
9
+ * @returns A Transaction object ready to be signed and executed.
10
+ */
11
+ export function buildManualExecutionPTB({ offrampAddress, executionReport, ccipAddress, ccipObjectRef, offrampStateObject, receiverConfig, tokenConfigs, overrideReceiverObjectIds, }) {
12
+ const reportBytes = serializeExecutionReport(executionReport);
13
+ // Create transaction
14
+ const tx = new Transaction();
15
+ // Step 1: Call manually_init_execute to prepare the execution
16
+ const receiverParamsArg = tx.moveCall({
17
+ target: `${offrampAddress}::offramp::manually_init_execute`,
18
+ arguments: [
19
+ tx.object(ccipObjectRef),
20
+ tx.object(offrampStateObject),
21
+ tx.object('0x6'), // Clock object
22
+ tx.pure.vector('u8', Array.from(reportBytes)),
23
+ ],
24
+ });
25
+ // Get the message from the from the report using the offramp helper
26
+ const messageArg = tx.moveCall({
27
+ target: `${ccipAddress}::offramp_state_helper::extract_any2sui_message`,
28
+ arguments: [receiverParamsArg],
29
+ });
30
+ // Process token pool transfers
31
+ if (tokenConfigs && tokenConfigs.length > 0) {
32
+ if (executionReport.message.tokenAmounts.length !== tokenConfigs.length) {
33
+ throw new CCIPMessageInvalidError('Token amounts length does not match token configs length');
34
+ }
35
+ // Process each token transfer
36
+ for (let i = 0; i < tokenConfigs.length; i++) {
37
+ const tokenConfig = tokenConfigs[i];
38
+ tx.moveCall({
39
+ target: `${tokenConfig.tokenPoolPackageId}::${tokenConfig.tokenPoolModule}::release_or_mint`,
40
+ typeArguments: [tokenConfig.tokenType],
41
+ arguments: [
42
+ tx.object(ccipObjectRef), // CCIPObjectRef
43
+ receiverParamsArg, // ReceiverParams (mutable)
44
+ ...tokenConfig.releaseOrMintParams.map((param) => tx.object(param)), // Pool-specific objects (clock, deny_list, token_state, state, etc.)
45
+ ],
46
+ });
47
+ }
48
+ }
49
+ // Decode extraArgs to get receiverObjectIds
50
+ const decodedExtraArgs = decodeExtraArgs(executionReport.message.extraArgs, networkInfo(executionReport.message.destChainSelector).family);
51
+ if (!decodedExtraArgs || decodedExtraArgs._tag !== 'SuiExtraArgsV1') {
52
+ throw new CCIPMessageInvalidError('Expected Sui extra args');
53
+ }
54
+ if (decodedExtraArgs.receiverObjectIds.length === 0) {
55
+ throw new CCIPMessageInvalidError('No receiverObjectIds provided in SUIExtraArgsV1');
56
+ }
57
+ // Call the receiver contract
58
+ tx.moveCall({
59
+ target: `${receiverConfig.packageId}::${receiverConfig.moduleName}::ccip_receive`,
60
+ arguments: [
61
+ tx.pure.vector('u8', Buffer.from(executionReport.message.messageId.slice(2), 'hex')),
62
+ tx.object(ccipObjectRef),
63
+ messageArg,
64
+ // if overrideReceiverObjectIds is provided, use them; otherwise, use the ones from decodedExtraArgs (original message)
65
+ ...(overrideReceiverObjectIds && overrideReceiverObjectIds.length > 0
66
+ ? overrideReceiverObjectIds.map(tx.object)
67
+ : decodedExtraArgs.receiverObjectIds.map(tx.object)),
68
+ ],
69
+ });
70
+ // Step 2: Call finish_execute to complete the execution
71
+ tx.moveCall({
72
+ target: `${offrampAddress}::offramp::finish_execute`,
73
+ arguments: [
74
+ tx.object(ccipObjectRef),
75
+ tx.object(offrampStateObject),
76
+ receiverParamsArg, // ReceiverParams from manually_init_execute
77
+ ],
78
+ });
79
+ return tx;
80
+ }
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sui/manuallyExec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAiC5C;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,cAAc,EACd,eAAe,EACf,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,yBAAyB,GACD;IACxB,MAAM,WAAW,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAA;IAE7D,qBAAqB;IACrB,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAA;IAE5B,8DAA8D;IAC9D,MAAM,iBAAiB,GAAG,EAAE,CAAC,QAAQ,CAAC;QACpC,MAAM,EAAE,GAAG,cAAc,kCAAkC;QAC3D,SAAS,EAAE;YACT,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;YACxB,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC7B,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,eAAe;YACjC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAA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2
+ import type { CCIPMessage, CCIPVersion } from '../types.ts';
3
+ /**
4
+ * Derive a dynamic field object ID using the Sui algorithm
5
+ * This matches the Go implementation in chainlink-sui
6
+ */
7
+ export declare function deriveObjectID(parentAddress: string, keyBytes: Uint8Array): string;
8
+ /**
9
+ * Get the CCIPObjectRef ID for a CCIP package
10
+ */
11
+ export declare function getCcipObjectRef(client: SuiClient, ccipPackageId: string): Promise<string>;
12
+ /**
13
+ * Get the OffRampState object ID for an offramp package
14
+ */
15
+ export declare function getOffRampStateObject(client: SuiClient, offrampPackageId: string): Promise<string>;
16
+ /**
17
+ * Get the receiver module configuration from the receiver registry.
18
+ * @param provider - Sui client
19
+ * @param ccipPackageId - CCIP package ID
20
+ * @param ccipObjectRef - CCIP object reference
21
+ * @param receiverPackageId - Receiver package ID
22
+ * @returns Receiver module name and package ID
23
+ */
24
+ export declare function getReceiverModule(provider: SuiClient, ccipPackageId: string, ccipObjectRef: string, receiverPackageId: string): Promise<{
25
+ moduleName: string;
26
+ packageId: string;
27
+ }>;
28
+ /**
29
+ * Fetch token configurations for the given token amounts.
30
+ * @param client - Sui client
31
+ * @param ccipPackageId - CCIP package ID
32
+ * @param ccipObjectRef - CCIP object reference
33
+ * @param tokenAmounts - Token amounts from CCIP message
34
+ * @returns Array of token configurations
35
+ */
36
+ export declare function fetchTokenConfigs(client: SuiClient, ccipPackageId: string, ccipObjectRef: string, tokenAmounts: CCIPMessage<typeof CCIPVersion.V1_6>['tokenAmounts']): Promise<{
37
+ tokenPoolPackageId: string;
38
+ tokenPoolModule: string;
39
+ tokenType: string;
40
+ administrator: string;
41
+ pendingAdministrator: string;
42
+ tokenPoolTypeProof: string;
43
+ lockOrBurnParams: string[];
44
+ releaseOrMintParams: string[];
45
+ }[]>;
46
+ //# sourceMappingURL=objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/sui/objects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAMnD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,CAsClF;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwChG;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,SAAS,EACjB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,SAAS,EACnB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM;;;GA+C1B;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,WAAW,CAAC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC;;;;;;;;;KA2InE"}
@@ -0,0 +1,259 @@
1
+ import { bcs } from '@mysten/sui/bcs';
2
+ import { Transaction } from '@mysten/sui/transactions';
3
+ import { normalizeSuiAddress } from '@mysten/sui/utils';
4
+ import { blake2b } from '@noble/hashes/blake2';
5
+ import { CCIPDataFormatUnsupportedError } from "../errors/index.js";
6
+ /**
7
+ * Derive a dynamic field object ID using the Sui algorithm
8
+ * This matches the Go implementation in chainlink-sui
9
+ */
10
+ export function deriveObjectID(parentAddress, keyBytes) {
11
+ // Normalize parent address to 32 bytes
12
+ const normalizedParent = normalizeSuiAddress(parentAddress);
13
+ const parentBytes = bcs.Address.serialize(normalizedParent).toBytes();
14
+ // BCS serialize the key (vector<u8>)
15
+ const bcsKeyBytes = bcs.vector(bcs.u8()).serialize(Array.from(keyBytes)).toBytes();
16
+ // Construct TypeTag for DerivedObjectKey<vector<u8>>
17
+ const suiFrameworkAddress = bcs.Address.serialize('0x2').toBytes();
18
+ const typeTagBytes = new Uint8Array([
19
+ 0x07, // TypeTag::Struct
20
+ ...suiFrameworkAddress,
21
+ 0x0e, // module length
22
+ ...new TextEncoder().encode('derived_object'),
23
+ 0x10, // struct name length
24
+ ...new TextEncoder().encode('DerivedObjectKey'),
25
+ 0x01, // type params count
26
+ ...[0x06, 0x01], // vector<u8> TypeTag
27
+ ]);
28
+ // Build the hash input
29
+ const keyLenBytes = new Uint8Array(8);
30
+ new DataView(keyLenBytes.buffer).setBigUint64(0, BigInt(bcsKeyBytes.length), true);
31
+ const hashInput = new Uint8Array([
32
+ 0xf0, // HashingIntentScope::ChildObjectId
33
+ ...parentBytes,
34
+ ...keyLenBytes,
35
+ ...bcsKeyBytes,
36
+ ...typeTagBytes,
37
+ ]);
38
+ // Hash with Blake2b-256
39
+ const hash = blake2b(hashInput, { dkLen: 32 });
40
+ // Convert to address string
41
+ return normalizeSuiAddress('0x' + Buffer.from(hash).toString('hex'));
42
+ }
43
+ /**
44
+ * Get the CCIPObjectRef ID for a CCIP package
45
+ */
46
+ export async function getCcipObjectRef(client, ccipPackageId) {
47
+ // Get the pointer to find the CCIPObject ID
48
+ const pointerResponse = await client.getOwnedObjects({
49
+ owner: ccipPackageId,
50
+ filter: {
51
+ StructType: `${ccipPackageId}::state_object::CCIPObjectRefPointer`,
52
+ },
53
+ });
54
+ if (pointerResponse.data.length === 0) {
55
+ throw new CCIPDataFormatUnsupportedError('No CCIPObjectRefPointer found for the given packageId');
56
+ }
57
+ // Get the pointer object to extract ccip_object_id
58
+ const pointerId = pointerResponse.data[0].data?.objectId;
59
+ if (!pointerId) {
60
+ throw new CCIPDataFormatUnsupportedError('Pointer does not have objectId');
61
+ }
62
+ const pointerObject = await client.getObject({
63
+ id: pointerId,
64
+ options: { showContent: true },
65
+ });
66
+ if (pointerObject.data?.content?.dataType !== 'moveObject') {
67
+ throw new CCIPDataFormatUnsupportedError('Pointer object is not a Move object');
68
+ }
69
+ const ccipObjectId = pointerObject.data.content.fields['ccip_object_id'];
70
+ if (!ccipObjectId) {
71
+ throw new CCIPDataFormatUnsupportedError('Could not find ccip_object_id in pointer');
72
+ }
73
+ // Derive the CCIPObjectRef ID from the parent CCIPObject ID
74
+ return deriveObjectID(ccipObjectId, new TextEncoder().encode('CCIPObjectRef'));
75
+ }
76
+ /**
77
+ * Get the OffRampState object ID for an offramp package
78
+ */
79
+ export async function getOffRampStateObject(client, offrampPackageId) {
80
+ const offrampPointerResponse = await client.getOwnedObjects({
81
+ owner: offrampPackageId,
82
+ filter: {
83
+ StructType: `${offrampPackageId}::offramp::OffRampStatePointer`,
84
+ },
85
+ });
86
+ if (offrampPointerResponse.data.length === 0) {
87
+ throw new CCIPDataFormatUnsupportedError('No OffRampStatePointer found for the given offramp package');
88
+ }
89
+ const offrampPointerId = offrampPointerResponse.data[0].data?.objectId;
90
+ if (!offrampPointerId) {
91
+ throw new CCIPDataFormatUnsupportedError('OffRampStatePointer does not have a valid objectId');
92
+ }
93
+ const offrampPointerObject = await client.getObject({
94
+ id: offrampPointerId,
95
+ options: { showContent: true },
96
+ });
97
+ if (offrampPointerObject.data?.content?.dataType !== 'moveObject') {
98
+ throw new CCIPDataFormatUnsupportedError('OffRamp pointer object is not a Move object');
99
+ }
100
+ const offrampObjectId = offrampPointerObject.data.content.fields['off_ramp_object_id'];
101
+ if (!offrampObjectId) {
102
+ throw new CCIPDataFormatUnsupportedError('Could not find off_ramp_object_id in pointer');
103
+ }
104
+ // Derive the OffRampState ID from the parent OffRamp Object ID
105
+ return deriveObjectID(offrampObjectId, new TextEncoder().encode('OffRampState'));
106
+ }
107
+ /**
108
+ * Get the receiver module configuration from the receiver registry.
109
+ * @param provider - Sui client
110
+ * @param ccipPackageId - CCIP package ID
111
+ * @param ccipObjectRef - CCIP object reference
112
+ * @param receiverPackageId - Receiver package ID
113
+ * @returns Receiver module name and package ID
114
+ */
115
+ export async function getReceiverModule(provider, ccipPackageId, ccipObjectRef, receiverPackageId) {
116
+ // Call get_receiver_config from receiver_registry contract
117
+ const tx = new Transaction();
118
+ tx.moveCall({
119
+ target: `${ccipPackageId}::receiver_registry::get_receiver_config`,
120
+ arguments: [tx.object(ccipObjectRef), tx.pure.address(receiverPackageId)],
121
+ });
122
+ const result = await provider.devInspectTransactionBlock({
123
+ transactionBlock: tx,
124
+ sender: '0x0000000000000000000000000000000000000000000000000000000000000000',
125
+ });
126
+ if (result.error) {
127
+ throw new CCIPDataFormatUnsupportedError(`Failed to call get_receiver_config: ${result.error}`);
128
+ }
129
+ if (!result.results || result.results.length === 0) {
130
+ throw new CCIPDataFormatUnsupportedError('No results returned from get_receiver_config');
131
+ }
132
+ const returnValues = result.results[0]?.returnValues;
133
+ if (!returnValues || returnValues.length === 0) {
134
+ throw new CCIPDataFormatUnsupportedError('No return values from get_receiver_config');
135
+ }
136
+ // Decode the ReceiverConfig struct
137
+ // ReceiverConfig has two fields: module_name (String) and proof_typename (ascii::String)
138
+ // The struct is returned as a BCS-encoded byte array
139
+ const receiverConfigBytes = returnValues[0][0];
140
+ // Parse the struct:
141
+ // First field is module_name (String = vector<u8> with length prefix)
142
+ let offset = 0;
143
+ const moduleNameLength = receiverConfigBytes[offset];
144
+ offset += 1;
145
+ const moduleName = new TextDecoder().decode(new Uint8Array(receiverConfigBytes.slice(offset, offset + moduleNameLength)));
146
+ return {
147
+ moduleName,
148
+ packageId: receiverPackageId,
149
+ };
150
+ }
151
+ /**
152
+ * Fetch token configurations for the given token amounts.
153
+ * @param client - Sui client
154
+ * @param ccipPackageId - CCIP package ID
155
+ * @param ccipObjectRef - CCIP object reference
156
+ * @param tokenAmounts - Token amounts from CCIP message
157
+ * @returns Array of token configurations
158
+ */
159
+ export async function fetchTokenConfigs(client, ccipPackageId, ccipObjectRef, tokenAmounts) {
160
+ if (tokenAmounts.length === 0) {
161
+ return [];
162
+ }
163
+ const tokenConfigs = [];
164
+ const tokenAddresses = [
165
+ ...new Set(tokenAmounts.map((token) => token.destTokenAddress).filter((addr) => addr && addr !== '0x0')),
166
+ ];
167
+ // Fetch token config for each unique token address
168
+ for (const tokenAddress of tokenAddresses) {
169
+ const tx = new Transaction();
170
+ // Call get_token_config_struct from token_admin_registry
171
+ tx.moveCall({
172
+ target: `${ccipPackageId}::token_admin_registry::get_token_config_struct`,
173
+ arguments: [tx.object(ccipObjectRef), tx.pure.address(tokenAddress)],
174
+ });
175
+ const result = await client.devInspectTransactionBlock({
176
+ transactionBlock: tx,
177
+ sender: '0x0000000000000000000000000000000000000000000000000000000000000000',
178
+ });
179
+ if (result.error) {
180
+ throw new CCIPDataFormatUnsupportedError(`Failed to fetch token config for ${tokenAddress}: ${result.error}`);
181
+ }
182
+ if (!result.results || result.results.length === 0) {
183
+ throw new CCIPDataFormatUnsupportedError(`No results returned from get_token_config_struct for ${tokenAddress}`);
184
+ }
185
+ const returnValues = result.results[0]?.returnValues;
186
+ if (!returnValues || returnValues.length === 0) {
187
+ throw new CCIPDataFormatUnsupportedError(`No return values from get_token_config_struct for ${tokenAddress}`);
188
+ }
189
+ // Parse the TokenConfig struct from BCS-encoded bytes
190
+ const configBytes = returnValues[0][0];
191
+ // TokenConfig structure (from token_admin_registry.go):
192
+ // - TokenPoolPackageId (address = 32 bytes)
193
+ // - TokenPoolModule (String = length + bytes)
194
+ // - TokenType (ascii::String = length + bytes)
195
+ // - Administrator (address = 32 bytes)
196
+ // - PendingAdministrator (address = 32 bytes)
197
+ // - TokenPoolTypeProof (ascii::String = length + bytes)
198
+ // - LockOrBurnParams (vector<address> = length + N * 32 bytes)
199
+ // - ReleaseOrMintParams (vector<address> = length + N * 32 bytes)
200
+ let offset = 0;
201
+ // TokenPoolPackageId (32 bytes)
202
+ const tokenPoolPackageIdBytes = configBytes.slice(offset, offset + 32);
203
+ const tokenPoolPackageId = normalizeSuiAddress('0x' + Buffer.from(tokenPoolPackageIdBytes).toString('hex'));
204
+ offset += 32;
205
+ // TokenPoolModule (String)
206
+ const moduleNameLength = configBytes[offset];
207
+ offset += 1;
208
+ const tokenPoolModule = new TextDecoder().decode(new Uint8Array(configBytes.slice(offset, offset + moduleNameLength)));
209
+ offset += moduleNameLength;
210
+ // TokenType (ascii::String)
211
+ const tokenTypeLength = configBytes[offset];
212
+ offset += 1;
213
+ const tokenType = new TextDecoder().decode(new Uint8Array(configBytes.slice(offset, offset + tokenTypeLength)));
214
+ offset += tokenTypeLength;
215
+ // Administrator (32 bytes)
216
+ const administratorBytes = configBytes.slice(offset, offset + 32);
217
+ const administrator = normalizeSuiAddress('0x' + Buffer.from(administratorBytes).toString('hex'));
218
+ offset += 32;
219
+ // PendingAdministrator (32 bytes)
220
+ const pendingAdminBytes = configBytes.slice(offset, offset + 32);
221
+ const pendingAdministrator = normalizeSuiAddress('0x' + Buffer.from(pendingAdminBytes).toString('hex'));
222
+ offset += 32;
223
+ // TokenPoolTypeProof (ascii::String)
224
+ const proofLength = configBytes[offset];
225
+ offset += 1;
226
+ const tokenPoolTypeProof = new TextDecoder().decode(new Uint8Array(configBytes.slice(offset, offset + proofLength)));
227
+ offset += proofLength;
228
+ // LockOrBurnParams (vector<address>)
229
+ const lockOrBurnCount = configBytes[offset];
230
+ offset += 1;
231
+ const lockOrBurnParams = [];
232
+ for (let i = 0; i < lockOrBurnCount; i++) {
233
+ const addrBytes = configBytes.slice(offset, offset + 32);
234
+ lockOrBurnParams.push(normalizeSuiAddress('0x' + Buffer.from(addrBytes).toString('hex')));
235
+ offset += 32;
236
+ }
237
+ // ReleaseOrMintParams (vector<address>)
238
+ const releaseOrMintCount = configBytes[offset];
239
+ offset += 1;
240
+ const releaseOrMintParams = [];
241
+ for (let i = 0; i < releaseOrMintCount; i++) {
242
+ const addrBytes = configBytes.slice(offset, offset + 32);
243
+ releaseOrMintParams.push(normalizeSuiAddress('0x' + Buffer.from(addrBytes).toString('hex')));
244
+ offset += 32;
245
+ }
246
+ tokenConfigs.push({
247
+ tokenPoolPackageId,
248
+ tokenPoolModule,
249
+ tokenType,
250
+ administrator,
251
+ pendingAdministrator,
252
+ tokenPoolTypeProof,
253
+ lockOrBurnParams,
254
+ releaseOrMintParams,
255
+ });
256
+ }
257
+ return tokenConfigs;
258
+ }
259
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.js","sourceRoot":"","sources":["../../src/sui/objects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AAGnE;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB,EAAE,QAAoB;IACxE,uCAAuC;IACvC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAC3D,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAA;IAErE,qCAAqC;IACrC,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;IAElF,qDAAqD;IACrD,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;IAClE,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC;QAClC,IAAI,EAAE,kBAAkB;QACxB,GAAG,mBAAmB;QACtB,IAAI,EAAE,gB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CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACzF,MAAM,IAAI,EAAE,CAAA;QACd,CAAC;QAED,wCAAwC;QACxC,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;QAC9C,MAAM,IAAI,CAAC,CAAA;QACX,MAAM,mBAAmB,GAAa,EAAE,CAAA;QACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,CAAA;YACxD,mBAAmB,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAC5F,MAAM,IAAI,EAAE,CAAA;QACd,CAAC;QAED,YAAY,CAAC,IAAI,CAAC;YAChB,kBAAkB;YAClB,eAAe;YACf,SAAS;YACT,aAAa;YACb,oBAAoB;YACpB,kBAAkB;YAClB,gBAAgB;YAChB,mBAAmB;SACpB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Address, ContractProvider } from '@ton/core';
2
+ /**
3
+ * Configuration for a source chain on the TON OffRamp contract.
4
+ */
5
+ export interface SourceChainConfig {
6
+ router: Address;
7
+ isEnabled: boolean;
8
+ minSeqNr: bigint;
9
+ isRMNVerificationDisabled: boolean;
10
+ onRamp: Buffer;
11
+ }
12
+ /**
13
+ * Dynamic configuration for the OffRamp contract.
14
+ * Contains addresses that can be updated without redeploying the contract.
15
+ */
16
+ export interface DynamicConfig {
17
+ router: Address;
18
+ feeQuoter: Address;
19
+ permissionlessExecutionThresholdSeconds: number;
20
+ }
21
+ /**
22
+ * TON OffRamp contract binding.
23
+ * The OffRamp receives and executes cross-chain messages on the destination (TON) chain.
24
+ */
25
+ export declare class OffRamp {
26
+ readonly address: Address;
27
+ /**
28
+ * Creates a new OffRamp instance.
29
+ * @param address - The OffRamp contract address on TON.
30
+ */
31
+ constructor(address: Address);
32
+ /**
33
+ * Creates an OffRamp instance from a contract address.
34
+ * @param address - The OffRamp contract address on TON.
35
+ * @returns A new OffRamp instance.
36
+ */
37
+ static createFromAddress(address: Address): OffRamp;
38
+ /**
39
+ * Retrieves the source chain configuration for a given chain selector.
40
+ *
41
+ * @param provider - TON contract provider for making RPC calls.
42
+ * @param sourceChainSelector - The CCIP chain selector of the source chain.
43
+ * @returns The source chain configuration.
44
+ * @throws Error with exitCode 266 if the source chain is not enabled.
45
+ */
46
+ getSourceChainConfig(provider: ContractProvider, sourceChainSelector: bigint): Promise<SourceChainConfig>;
47
+ }
48
+ //# sourceMappingURL=offramp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offramp.d.ts","sourceRoot":"","sources":["../../../src/ton/bindings/offramp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,yBAAyB,EAAE,OAAO,CAAA;IAClC,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,uCAAuC,EAAE,MAAM,CAAA;CAChD;AAED;;;GAGG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAEzB;;;OAGG;gBACS,OAAO,EAAE,OAAO;IAI5B;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAInD;;;;;;;OAOG;IACG,oBAAoB,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,iBAAiB,CAAC;CAoC9B"}