@recoillink/aleo-sdk 0.0.0-stage → 45.0.1

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 (259) hide show
  1. package/LICENSE.md +193 -0
  2. package/README.md +56 -2
  3. package/dist/artifacts.d.ts +14 -0
  4. package/dist/artifacts.d.ts.map +1 -0
  5. package/dist/artifacts.js +23 -0
  6. package/dist/artifacts.js.map +1 -0
  7. package/dist/clients/base.d.ts +27 -0
  8. package/dist/clients/base.d.ts.map +1 -0
  9. package/dist/clients/base.js +105 -0
  10. package/dist/clients/base.js.map +1 -0
  11. package/dist/clients/protocol.d.ts +26 -0
  12. package/dist/clients/protocol.d.ts.map +1 -0
  13. package/dist/clients/protocol.js +104 -0
  14. package/dist/clients/protocol.js.map +1 -0
  15. package/dist/clients/provider.d.ts +42 -0
  16. package/dist/clients/provider.d.ts.map +1 -0
  17. package/dist/clients/provider.js +460 -0
  18. package/dist/clients/provider.js.map +1 -0
  19. package/dist/clients/provider.node.d.ts +7 -0
  20. package/dist/clients/provider.node.d.ts.map +1 -0
  21. package/dist/clients/provider.node.js +20 -0
  22. package/dist/clients/provider.node.js.map +1 -0
  23. package/dist/clients/signer.d.ts +32 -0
  24. package/dist/clients/signer.d.ts.map +1 -0
  25. package/dist/clients/signer.js +137 -0
  26. package/dist/clients/signer.js.map +1 -0
  27. package/dist/constants.d.ts +8 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/constants.js +8 -0
  30. package/dist/constants.js.map +1 -0
  31. package/dist/hook/base.d.ts +19 -0
  32. package/dist/hook/base.d.ts.map +1 -0
  33. package/dist/hook/base.js +29 -0
  34. package/dist/hook/base.js.map +1 -0
  35. package/dist/hook/hook-artifact-manager.d.ts +25 -0
  36. package/dist/hook/hook-artifact-manager.d.ts.map +1 -0
  37. package/dist/hook/hook-artifact-manager.js +62 -0
  38. package/dist/hook/hook-artifact-manager.js.map +1 -0
  39. package/dist/hook/hook-query.d.ts +44 -0
  40. package/dist/hook/hook-query.d.ts.map +1 -0
  41. package/dist/hook/hook-query.js +103 -0
  42. package/dist/hook/hook-query.js.map +1 -0
  43. package/dist/hook/hook-tx.d.ts +46 -0
  44. package/dist/hook/hook-tx.d.ts.map +1 -0
  45. package/dist/hook/hook-tx.js +89 -0
  46. package/dist/hook/hook-tx.js.map +1 -0
  47. package/dist/hook/igp-hook.d.ts +21 -0
  48. package/dist/hook/igp-hook.d.ts.map +1 -0
  49. package/dist/hook/igp-hook.js +145 -0
  50. package/dist/hook/igp-hook.js.map +1 -0
  51. package/dist/hook/merkle-tree-hook.d.ts +21 -0
  52. package/dist/hook/merkle-tree-hook.d.ts.map +1 -0
  53. package/dist/hook/merkle-tree-hook.js +58 -0
  54. package/dist/hook/merkle-tree-hook.js.map +1 -0
  55. package/dist/index.d.ts +15 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +14 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/ism/base.d.ts +15 -0
  60. package/dist/ism/base.d.ts.map +1 -0
  61. package/dist/ism/base.js +25 -0
  62. package/dist/ism/base.js.map +1 -0
  63. package/dist/ism/ism-artifact-manager.d.ts +12 -0
  64. package/dist/ism/ism-artifact-manager.d.ts.map +1 -0
  65. package/dist/ism/ism-artifact-manager.js +62 -0
  66. package/dist/ism/ism-artifact-manager.js.map +1 -0
  67. package/dist/ism/ism-query.d.ts +51 -0
  68. package/dist/ism/ism-query.d.ts.map +1 -0
  69. package/dist/ism/ism-query.js +155 -0
  70. package/dist/ism/ism-query.js.map +1 -0
  71. package/dist/ism/ism-tx.d.ts +14 -0
  72. package/dist/ism/ism-tx.d.ts.map +1 -0
  73. package/dist/ism/ism-tx.js +77 -0
  74. package/dist/ism/ism-tx.js.map +1 -0
  75. package/dist/ism/multisig-ism.d.ts +20 -0
  76. package/dist/ism/multisig-ism.d.ts.map +1 -0
  77. package/dist/ism/multisig-ism.js +56 -0
  78. package/dist/ism/multisig-ism.js.map +1 -0
  79. package/dist/ism/routing-ism.d.ts +20 -0
  80. package/dist/ism/routing-ism.d.ts.map +1 -0
  81. package/dist/ism/routing-ism.js +108 -0
  82. package/dist/ism/routing-ism.js.map +1 -0
  83. package/dist/ism/test-ism.d.ts +20 -0
  84. package/dist/ism/test-ism.d.ts.map +1 -0
  85. package/dist/ism/test-ism.js +50 -0
  86. package/dist/ism/test-ism.js.map +1 -0
  87. package/dist/mailbox/mailbox-artifact-manager.d.ts +21 -0
  88. package/dist/mailbox/mailbox-artifact-manager.d.ts.map +1 -0
  89. package/dist/mailbox/mailbox-artifact-manager.js +36 -0
  90. package/dist/mailbox/mailbox-artifact-manager.js.map +1 -0
  91. package/dist/mailbox/mailbox-query.d.ts +12 -0
  92. package/dist/mailbox/mailbox-query.d.ts.map +1 -0
  93. package/dist/mailbox/mailbox-query.js +33 -0
  94. package/dist/mailbox/mailbox-query.js.map +1 -0
  95. package/dist/mailbox/mailbox-tx.d.ts +42 -0
  96. package/dist/mailbox/mailbox-tx.d.ts.map +1 -0
  97. package/dist/mailbox/mailbox-tx.js +94 -0
  98. package/dist/mailbox/mailbox-tx.js.map +1 -0
  99. package/dist/mailbox/mailbox.d.ts +29 -0
  100. package/dist/mailbox/mailbox.d.ts.map +1 -0
  101. package/dist/mailbox/mailbox.js +165 -0
  102. package/dist/mailbox/mailbox.js.map +1 -0
  103. package/dist/programs.d.ts +3 -0
  104. package/dist/programs.d.ts.map +1 -0
  105. package/dist/programs.js +14 -0
  106. package/dist/programs.js.map +1 -0
  107. package/dist/runtime/mainnet.d.ts +3 -0
  108. package/dist/runtime/mainnet.d.ts.map +1 -0
  109. package/dist/runtime/mainnet.js +5 -0
  110. package/dist/runtime/mainnet.js.map +1 -0
  111. package/dist/runtime/provider.d.ts +10 -0
  112. package/dist/runtime/provider.d.ts.map +1 -0
  113. package/dist/runtime/provider.js +18 -0
  114. package/dist/runtime/provider.js.map +1 -0
  115. package/dist/runtime/provider.test.d.ts +2 -0
  116. package/dist/runtime/provider.test.d.ts.map +1 -0
  117. package/dist/runtime/provider.test.js +45 -0
  118. package/dist/runtime/provider.test.js.map +1 -0
  119. package/dist/runtime/testnet.d.ts +3 -0
  120. package/dist/runtime/testnet.d.ts.map +1 -0
  121. package/dist/runtime/testnet.js +8 -0
  122. package/dist/runtime/testnet.js.map +1 -0
  123. package/dist/runtime.d.ts +5 -0
  124. package/dist/runtime.d.ts.map +1 -0
  125. package/dist/runtime.js +4 -0
  126. package/dist/runtime.js.map +1 -0
  127. package/dist/testing/constants.d.ts +58 -0
  128. package/dist/testing/constants.d.ts.map +1 -0
  129. package/dist/testing/constants.js +60 -0
  130. package/dist/testing/constants.js.map +1 -0
  131. package/dist/testing/index.d.ts +4 -0
  132. package/dist/testing/index.d.ts.map +1 -0
  133. package/dist/testing/index.js +7 -0
  134. package/dist/testing/index.js.map +1 -0
  135. package/dist/testing/node.d.ts +10 -0
  136. package/dist/testing/node.d.ts.map +1 -0
  137. package/dist/testing/node.js +39 -0
  138. package/dist/testing/node.js.map +1 -0
  139. package/dist/testing/utils.d.ts +19 -0
  140. package/dist/testing/utils.d.ts.map +1 -0
  141. package/dist/testing/utils.js +23 -0
  142. package/dist/testing/utils.js.map +1 -0
  143. package/dist/tests/5_ism_artifacts.e2e-test.d.ts +2 -0
  144. package/dist/tests/5_ism_artifacts.e2e-test.d.ts.map +1 -0
  145. package/dist/tests/5_ism_artifacts.e2e-test.js +415 -0
  146. package/dist/tests/5_ism_artifacts.e2e-test.js.map +1 -0
  147. package/dist/tests/6_hook_artifacts.e2e-test.d.ts +2 -0
  148. package/dist/tests/6_hook_artifacts.e2e-test.d.ts.map +1 -0
  149. package/dist/tests/6_hook_artifacts.e2e-test.js +306 -0
  150. package/dist/tests/6_hook_artifacts.e2e-test.js.map +1 -0
  151. package/dist/tests/7a_warp_native_artifacts.e2e-test.d.ts +2 -0
  152. package/dist/tests/7a_warp_native_artifacts.e2e-test.d.ts.map +1 -0
  153. package/dist/tests/7a_warp_native_artifacts.e2e-test.js +105 -0
  154. package/dist/tests/7a_warp_native_artifacts.e2e-test.js.map +1 -0
  155. package/dist/tests/7b_warp_collateral_artifacts.e2e-test.d.ts +2 -0
  156. package/dist/tests/7b_warp_collateral_artifacts.e2e-test.d.ts.map +1 -0
  157. package/dist/tests/7b_warp_collateral_artifacts.e2e-test.js +144 -0
  158. package/dist/tests/7b_warp_collateral_artifacts.e2e-test.js.map +1 -0
  159. package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.d.ts +2 -0
  160. package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.d.ts.map +1 -0
  161. package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.js +99 -0
  162. package/dist/tests/7c_warp_synthetic_artifacts.e2e-test.js.map +1 -0
  163. package/dist/tests/8_mailbox_artifacts.e2e-test.d.ts +2 -0
  164. package/dist/tests/8_mailbox_artifacts.e2e-test.d.ts.map +1 -0
  165. package/dist/tests/8_mailbox_artifacts.e2e-test.js +395 -0
  166. package/dist/tests/8_mailbox_artifacts.e2e-test.js.map +1 -0
  167. package/dist/tests/9_validator_announce_artifacts.e2e-test.d.ts +2 -0
  168. package/dist/tests/9_validator_announce_artifacts.e2e-test.d.ts.map +1 -0
  169. package/dist/tests/9_validator_announce_artifacts.e2e-test.js +138 -0
  170. package/dist/tests/9_validator_announce_artifacts.e2e-test.js.map +1 -0
  171. package/dist/tests/e2e-test.setup.d.ts +2 -0
  172. package/dist/tests/e2e-test.setup.d.ts.map +1 -0
  173. package/dist/tests/e2e-test.setup.js +33 -0
  174. package/dist/tests/e2e-test.setup.js.map +1 -0
  175. package/dist/tests/warp-artifact-test-suite.d.ts +34 -0
  176. package/dist/tests/warp-artifact-test-suite.d.ts.map +1 -0
  177. package/dist/tests/warp-artifact-test-suite.js +672 -0
  178. package/dist/tests/warp-artifact-test-suite.js.map +1 -0
  179. package/dist/utils/base-query.d.ts +50 -0
  180. package/dist/utils/base-query.d.ts.map +1 -0
  181. package/dist/utils/base-query.js +72 -0
  182. package/dist/utils/base-query.js.map +1 -0
  183. package/dist/utils/helper.crypto.d.ts +4 -0
  184. package/dist/utils/helper.crypto.d.ts.map +1 -0
  185. package/dist/utils/helper.crypto.js +12 -0
  186. package/dist/utils/helper.crypto.js.map +1 -0
  187. package/dist/utils/helper.d.ts +63 -0
  188. package/dist/utils/helper.d.ts.map +1 -0
  189. package/dist/utils/helper.js +291 -0
  190. package/dist/utils/helper.js.map +1 -0
  191. package/dist/utils/helper.node.d.ts +9 -0
  192. package/dist/utils/helper.node.d.ts.map +1 -0
  193. package/dist/utils/helper.node.js +159 -0
  194. package/dist/utils/helper.node.js.map +1 -0
  195. package/dist/utils/helper.test.d.ts +2 -0
  196. package/dist/utils/helper.test.d.ts.map +1 -0
  197. package/dist/utils/helper.test.js +22 -0
  198. package/dist/utils/helper.test.js.map +1 -0
  199. package/dist/utils/provable.d.ts +4 -0
  200. package/dist/utils/provable.d.ts.map +1 -0
  201. package/dist/utils/provable.js +2 -0
  202. package/dist/utils/provable.js.map +1 -0
  203. package/dist/utils/types.d.ts +104 -0
  204. package/dist/utils/types.d.ts.map +1 -0
  205. package/dist/utils/types.js +64 -0
  206. package/dist/utils/types.js.map +1 -0
  207. package/dist/validator-announce/validator-announce-artifact-manager.d.ts +21 -0
  208. package/dist/validator-announce/validator-announce-artifact-manager.d.ts.map +1 -0
  209. package/dist/validator-announce/validator-announce-artifact-manager.js +27 -0
  210. package/dist/validator-announce/validator-announce-artifact-manager.js.map +1 -0
  211. package/dist/validator-announce/validator-announce-query.d.ts +15 -0
  212. package/dist/validator-announce/validator-announce-query.d.ts.map +1 -0
  213. package/dist/validator-announce/validator-announce-query.js +32 -0
  214. package/dist/validator-announce/validator-announce-query.js.map +1 -0
  215. package/dist/validator-announce/validator-announce-tx.d.ts +11 -0
  216. package/dist/validator-announce/validator-announce-tx.d.ts.map +1 -0
  217. package/dist/validator-announce/validator-announce-tx.js +20 -0
  218. package/dist/validator-announce/validator-announce-tx.js.map +1 -0
  219. package/dist/validator-announce/validator-announce.d.ts +29 -0
  220. package/dist/validator-announce/validator-announce.d.ts.map +1 -0
  221. package/dist/validator-announce/validator-announce.js +71 -0
  222. package/dist/validator-announce/validator-announce.js.map +1 -0
  223. package/dist/warp/collateral-token.d.ts +21 -0
  224. package/dist/warp/collateral-token.d.ts.map +1 -0
  225. package/dist/warp/collateral-token.js +108 -0
  226. package/dist/warp/collateral-token.js.map +1 -0
  227. package/dist/warp/native-token.d.ts +21 -0
  228. package/dist/warp/native-token.d.ts.map +1 -0
  229. package/dist/warp/native-token.js +114 -0
  230. package/dist/warp/native-token.js.map +1 -0
  231. package/dist/warp/provider-query.d.ts +22 -0
  232. package/dist/warp/provider-query.d.ts.map +1 -0
  233. package/dist/warp/provider-query.js +89 -0
  234. package/dist/warp/provider-query.js.map +1 -0
  235. package/dist/warp/synthetic-token.d.ts +21 -0
  236. package/dist/warp/synthetic-token.d.ts.map +1 -0
  237. package/dist/warp/synthetic-token.js +108 -0
  238. package/dist/warp/synthetic-token.js.map +1 -0
  239. package/dist/warp/warp-artifact-manager.d.ts +15 -0
  240. package/dist/warp/warp-artifact-manager.d.ts.map +1 -0
  241. package/dist/warp/warp-artifact-manager.js +48 -0
  242. package/dist/warp/warp-artifact-manager.js.map +1 -0
  243. package/dist/warp/warp-query.d.ts +76 -0
  244. package/dist/warp/warp-query.d.ts.map +1 -0
  245. package/dist/warp/warp-query.js +321 -0
  246. package/dist/warp/warp-query.js.map +1 -0
  247. package/dist/warp/warp-query.test.d.ts +2 -0
  248. package/dist/warp/warp-query.test.d.ts.map +1 -0
  249. package/dist/warp/warp-query.test.js +270 -0
  250. package/dist/warp/warp-query.test.js.map +1 -0
  251. package/dist/warp/warp-tx.d.ts +58 -0
  252. package/dist/warp/warp-tx.d.ts.map +1 -0
  253. package/dist/warp/warp-tx.js +229 -0
  254. package/dist/warp/warp-tx.js.map +1 -0
  255. package/dist/warp/warp-tx.test.d.ts +2 -0
  256. package/dist/warp/warp-tx.test.d.ts.map +1 -0
  257. package/dist/warp/warp-tx.test.js +44 -0
  258. package/dist/warp/warp-tx.test.js.map +1 -0
  259. package/package.json +91 -3
@@ -0,0 +1,137 @@
1
+ import { TokenType } from '@recoillink/provider-sdk/warp';
2
+ import { assert, isNullish, retryAsync } from '@recoillink/utils';
3
+ import { getFileOverrideProgramId, loadProgramsInDeployOrder, } from '../utils/helper.node.js';
4
+ import { RETRY_ATTEMPTS, RETRY_DELAY_MS, SUFFIX_LENGTH_LONG, getProgramSuffix, } from '../utils/helper.js';
5
+ import { AleoProvider } from './provider.node.js';
6
+ export class AleoSigner extends AleoProvider {
7
+ static WARP_SUFFIX_ALREADY_DEPLOYED_ERROR = 'already deployed, please choose another suffix';
8
+ programManager;
9
+ static async connectWithSigner(metadata, privateKey) {
10
+ assert(!isNullish(metadata.chainId), `chainId not defined in chain metadata`);
11
+ const rpcUrls = (metadata.rpcUrls ?? []).map((rpc) => rpc.http);
12
+ return new AleoSigner(rpcUrls, metadata, privateKey);
13
+ }
14
+ constructor(rpcUrls, chainMetadata, privateKey) {
15
+ super(rpcUrls, chainMetadata.chainId, chainMetadata);
16
+ this.programManager = this.getProgramManager(privateKey);
17
+ }
18
+ async getIsmManager() {
19
+ // Use the configured ISM manager program ID (from env or default)
20
+ const ismManagerProgramId = this.ismManager;
21
+ // Check if it's already deployed
22
+ const isDeployed = await this.isProgramDeployed(ismManagerProgramId);
23
+ if (!isDeployed) {
24
+ const suffix = getProgramSuffix(ismManagerProgramId);
25
+ await this.deployProgram('ism_manager', suffix);
26
+ }
27
+ return ismManagerProgramId;
28
+ }
29
+ async isProgramDeployed(programId) {
30
+ try {
31
+ await this.aleoClient.getProgram(programId);
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ isProgramAlreadyExistsError(err, programId) {
39
+ return (err instanceof Error &&
40
+ err.message.includes('already exists on the network') &&
41
+ err.message.includes(programId));
42
+ }
43
+ async getWarpTokenSuffix(tokenType, preferredSuffix, maxAttempts = 20) {
44
+ if (tokenType === TokenType.native) {
45
+ return 'credits';
46
+ }
47
+ // If a file override is set, validate the override program isn't already deployed
48
+ const warpProgram = tokenType === TokenType.collateral ? 'hyp_collateral' : 'hyp_synthetic';
49
+ const overrideProgramId = getFileOverrideProgramId(warpProgram);
50
+ if (overrideProgramId) {
51
+ const isDeployed = await this.isProgramDeployed(overrideProgramId);
52
+ assert(!isDeployed, `${overrideProgramId} ${AleoSigner.WARP_SUFFIX_ALREADY_DEPLOYED_ERROR}`);
53
+ return ''; // suffix unused — program name comes from the override file
54
+ }
55
+ const configuredSuffix = preferredSuffix || this.warpSuffix;
56
+ if (configuredSuffix) {
57
+ const tokenProgramId = `${this.prefix}_warp_token_${configuredSuffix}.aleo`;
58
+ const isAlreadyDeployed = await this.isProgramDeployed(tokenProgramId);
59
+ assert(!isAlreadyDeployed, `Warp route with suffix ${configuredSuffix} ${AleoSigner.WARP_SUFFIX_ALREADY_DEPLOYED_ERROR}`);
60
+ return configuredSuffix;
61
+ }
62
+ for (let i = 0; i < maxAttempts; i++) {
63
+ const suffix = this.generateSuffix(SUFFIX_LENGTH_LONG);
64
+ const tokenProgramId = `${this.prefix}_warp_token_${suffix}.aleo`;
65
+ if (!(await this.isProgramDeployed(tokenProgramId))) {
66
+ return suffix;
67
+ }
68
+ }
69
+ throw new Error(`Could not find an unused suffix for ${tokenType} after ${maxAttempts} attempts`);
70
+ }
71
+ async deployProgram(programName, coreSuffix, warpSuffix) {
72
+ const programs = loadProgramsInDeployOrder(this.prefix, programName, coreSuffix, warpSuffix);
73
+ for (const { id, program } of programs) {
74
+ if (await this.isProgramDeployed(id)) {
75
+ continue;
76
+ }
77
+ try {
78
+ const tx = this.skipProofs
79
+ ? await this.programManager.buildDevnodeDeploymentTransaction({
80
+ program,
81
+ priorityFee: 0,
82
+ privateFee: false,
83
+ })
84
+ : await this.programManager.buildDeploymentTransaction(program, 0, false, undefined, undefined, undefined);
85
+ const txId = await this.programManager.networkClient.submitTransaction(tx);
86
+ await this.aleoClient.waitForTransactionConfirmation(txId);
87
+ }
88
+ catch (err) {
89
+ if (this.isProgramAlreadyExistsError(err, id)) {
90
+ continue;
91
+ }
92
+ throw err;
93
+ }
94
+ }
95
+ return programs.reduce((acc, p) => ({ ...acc, [p.name]: p.id }), {});
96
+ }
97
+ getSignerAddress() {
98
+ return this.programManager.account.address().to_string();
99
+ }
100
+ getNetworkPrefix() {
101
+ return this.prefix;
102
+ }
103
+ /**
104
+ * Get the hook manager program ID for a given mailbox suffix.
105
+ * Deploys the hook_manager program if it's not already deployed.
106
+ *
107
+ * @param suffix - The mailbox suffix
108
+ * @returns The hook manager program ID
109
+ */
110
+ async getHookManager(suffix) {
111
+ const programs = await this.deployProgram('hook_manager', suffix);
112
+ const hookManagerProgramId = programs['hook_manager'];
113
+ assert(hookManagerProgramId, `hook_manager program not deployed`);
114
+ return hookManagerProgramId;
115
+ }
116
+ supportsTransactionBatching() {
117
+ return false;
118
+ }
119
+ async transactionToPrintableJson(transaction) {
120
+ return transaction;
121
+ }
122
+ async sendAndConfirmTransaction(transaction) {
123
+ const tx = this.skipProofs
124
+ ? await this.programManager.buildDevnodeExecutionTransaction(transaction)
125
+ : await this.programManager.buildExecutionTransaction(transaction);
126
+ const txId = await retryAsync(() => this.programManager.networkClient.submitTransaction(tx), RETRY_ATTEMPTS, RETRY_DELAY_MS);
127
+ const receipt = await this.aleoClient.waitForTransactionConfirmation(txId);
128
+ return {
129
+ ...receipt,
130
+ transactionHash: receipt.transaction.id,
131
+ };
132
+ }
133
+ async sendAndConfirmBatchTransactions(_transactions) {
134
+ throw new Error(`${AleoSigner.name} does not support transaction batching`);
135
+ }
136
+ }
137
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/clients/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU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AC;IACf,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,WAA4B;QAE5B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC7B,WAA4B;QAE5B,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU;YACxB,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,gCAAgC,CAAC,WAAW,CAAC;YACzE,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;QAErE,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,iBAAiB,CAAC,EAAE,CAAC,EAC7D,cAAc,EACd,cAAc,CACf,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,8BAA8B,CAAC,IAAI,CAAC,CAAC;QAE3E,OAAO;YACL,GAAG,OAAO;YACV,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,+BAA+B,CACnC,aAAgC;QAEhC,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,wCAAwC,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export declare const ALEO_NULL_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
2
+ export declare const ALEO_NATIVE_DENOM = "credits";
3
+ export declare const AleoNetworkId: {
4
+ readonly MAINNET: 0;
5
+ readonly TESTNET: 1;
6
+ };
7
+ export type AleoNetworkId = (typeof AleoNetworkId)[keyof typeof AleoNetworkId];
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,oEACqC,CAAC;AACpE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAG3C,eAAO,MAAM,aAAa;aACxB,OAAO,EAAE,CAAC;aACV,OAAO,EAAE,CAAC;CACF,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export const ALEO_NULL_ADDRESS = 'aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc';
2
+ export const ALEO_NATIVE_DENOM = 'credits';
3
+ // CAST: Preserve literal IDs so AleoNetworkId remains the 0 | 1 union.
4
+ export const AleoNetworkId = {
5
+ MAINNET: 0,
6
+ TESTNET: 1,
7
+ };
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAC5B,iEAAiE,CAAC;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,uEAAuE;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;CACF,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type AnyAleoNetworkClient } from '../clients/base.js';
2
+ /**
3
+ * Get the newly created hook address after hook creation transaction.
4
+ * This should be called AFTER the hook creation transaction has been confirmed.
5
+ *
6
+ * @param aleoClient - The Aleo network client
7
+ * @param hookManagerProgramId - The hook manager program ID
8
+ * @param nonce - The nonce captured before hook creation
9
+ * @returns The full hook address (e.g., "hook_manager_xxx.aleo/aleo1...")
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const expectedNonce = await getNewContractExpectedNonce(client, hookManagerProgramId);
14
+ * const receipt = await signer.sendAndConfirmTransaction(createHookTx);
15
+ * const hookAddress = await getNewHookAddress(client, hookManagerProgramId, expectedNonce);
16
+ * ```
17
+ */
18
+ export declare function getNewHookAddress(aleoClient: AnyAleoNetworkClient, hookManagerProgramId: string, nonce: string): Promise<string>;
19
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/hook/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,oBAAoB,EAChC,oBAAoB,EAAE,MAAM,EAC5B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
@@ -0,0 +1,29 @@
1
+ import { retryAsync } from '@recoillink/utils';
2
+ import { RETRY_ATTEMPTS, RETRY_DELAY_MS } from '../utils/helper.js';
3
+ /**
4
+ * Get the newly created hook address after hook creation transaction.
5
+ * This should be called AFTER the hook creation transaction has been confirmed.
6
+ *
7
+ * @param aleoClient - The Aleo network client
8
+ * @param hookManagerProgramId - The hook manager program ID
9
+ * @param nonce - The nonce captured before hook creation
10
+ * @returns The full hook address (e.g., "hook_manager_xxx.aleo/aleo1...")
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const expectedNonce = await getNewContractExpectedNonce(client, hookManagerProgramId);
15
+ * const receipt = await signer.sendAndConfirmTransaction(createHookTx);
16
+ * const hookAddress = await getNewHookAddress(client, hookManagerProgramId, expectedNonce);
17
+ * ```
18
+ */
19
+ export async function getNewHookAddress(aleoClient, hookManagerProgramId, nonce) {
20
+ const hookAddressRaw = await retryAsync(async () => {
21
+ const result = await aleoClient.getProgramMappingValue(hookManagerProgramId, 'hook_addresses', nonce);
22
+ if (result === null) {
23
+ throw new Error(`could not read hook address with nonce ${nonce} from hook_manager ${hookManagerProgramId}`);
24
+ }
25
+ return result;
26
+ }, RETRY_ATTEMPTS, RETRY_DELAY_MS);
27
+ return `${hookManagerProgramId}/${hookAddressRaw}`;
28
+ }
29
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/hook/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAgC,EAChC,oBAA4B,EAC5B,KAAa;IAEb,MAAM,cAAc,GAAG,MAAM,UAAU,CACrC,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,sBAAsB,CACpD,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,CACN,CAAC;QACF,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,0CAA0C,KAAK,sBAAsB,oBAAoB,EAAE,CAC5F,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,cAAc,EACd,cAAc,CACf,CAAC;IAEF,OAAO,GAAG,oBAAoB,IAAI,cAAc,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type ArtifactReader, type ArtifactWriter } from '@recoillink/provider-sdk/artifact';
2
+ import { type DeployedHookAddress, type DeployedHookArtifact, type HookType, type IRawHookArtifactManager, type RawHookArtifactConfigs } from '@recoillink/provider-sdk/hook';
3
+ import { type AnyAleoNetworkClient } from '../clients/base.js';
4
+ import { type AleoSigner } from '../clients/signer.js';
5
+ /**
6
+ * Aleo Hook Artifact Manager implementing IRawHookArtifactManager.
7
+ *
8
+ * This manager:
9
+ * - Provides factory methods for creating type-specific hook readers and writers
10
+ * - Supports IGP and MerkleTree hook types
11
+ * - Automatically detects hook type when reading deployed hooks
12
+ *
13
+ * Design: The mailbox address is optional at construction and only validated
14
+ * when creating writers for deployment. This allows the manager to be used
15
+ * for read-only operations without requiring deployment context.
16
+ */
17
+ export declare class AleoHookArtifactManager implements IRawHookArtifactManager {
18
+ private readonly aleoClient;
19
+ private readonly mailboxAddress?;
20
+ constructor(aleoClient: AnyAleoNetworkClient, mailboxAddress?: string | undefined);
21
+ readHook(address: string): Promise<DeployedHookArtifact>;
22
+ createReader<T extends HookType>(type: T): ArtifactReader<RawHookArtifactConfigs[T], DeployedHookAddress>;
23
+ createWriter<T extends HookType>(type: T, signer: AleoSigner): ArtifactWriter<RawHookArtifactConfigs[T], DeployedHookAddress>;
24
+ }
25
+ //# sourceMappingURL=hook-artifact-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-artifact-manager.d.ts","sourceRoot":"","sources":["../../src/hook/hook-artifact-manager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAG5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,YAAW,uBAAuB;IAEnE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAFlC,YACmB,UAAU,EAAE,oBAAoB,EAChC,cAAc,CAAC,EAAE,MAAM,YAAA,EACtC;IAEE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAe7D;IAED,YAAY,CAAC,CAAC,SAAS,QAAQ,EAC7B,IAAI,EAAE,CAAC,GACN,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAkBhE;IAED,YAAY,CAAC,CAAC,SAAS,QAAQ,EAC7B,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,UAAU,GACjB,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAqBhE;CACF"}
@@ -0,0 +1,62 @@
1
+ import { AltVM } from '@recoillink/provider-sdk';
2
+ import { altVmHookTypeToProviderHookType, throwUnsupportedHookType, } from '@recoillink/provider-sdk/hook';
3
+ import { assert } from '@recoillink/utils';
4
+ import { getHookType } from './hook-query.js';
5
+ import { AleoIgpHookReader, AleoIgpHookWriter } from './igp-hook.js';
6
+ import { AleoMerkleTreeHookReader, AleoMerkleTreeHookWriter, } from './merkle-tree-hook.js';
7
+ /**
8
+ * Aleo Hook Artifact Manager implementing IRawHookArtifactManager.
9
+ *
10
+ * This manager:
11
+ * - Provides factory methods for creating type-specific hook readers and writers
12
+ * - Supports IGP and MerkleTree hook types
13
+ * - Automatically detects hook type when reading deployed hooks
14
+ *
15
+ * Design: The mailbox address is optional at construction and only validated
16
+ * when creating writers for deployment. This allows the manager to be used
17
+ * for read-only operations without requiring deployment context.
18
+ */
19
+ export class AleoHookArtifactManager {
20
+ aleoClient;
21
+ mailboxAddress;
22
+ constructor(aleoClient, mailboxAddress) {
23
+ this.aleoClient = aleoClient;
24
+ this.mailboxAddress = mailboxAddress;
25
+ }
26
+ async readHook(address) {
27
+ // Detect hook type first
28
+ const aleoHookType = await getHookType(this.aleoClient, address);
29
+ if (aleoHookType === AltVM.HookType.CUSTOM ||
30
+ aleoHookType === AltVM.HookType.PAUSABLE) {
31
+ return throwUnsupportedHookType(aleoHookType, 'Aleo');
32
+ }
33
+ // Get the appropriate reader and read the hook
34
+ const reader = this.createReader(altVmHookTypeToProviderHookType(aleoHookType));
35
+ return reader.read(address);
36
+ }
37
+ createReader(type) {
38
+ const readers = {
39
+ [AltVM.HookType.MERKLE_TREE]: () => new AleoMerkleTreeHookReader(this.aleoClient),
40
+ [AltVM.HookType.INTERCHAIN_GAS_PAYMASTER]: () => new AleoIgpHookReader(this.aleoClient),
41
+ };
42
+ const reader = readers[type];
43
+ if (!reader) {
44
+ return throwUnsupportedHookType(type, 'Aleo');
45
+ }
46
+ return reader();
47
+ }
48
+ createWriter(type, signer) {
49
+ const mailboxAddress = this.mailboxAddress;
50
+ assert(mailboxAddress, 'mailbox address required for hook deployment');
51
+ const writers = {
52
+ [AltVM.HookType.MERKLE_TREE]: () => new AleoMerkleTreeHookWriter(this.aleoClient, signer, mailboxAddress),
53
+ [AltVM.HookType.INTERCHAIN_GAS_PAYMASTER]: () => new AleoIgpHookWriter(this.aleoClient, signer, mailboxAddress),
54
+ };
55
+ const writer = writers[type];
56
+ if (!writer) {
57
+ return throwUnsupportedHookType(type, 'Aleo');
58
+ }
59
+ return writer();
60
+ }
61
+ }
62
+ //# sourceMappingURL=hook-artifact-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-artifact-manager.js","sourceRoot":"","sources":["../../src/hook/hook-artifact-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAKjD,OAAO,EAML,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,uBAAuB;IAEf,UAAU;IACV,cAAc;IAFjC,YACmB,UAAgC,EAChC,cAAuB;0BADvB,UAAU;8BACV,cAAc;IAC9B,CAAC;IAEJ,KAAK,CAAC,QAAQ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AU,EAAE,MAAM,EAAE,cAAc,CAAC;YACvE,CAAC,KAAK,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,GAAG,EAAE,CAC9C,IAAI,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC;SACjE,CAAC;QAEF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,44 @@
1
+ import { AltVM } from '@recoillink/provider-sdk';
2
+ import { type AnyAleoNetworkClient } from '../clients/base.js';
3
+ import { AleoHookType } from '../utils/types.js';
4
+ /**
5
+ * Query the hook type for a given hook address.
6
+ *
7
+ * @param aleoClient - The Aleo network client
8
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
9
+ * @returns The hook type
10
+ */
11
+ export declare function getHookType(aleoClient: AnyAleoNetworkClient, hookAddress: string): Promise<AltVM.HookType>;
12
+ /**
13
+ * Query the configuration for a MerkleTree hook.
14
+ *
15
+ * @param aleoClient - The Aleo network client
16
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
17
+ * @returns The MerkleTree hook configuration
18
+ */
19
+ export declare function getMerkleTreeHookConfig(aleoClient: AnyAleoNetworkClient, hookAddress: string): Promise<{
20
+ type: AleoHookType.MERKLE_TREE;
21
+ address: string;
22
+ }>;
23
+ /**
24
+ * Query the configuration for an IGP (Interchain Gas Paymaster) hook.
25
+ *
26
+ * @param aleoClient - The Aleo network client
27
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
28
+ * @returns The IGP hook configuration with owner and destination gas configs
29
+ */
30
+ export declare function getIgpHookConfig(aleoClient: AnyAleoNetworkClient, hookAddress: string): Promise<{
31
+ type: AleoHookType.INTERCHAIN_GAS_PAYMASTER;
32
+ address: string;
33
+ owner: string;
34
+ destinationGasConfigs: {
35
+ [domainId: string]: {
36
+ gasOracle: {
37
+ tokenExchangeRate: string;
38
+ gasPrice: string;
39
+ };
40
+ gasOverhead: string;
41
+ };
42
+ };
43
+ }>;
44
+ //# sourceMappingURL=hook-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-query.d.ts","sourceRoot":"","sources":["../../src/hook/hook-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGjD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiBjD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,oBAAoB,EAChC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAqCzB;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,oBAAoB,EAChC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IACT,IAAI,EAAE,YAAY,CAAC,WAAW,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAYD;AASD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,oBAAoB,EAChC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IACT,IAAI,EAAE,YAAY,CAAC,wBAAwB,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE;QACrB,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,SAAS,EAAE;gBACT,iBAAiB,EAAE,MAAM,CAAC;gBAC1B,QAAQ,EAAE,MAAM,CAAC;aAClB,CAAC;YACF,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;KACH,CAAC;CACH,CAAC,CA+ED"}
@@ -0,0 +1,103 @@
1
+ import { AltVM } from '@recoillink/provider-sdk';
2
+ import { assert } from '@recoillink/utils';
3
+ import { queryMappingValue, tryQueryMappingValue, } from '../utils/base-query.js';
4
+ import { fromAleoAddress } from '../utils/helper.js';
5
+ import { AleoHookType } from '../utils/types.js';
6
+ /**
7
+ * Type guard to check if a number is a valid AleoHookType
8
+ */
9
+ function isAleoHookType(maybeHookType) {
10
+ switch (maybeHookType) {
11
+ case AleoHookType.CUSTOM:
12
+ case AleoHookType.MERKLE_TREE:
13
+ case AleoHookType.INTERCHAIN_GAS_PAYMASTER:
14
+ case AleoHookType.PAUSABLE:
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ /**
20
+ * Query the hook type for a given hook address.
21
+ *
22
+ * @param aleoClient - The Aleo network client
23
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
24
+ * @returns The hook type
25
+ */
26
+ export async function getHookType(aleoClient, hookAddress) {
27
+ const { address, programId } = fromAleoAddress(hookAddress);
28
+ const result = await queryMappingValue(aleoClient, programId, 'hooks', address, (raw) => {
29
+ assert(typeof raw === 'number', `Expected hook type to be a number but got ${typeof raw}`);
30
+ return raw;
31
+ });
32
+ assert(isAleoHookType(result), `Unknown hook type ${result} for address: ${hookAddress}`);
33
+ switch (result) {
34
+ case AleoHookType.CUSTOM:
35
+ return AltVM.HookType.CUSTOM;
36
+ case AleoHookType.MERKLE_TREE:
37
+ return AltVM.HookType.MERKLE_TREE;
38
+ case AleoHookType.INTERCHAIN_GAS_PAYMASTER:
39
+ return AltVM.HookType.INTERCHAIN_GAS_PAYMASTER;
40
+ case AleoHookType.PAUSABLE:
41
+ return AltVM.HookType.PAUSABLE;
42
+ default:
43
+ throw new Error(`Unknown hook type ${result} for address: ${hookAddress}`);
44
+ }
45
+ }
46
+ /**
47
+ * Query the configuration for a MerkleTree hook.
48
+ *
49
+ * @param aleoClient - The Aleo network client
50
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
51
+ * @returns The MerkleTree hook configuration
52
+ */
53
+ export async function getMerkleTreeHookConfig(aleoClient, hookAddress) {
54
+ const hookType = await getHookType(aleoClient, hookAddress);
55
+ assert(hookType === AltVM.HookType.MERKLE_TREE, `Expected MerkleTree hook but got ${hookType} at address ${hookAddress}`);
56
+ return {
57
+ type: AleoHookType.MERKLE_TREE,
58
+ address: hookAddress,
59
+ };
60
+ }
61
+ /**
62
+ * Query the configuration for an IGP (Interchain Gas Paymaster) hook.
63
+ *
64
+ * @param aleoClient - The Aleo network client
65
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
66
+ * @returns The IGP hook configuration with owner and destination gas configs
67
+ */
68
+ export async function getIgpHookConfig(aleoClient, hookAddress) {
69
+ const hookType = await getHookType(aleoClient, hookAddress);
70
+ assert(hookType === AltVM.HookType.INTERCHAIN_GAS_PAYMASTER, `Expected IGP hook but got ${hookType} at address ${hookAddress}`);
71
+ const { programId, address } = fromAleoAddress(hookAddress);
72
+ const destinationGasConfigs = {};
73
+ const igpData = await queryMappingValue(aleoClient, programId, 'igps', address, (raw) => {
74
+ const igpData = raw;
75
+ assert(igpData?.hook_owner, `Invalid IGP data structure for hook ${hookAddress}, expected object with hook_owner field`);
76
+ return igpData;
77
+ });
78
+ const owner = igpData.hook_owner;
79
+ const gasConfigLength = await tryQueryMappingValue(aleoClient, programId, 'destination_gas_config_length', address, (raw) => raw);
80
+ for (let i = 0; i < (gasConfigLength || 0); i++) {
81
+ const gasConfigKey = await aleoClient.getProgramMappingPlaintext(programId, 'destination_gas_config_iter', `{hook:${address},index:${i}u32}`);
82
+ const destinationGasConfig = await tryQueryMappingValue(aleoClient, programId, 'destination_gas_configs', gasConfigKey.toString(), (raw) => raw);
83
+ // This is necessary because `destination_gas_config_iter` maintains keys for all destination domain entries,
84
+ // including those from domains that have already been removed. When a domain is
85
+ // deleted from the Destination Gas Configs, its key remains in the map and `destination_gas_configs` simply returns null.
86
+ if (!destinationGasConfig)
87
+ continue;
88
+ destinationGasConfigs[gasConfigKey.toObject().destination] = {
89
+ gasOracle: {
90
+ tokenExchangeRate: destinationGasConfig.exchange_rate.toString(),
91
+ gasPrice: destinationGasConfig.gas_price.toString(),
92
+ },
93
+ gasOverhead: destinationGasConfig.gas_overhead.toString(),
94
+ };
95
+ }
96
+ return {
97
+ type: AleoHookType.INTERCHAIN_GAS_PAYMASTER,
98
+ address: hookAddress,
99
+ owner,
100
+ destinationGasConfigs,
101
+ };
102
+ }
103
+ //# sourceMappingURL=hook-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-query.js","sourceRoot":"","sources":["../../src/hook/hook-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,SAAS,cAAc,CAAC,aAAqB;IAC3C,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,YAAY,CAAC,MAAM,CAAC;QACzB,KAAK,YAAY,CAAC,WAAW,CAAC;QAC9B,KAAK,YAAY,CAAC,wBAAwB,CAAC;QAC3C,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,UAAgC,EAChC,WAAmB;IAEnB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE5D,MAAM,MAAM,GAAG,MAAM,iBAAiB,CACpC,UAAU,EACV,SAAS,EAC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CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,GAAG;YAC3D,SAAS,EAAE;gBACT,iBAAiB,EAAE,oBAAoB,CAAC,aAAa,CAAC,QAAQ,EAAE;gBAChE,QAAQ,EAAE,oBAAoB,CAAC,SAAS,CAAC,QAAQ,EAAE;aACpD;YACD,WAAW,EAAE,oBAAoB,CAAC,YAAY,CAAC,QAAQ,EAAE;SAC1D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,YAAY,CAAC,wBAAwB;QAC3C,OAAO,EAAE,WAAW;QACpB,KAAK;QACL,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { type AleoTransaction } from '../utils/types.js';
2
+ /**
3
+ * Build transaction to create a MerkleTree hook
4
+ *
5
+ * @param hookManagerProgramId - The hook manager program ID
6
+ * @param dispatchProxyProgramId - The dispatch proxy program ID
7
+ * @returns The transaction object
8
+ */
9
+ export declare function getCreateMerkleTreeHookTx(hookManagerProgramId: string, dispatchProxyProgramId: string): AleoTransaction;
10
+ /**
11
+ * Build transaction to create an IGP (InterchainGasPaymaster) hook
12
+ *
13
+ * @param hookManagerProgramId - The hook manager program ID
14
+ * @returns The transaction object
15
+ */
16
+ export declare function getCreateIgpHookTx(hookManagerProgramId: string): AleoTransaction;
17
+ /**
18
+ * Build transaction to set IGP hook owner
19
+ *
20
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
21
+ * @param newOwner - The new owner address
22
+ * @returns The transaction object
23
+ */
24
+ export declare function getSetIgpHookOwnerTx(hookAddress: string, newOwner: string): AleoTransaction;
25
+ /**
26
+ * Build transaction to set destination gas configuration
27
+ *
28
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
29
+ * @param gasConfig - The gas configuration for the destination
30
+ * @returns The transaction object
31
+ */
32
+ export declare function getSetDestinationGasConfigTx(hookAddress: string, gasConfig: {
33
+ remoteDomainId: number;
34
+ gasOverhead: string;
35
+ tokenExchangeRate: string;
36
+ gasPrice: string;
37
+ }): AleoTransaction;
38
+ /**
39
+ * Build transaction to remove destination gas configuration
40
+ *
41
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
42
+ * @param remoteDomainId - The remote domain ID to remove
43
+ * @returns The transaction object
44
+ */
45
+ export declare function getRemoveDestinationGasConfigTx(hookAddress: string, remoteDomainId: number): AleoTransaction;
46
+ //# sourceMappingURL=hook-tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-tx.d.ts","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,sBAAsB,EAAE,MAAM,GAC7B,eAAe,CAQjB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,oBAAoB,EAAE,MAAM,GAC3B,eAAe,CAQjB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,eAAe,CAUjB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE;IACT,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB,GACA,eAAe,CAcjB;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,eAAe,CAUjB"}
@@ -0,0 +1,89 @@
1
+ import { getAddressFromProgramId } from '../utils/helper.crypto.js';
2
+ import { fromAleoAddress } from '../utils/helper.js';
3
+ /**
4
+ * Build transaction to create a MerkleTree hook
5
+ *
6
+ * @param hookManagerProgramId - The hook manager program ID
7
+ * @param dispatchProxyProgramId - The dispatch proxy program ID
8
+ * @returns The transaction object
9
+ */
10
+ export function getCreateMerkleTreeHookTx(hookManagerProgramId, dispatchProxyProgramId) {
11
+ return {
12
+ programName: hookManagerProgramId,
13
+ functionName: 'init_merkle_tree',
14
+ priorityFee: 0,
15
+ privateFee: false,
16
+ inputs: [getAddressFromProgramId(dispatchProxyProgramId)],
17
+ };
18
+ }
19
+ /**
20
+ * Build transaction to create an IGP (InterchainGasPaymaster) hook
21
+ *
22
+ * @param hookManagerProgramId - The hook manager program ID
23
+ * @returns The transaction object
24
+ */
25
+ export function getCreateIgpHookTx(hookManagerProgramId) {
26
+ return {
27
+ programName: hookManagerProgramId,
28
+ functionName: 'init_igp',
29
+ priorityFee: 0,
30
+ privateFee: false,
31
+ inputs: [],
32
+ };
33
+ }
34
+ /**
35
+ * Build transaction to set IGP hook owner
36
+ *
37
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
38
+ * @param newOwner - The new owner address
39
+ * @returns The transaction object
40
+ */
41
+ export function getSetIgpHookOwnerTx(hookAddress, newOwner) {
42
+ const { programId, address } = fromAleoAddress(hookAddress);
43
+ return {
44
+ programName: programId,
45
+ functionName: 'transfer_igp_ownership',
46
+ priorityFee: 0,
47
+ privateFee: false,
48
+ inputs: [address, newOwner],
49
+ };
50
+ }
51
+ /**
52
+ * Build transaction to set destination gas configuration
53
+ *
54
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
55
+ * @param gasConfig - The gas configuration for the destination
56
+ * @returns The transaction object
57
+ */
58
+ export function getSetDestinationGasConfigTx(hookAddress, gasConfig) {
59
+ const { programId, address } = fromAleoAddress(hookAddress);
60
+ return {
61
+ programName: programId,
62
+ functionName: 'set_destination_gas_config',
63
+ priorityFee: 0,
64
+ privateFee: false,
65
+ inputs: [
66
+ address,
67
+ `${gasConfig.remoteDomainId}u32`,
68
+ `{gas_overhead:${gasConfig.gasOverhead}u128,exchange_rate:${gasConfig.tokenExchangeRate}u128,gas_price:${gasConfig.gasPrice}u128}`,
69
+ ],
70
+ };
71
+ }
72
+ /**
73
+ * Build transaction to remove destination gas configuration
74
+ *
75
+ * @param hookAddress - The full hook address (e.g., "hook_manager.aleo/aleo1...")
76
+ * @param remoteDomainId - The remote domain ID to remove
77
+ * @returns The transaction object
78
+ */
79
+ export function getRemoveDestinationGasConfigTx(hookAddress, remoteDomainId) {
80
+ const { programId, address } = fromAleoAddress(hookAddress);
81
+ return {
82
+ programName: programId,
83
+ functionName: 'remove_destination_gas_config',
84
+ priorityFee: 0,
85
+ privateFee: false,
86
+ inputs: [address, `${remoteDomainId}u32`],
87
+ };
88
+ }
89
+ //# sourceMappingURL=hook-tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-tx.js","sourceRoot":"","sources":["../../src/hook/hook-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,oBAA4B,EAC5B,sBAA8B;IAE9B,OAAO;QACL,WAAW,EAAE,oBAAoB;QACjC,YAAY,EAAE,kBAAkB;QAChC,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,oBAA4B;IAE5B,OAAO;QACL,WAAW,EAAE,oBAAoB;QACjC,YAAY,EAAE,UAAU;QACxB,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAmB,EACnB,QAAgB;I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