@0xsequence/catapult 1.3.17 → 1.5.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 (232) hide show
  1. package/README.md +276 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +1 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/index.d.ts +1 -0
  6. package/dist/commands/index.d.ts.map +1 -1
  7. package/dist/commands/index.js +1 -0
  8. package/dist/commands/index.js.map +1 -1
  9. package/dist/commands/list.d.ts.map +1 -1
  10. package/dist/commands/list.js +12 -0
  11. package/dist/commands/list.js.map +1 -1
  12. package/dist/commands/provenance.d.ts +3 -0
  13. package/dist/commands/provenance.d.ts.map +1 -0
  14. package/dist/commands/provenance.js +138 -0
  15. package/dist/commands/provenance.js.map +1 -0
  16. package/dist/lib/__tests__/deployer.spec.js +118 -1
  17. package/dist/lib/__tests__/deployer.spec.js.map +1 -1
  18. package/dist/lib/__tests__/network-loader.spec.js.map +1 -1
  19. package/dist/lib/__tests__/provenance.spec.d.ts +2 -0
  20. package/dist/lib/__tests__/provenance.spec.d.ts.map +1 -0
  21. package/dist/lib/__tests__/provenance.spec.js +205 -0
  22. package/dist/lib/__tests__/provenance.spec.js.map +1 -0
  23. package/dist/lib/contracts/__tests__/repository.spec.js +243 -0
  24. package/dist/lib/contracts/__tests__/repository.spec.js.map +1 -1
  25. package/dist/lib/contracts/repository.d.ts +9 -1
  26. package/dist/lib/contracts/repository.d.ts.map +1 -1
  27. package/dist/lib/contracts/repository.js +93 -7
  28. package/dist/lib/contracts/repository.js.map +1 -1
  29. package/dist/lib/core/__tests__/assert-action.spec.d.ts +2 -0
  30. package/dist/lib/core/__tests__/assert-action.spec.d.ts.map +1 -0
  31. package/dist/lib/core/__tests__/assert-action.spec.js +377 -0
  32. package/dist/lib/core/__tests__/assert-action.spec.js.map +1 -0
  33. package/dist/lib/core/__tests__/engine.spec.js +80 -0
  34. package/dist/lib/core/__tests__/engine.spec.js.map +1 -1
  35. package/dist/lib/core/__tests__/loader.spec.js +29 -0
  36. package/dist/lib/core/__tests__/loader.spec.js.map +1 -1
  37. package/dist/lib/core/__tests__/resolver.spec.js +405 -0
  38. package/dist/lib/core/__tests__/resolver.spec.js.map +1 -1
  39. package/dist/lib/core/__tests__/sign-actions.spec.d.ts +2 -0
  40. package/dist/lib/core/__tests__/sign-actions.spec.d.ts.map +1 -0
  41. package/dist/lib/core/__tests__/sign-actions.spec.js +128 -0
  42. package/dist/lib/core/__tests__/sign-actions.spec.js.map +1 -0
  43. package/dist/lib/core/__tests__/signer.spec.d.ts +2 -0
  44. package/dist/lib/core/__tests__/signer.spec.d.ts.map +1 -0
  45. package/dist/lib/core/__tests__/signer.spec.js +40 -0
  46. package/dist/lib/core/__tests__/signer.spec.js.map +1 -0
  47. package/dist/lib/core/context.d.ts +3 -2
  48. package/dist/lib/core/context.d.ts.map +1 -1
  49. package/dist/lib/core/context.js +3 -2
  50. package/dist/lib/core/context.js.map +1 -1
  51. package/dist/lib/core/engine.d.ts +4 -0
  52. package/dist/lib/core/engine.d.ts.map +1 -1
  53. package/dist/lib/core/engine.js +206 -0
  54. package/dist/lib/core/engine.js.map +1 -1
  55. package/dist/lib/core/loader.d.ts +1 -0
  56. package/dist/lib/core/loader.d.ts.map +1 -1
  57. package/dist/lib/core/loader.js +6 -1
  58. package/dist/lib/core/loader.js.map +1 -1
  59. package/dist/lib/core/resolver.d.ts +2 -0
  60. package/dist/lib/core/resolver.d.ts.map +1 -1
  61. package/dist/lib/core/resolver.js +89 -0
  62. package/dist/lib/core/resolver.js.map +1 -1
  63. package/dist/lib/core/signer.d.ts +7 -0
  64. package/dist/lib/core/signer.d.ts.map +1 -0
  65. package/dist/lib/core/signer.js +60 -0
  66. package/dist/lib/core/signer.js.map +1 -0
  67. package/dist/lib/deployer.d.ts.map +1 -1
  68. package/dist/lib/deployer.js +21 -4
  69. package/dist/lib/deployer.js.map +1 -1
  70. package/dist/lib/index.d.ts +1 -0
  71. package/dist/lib/index.d.ts.map +1 -1
  72. package/dist/lib/index.js +1 -0
  73. package/dist/lib/index.js.map +1 -1
  74. package/dist/lib/parsers/__tests__/job.spec.js +77 -0
  75. package/dist/lib/parsers/__tests__/job.spec.js.map +1 -1
  76. package/dist/lib/parsers/__tests__/source.spec.d.ts +2 -0
  77. package/dist/lib/parsers/__tests__/source.spec.d.ts.map +1 -0
  78. package/dist/lib/parsers/__tests__/source.spec.js +158 -0
  79. package/dist/lib/parsers/__tests__/source.spec.js.map +1 -0
  80. package/dist/lib/parsers/index.d.ts +1 -0
  81. package/dist/lib/parsers/index.d.ts.map +1 -1
  82. package/dist/lib/parsers/index.js +1 -0
  83. package/dist/lib/parsers/index.js.map +1 -1
  84. package/dist/lib/parsers/job.d.ts.map +1 -1
  85. package/dist/lib/parsers/job.js +11 -0
  86. package/dist/lib/parsers/job.js.map +1 -1
  87. package/dist/lib/parsers/source.d.ts +4 -0
  88. package/dist/lib/parsers/source.d.ts.map +1 -0
  89. package/dist/lib/parsers/source.js +107 -0
  90. package/dist/lib/parsers/source.js.map +1 -0
  91. package/dist/lib/provenance.d.ts +34 -0
  92. package/dist/lib/provenance.d.ts.map +1 -0
  93. package/dist/lib/provenance.js +694 -0
  94. package/dist/lib/provenance.js.map +1 -0
  95. package/dist/lib/types/actions.d.ts +42 -2
  96. package/dist/lib/types/actions.d.ts.map +1 -1
  97. package/dist/lib/types/actions.js +4 -0
  98. package/dist/lib/types/actions.js.map +1 -1
  99. package/dist/lib/types/contracts.d.ts +3 -0
  100. package/dist/lib/types/contracts.d.ts.map +1 -1
  101. package/dist/lib/types/definitions.d.ts +1 -0
  102. package/dist/lib/types/definitions.d.ts.map +1 -1
  103. package/dist/lib/types/index.d.ts +1 -0
  104. package/dist/lib/types/index.d.ts.map +1 -1
  105. package/dist/lib/types/index.js +1 -0
  106. package/dist/lib/types/index.js.map +1 -1
  107. package/dist/lib/types/source.d.ts +26 -0
  108. package/dist/lib/types/source.d.ts.map +1 -0
  109. package/dist/lib/types/source.js +3 -0
  110. package/dist/lib/types/source.js.map +1 -0
  111. package/dist/lib/types/values.d.ts +33 -1
  112. package/dist/lib/types/values.d.ts.map +1 -1
  113. package/package.json +4 -1
  114. package/.eslintrc.json +0 -29
  115. package/.github/workflows/ci.yml +0 -181
  116. package/CONCEPT.md +0 -24
  117. package/contracts/checked-call.huff +0 -65
  118. package/eslint.config.js +0 -48
  119. package/examples/jobs/guards-v1.yaml +0 -17
  120. package/examples/jobs/sequence-seq-0001-patch.yaml +0 -59
  121. package/examples/jobs/sequence-v1.yaml +0 -59
  122. package/examples/templates/sequence-factory-v1.yaml +0 -56
  123. package/jest.config.js +0 -25
  124. package/src/cli.ts +0 -17
  125. package/src/commands/common.ts +0 -61
  126. package/src/commands/dry.ts +0 -209
  127. package/src/commands/etherscan.ts +0 -360
  128. package/src/commands/index.ts +0 -5
  129. package/src/commands/list.ts +0 -249
  130. package/src/commands/run.ts +0 -146
  131. package/src/commands/utils.ts +0 -215
  132. package/src/index.ts +0 -67
  133. package/src/lib/__tests__/deployer-events.spec.ts +0 -338
  134. package/src/lib/__tests__/deployer.spec.ts +0 -2093
  135. package/src/lib/__tests__/network-loader.spec.ts +0 -150
  136. package/src/lib/__tests__/network-selection.spec.ts +0 -41
  137. package/src/lib/__tests__/network-utils.spec.ts +0 -230
  138. package/src/lib/artifacts/__tests__/fixtures/contract1.json +0 -19
  139. package/src/lib/artifacts/__tests__/fixtures/contract2.json +0 -19
  140. package/src/lib/artifacts/__tests__/fixtures/duplicate-name.json +0 -19
  141. package/src/lib/artifacts/__tests__/fixtures/nested/nested-contract.json +0 -18
  142. package/src/lib/artifacts/__tests__/fixtures/not-an-artifact.json +0 -8
  143. package/src/lib/artifacts/__tests__/fixtures/readme.txt +0 -2
  144. package/src/lib/contracts/__tests__/repository.spec.ts +0 -344
  145. package/src/lib/contracts/repository.ts +0 -313
  146. package/src/lib/core/__tests__/context.spec.ts +0 -37
  147. package/src/lib/core/__tests__/engine.spec.ts +0 -1889
  148. package/src/lib/core/__tests__/graph.spec.ts +0 -125
  149. package/src/lib/core/__tests__/json-integration.spec.ts +0 -425
  150. package/src/lib/core/__tests__/loader.spec.ts +0 -334
  151. package/src/lib/core/__tests__/multi-platform-verification.spec.ts +0 -406
  152. package/src/lib/core/__tests__/resolver.spec.ts +0 -2053
  153. package/src/lib/core/__tests__/static-action.spec.ts +0 -172
  154. package/src/lib/core/context.ts +0 -127
  155. package/src/lib/core/engine.ts +0 -1782
  156. package/src/lib/core/graph.ts +0 -252
  157. package/src/lib/core/loader.ts +0 -247
  158. package/src/lib/core/resolver.ts +0 -757
  159. package/src/lib/deployer.ts +0 -981
  160. package/src/lib/events/__tests__/event-system.spec.ts +0 -392
  161. package/src/lib/events/cli-adapter.ts +0 -369
  162. package/src/lib/events/emitter.ts +0 -62
  163. package/src/lib/events/index.ts +0 -3
  164. package/src/lib/events/types.ts +0 -520
  165. package/src/lib/index.ts +0 -14
  166. package/src/lib/network-loader.ts +0 -90
  167. package/src/lib/network-selection.ts +0 -73
  168. package/src/lib/network-utils.ts +0 -64
  169. package/src/lib/parsers/__tests__/buildinfo.spec.ts +0 -122
  170. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-bytecode-buildinfo.json +0 -62
  171. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-json.txt +0 -2
  172. package/src/lib/parsers/__tests__/fixtures/buildinfo/multi-contract-buildinfo.json +0 -89
  173. package/src/lib/parsers/__tests__/fixtures/buildinfo/no-contracts-buildinfo.json +0 -17
  174. package/src/lib/parsers/__tests__/fixtures/buildinfo/simple-buildinfo.json +0 -63
  175. package/src/lib/parsers/__tests__/fixtures/buildinfo/wrong-format.json +0 -4
  176. package/src/lib/parsers/__tests__/job.spec.ts +0 -358
  177. package/src/lib/parsers/__tests__/template.spec.ts +0 -111
  178. package/src/lib/parsers/artifact/__tests__/artifact.spec.ts +0 -117
  179. package/src/lib/parsers/artifact/__tests__/fixtures/empty-bytecode.json +0 -5
  180. package/src/lib/parsers/artifact/__tests__/fixtures/hardhat-artifact.json +0 -67
  181. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-bytecode.json +0 -5
  182. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-json.txt +0 -11
  183. package/src/lib/parsers/artifact/__tests__/fixtures/minimal-artifact.json +0 -5
  184. package/src/lib/parsers/artifact/__tests__/fixtures/missing-abi.json +0 -4
  185. package/src/lib/parsers/artifact/__tests__/fixtures/missing-bytecode.json +0 -11
  186. package/src/lib/parsers/artifact/__tests__/fixtures/missing-contract-name.json +0 -11
  187. package/src/lib/parsers/artifact/__tests__/fixtures/simple-artifact.json +0 -40
  188. package/src/lib/parsers/artifact/__tests__/fixtures/wrong-types.json +0 -7
  189. package/src/lib/parsers/artifact/foundry-1.2.ts +0 -72
  190. package/src/lib/parsers/artifact/index.ts +0 -27
  191. package/src/lib/parsers/artifact/types.ts +0 -9
  192. package/src/lib/parsers/buildinfo.ts +0 -127
  193. package/src/lib/parsers/constants.ts +0 -56
  194. package/src/lib/parsers/index.ts +0 -5
  195. package/src/lib/parsers/job.ts +0 -148
  196. package/src/lib/parsers/template.ts +0 -135
  197. package/src/lib/std/templates/arachnid-deterministic-deployment-proxy.yaml +0 -68
  198. package/src/lib/std/templates/assured-deployment.yaml +0 -46
  199. package/src/lib/std/templates/era-evm-predeploy.yaml +0 -35
  200. package/src/lib/std/templates/erc-2470.yaml +0 -70
  201. package/src/lib/std/templates/min-balance.yaml +0 -35
  202. package/src/lib/std/templates/nano-universal-deployer.yaml +0 -61
  203. package/src/lib/std/templates/raw-erc-2470.yaml +0 -62
  204. package/src/lib/std/templates/raw-nano-universal-deployer.yaml +0 -54
  205. package/src/lib/std/templates/raw-sequence-universal-deployer-2.yaml +0 -52
  206. package/src/lib/std/templates/sequence-universal-deployer-2.yaml +0 -61
  207. package/src/lib/types/__tests__/json-request-action.spec.ts +0 -243
  208. package/src/lib/types/__tests__/read-json-value.spec.ts +0 -278
  209. package/src/lib/types/__tests__/resolve-json-value.spec.ts +0 -769
  210. package/src/lib/types/actions.ts +0 -127
  211. package/src/lib/types/artifacts.ts +0 -21
  212. package/src/lib/types/buildinfo.ts +0 -116
  213. package/src/lib/types/conditions.ts +0 -50
  214. package/src/lib/types/contracts.ts +0 -23
  215. package/src/lib/types/definitions.ts +0 -70
  216. package/src/lib/types/index.ts +0 -8
  217. package/src/lib/types/network.ts +0 -33
  218. package/src/lib/types/project.ts +0 -9
  219. package/src/lib/types/task.ts +0 -9
  220. package/src/lib/types/values.ts +0 -150
  221. package/src/lib/utils/assertion.ts +0 -24
  222. package/src/lib/utils/validation.ts +0 -116
  223. package/src/lib/validation/contract-references.ts +0 -210
  224. package/src/lib/validation/index.ts +0 -1
  225. package/src/lib/verification/__tests__/etherscan.spec.ts +0 -710
  226. package/src/lib/verification/__tests__/sourcify.spec.ts +0 -288
  227. package/src/lib/verification/etherscan.ts +0 -547
  228. package/src/lib/verification/sourcify.ts +0 -248
  229. package/test_validation/artifacts/TestContract.json +0 -9
  230. package/test_validation/jobs/test-missing.yaml +0 -16
  231. package/test_validation/networks.yaml +0 -3
  232. package/tsconfig.json +0 -36
@@ -1,769 +0,0 @@
1
- import { ResolveJsonValue } from "../values";
2
- import { ValueResolver } from "../../core/resolver";
3
- import { ExecutionContext } from "../../core/context";
4
- import { Network } from "../network";
5
- import { ContractRepository } from "../../contracts/repository";
6
-
7
- describe("ResolveJsonValue", () => {
8
- let resolver: ValueResolver;
9
- let context: ExecutionContext;
10
- let mockNetwork: Network;
11
- let mockRegistry: ContractRepository;
12
-
13
- beforeEach(async () => {
14
- resolver = new ValueResolver();
15
- mockRegistry = new ContractRepository();
16
- // Use a mock RPC URL since resolve-json doesn't need network access
17
- const rpcUrl = "http://127.0.0.1:8545";
18
- mockNetwork = {
19
- name: "testnet",
20
- chainId: 999,
21
- rpcUrl,
22
- supports: ["sourcify", "etherscan_v2"],
23
- gasLimit: 10000000,
24
- evmVersion: "cancun",
25
- };
26
- // A dummy private key is fine as these tests don't send transactions
27
- const mockPrivateKey =
28
- "0x0000000000000000000000000000000000000000000000000000000000000001";
29
- context = new ExecutionContext(mockNetwork, mockPrivateKey, mockRegistry);
30
- });
31
-
32
- afterEach(async () => {
33
- // Clean up context to prevent hanging connections
34
- if (context) {
35
- try {
36
- await context.dispose();
37
- } catch (error) {
38
- // Ignore cleanup errors
39
- }
40
- }
41
- });
42
-
43
- describe("type definition", () => {
44
- it("should have correct type structure for basic JSON", () => {
45
- const value: ResolveJsonValue = {
46
- type: "resolve-json",
47
- arguments: { name: "John", age: 30 },
48
- };
49
-
50
- expect(value.type).toBe("resolve-json");
51
- expect(value.arguments).toEqual({ name: "John", age: 30 });
52
- });
53
-
54
- it("should support nested JSON objects", () => {
55
- const value: ResolveJsonValue = {
56
- type: "resolve-json",
57
- arguments: {
58
- user: {
59
- profile: {
60
- name: "Alice",
61
- settings: {
62
- theme: "dark",
63
- notifications: true,
64
- },
65
- },
66
- },
67
- },
68
- };
69
-
70
- expect(value.arguments.user.profile.name).toBe("Alice");
71
- expect(value.arguments.user.profile.settings.theme).toBe("dark");
72
- });
73
-
74
- it("should support arrays in JSON", () => {
75
- const value: ResolveJsonValue = {
76
- type: "resolve-json",
77
- arguments: {
78
- items: ["first", "second", "third"],
79
- numbers: [1, 2, 3, 4, 5],
80
- },
81
- };
82
-
83
- expect(value.arguments.items).toEqual(["first", "second", "third"]);
84
- expect(value.arguments.numbers).toEqual([1, 2, 3, 4, 5]);
85
- });
86
-
87
- it("should support mixed data types", () => {
88
- const value: ResolveJsonValue = {
89
- type: "resolve-json",
90
- arguments: {
91
- string: "hello",
92
- number: 42,
93
- boolean: true,
94
- nullValue: null,
95
- array: [1, "two", false],
96
- object: { nested: "value" },
97
- },
98
- };
99
-
100
- expect(value.arguments.string).toBe("hello");
101
- expect(value.arguments.number).toBe(42);
102
- expect(value.arguments.boolean).toBe(true);
103
- expect(value.arguments.nullValue).toBeNull();
104
- expect(value.arguments.array).toEqual([1, "two", false]);
105
- expect(value.arguments.object.nested).toBe("value");
106
- });
107
- });
108
-
109
- describe("basic resolution", () => {
110
- it("should resolve simple JSON object with primitive values", async () => {
111
- const value: ResolveJsonValue = {
112
- type: "resolve-json",
113
- arguments: { name: "John", age: 30, active: true },
114
- };
115
-
116
- const result = await resolver.resolve(value, context);
117
- expect(result).toEqual({ name: "John", age: 30, active: true });
118
- });
119
-
120
- it("should resolve nested JSON object", async () => {
121
- const value: ResolveJsonValue = {
122
- type: "resolve-json",
123
- arguments: {
124
- user: {
125
- id: 1,
126
- profile: {
127
- name: "Alice",
128
- email: "alice@example.com",
129
- },
130
- },
131
- },
132
- };
133
-
134
- const result = await resolver.resolve(value, context);
135
- expect(result).toEqual({
136
- user: {
137
- id: 1,
138
- profile: {
139
- name: "Alice",
140
- email: "alice@example.com",
141
- },
142
- },
143
- });
144
- });
145
-
146
- it("should resolve array of primitive values", async () => {
147
- const value: ResolveJsonValue = {
148
- type: "resolve-json",
149
- arguments: [1, 2, 3, "four", "five"],
150
- };
151
-
152
- const result = await resolver.resolve(value, context);
153
- expect(result).toEqual([1, 2, 3, "four", "five"]);
154
- });
155
-
156
- it("should resolve array of objects", async () => {
157
- const value: ResolveJsonValue = {
158
- type: "resolve-json",
159
- arguments: [
160
- { id: 1, name: "First" },
161
- { id: 2, name: "Second" },
162
- { id: 3, name: "Third" },
163
- ],
164
- };
165
-
166
- const result = await resolver.resolve(value, context);
167
- expect(result).toEqual([
168
- { id: 1, name: "First" },
169
- { id: 2, name: "Second" },
170
- { id: 3, name: "Third" },
171
- ]);
172
- });
173
-
174
- it("should resolve mixed array with objects and primitives", async () => {
175
- const value: ResolveJsonValue = {
176
- type: "resolve-json",
177
- arguments: [
178
- "string",
179
- { id: 1, value: "object" },
180
- 42,
181
- { nested: { deep: "value" } },
182
- false,
183
- ],
184
- };
185
-
186
- const result = await resolver.resolve(value, context);
187
- expect(result).toEqual([
188
- "string",
189
- { id: 1, value: "object" },
190
- 42,
191
- { nested: { deep: "value" } },
192
- false,
193
- ]);
194
- });
195
- });
196
-
197
- describe("template variable resolution", () => {
198
- it("should resolve template variables in JSON object", async () => {
199
- context.setOutput("userName", "Alice");
200
- context.setOutput("userAge", "25");
201
-
202
- const value: ResolveJsonValue = {
203
- type: "resolve-json",
204
- arguments: {
205
- name: "{{userName}}",
206
- age: "{{userAge}}",
207
- status: "active",
208
- },
209
- };
210
-
211
- const result = await resolver.resolve(value, context);
212
- expect(result).toEqual({
213
- name: "Alice",
214
- age: "25",
215
- status: "active",
216
- });
217
- });
218
-
219
- it("should resolve template variables in nested objects", async () => {
220
- context.setOutput("theme", "dark");
221
- context.setOutput("notifications", "true");
222
-
223
- const value: ResolveJsonValue = {
224
- type: "resolve-json",
225
- arguments: {
226
- user: {
227
- settings: {
228
- theme: "{{theme}}",
229
- notifications: "{{notifications}}",
230
- },
231
- },
232
- },
233
- };
234
-
235
- const result = await resolver.resolve(value, context);
236
- expect(result).toEqual({
237
- user: {
238
- settings: {
239
- theme: "dark",
240
- notifications: "true",
241
- },
242
- },
243
- });
244
- });
245
-
246
- it("should resolve template variables in arrays", async () => {
247
- context.setOutput("firstItem", "item1");
248
- context.setOutput("secondItem", "item2");
249
-
250
- const value: ResolveJsonValue = {
251
- type: "resolve-json",
252
- arguments: ["{{firstItem}}", "{{secondItem}}", "static"],
253
- };
254
-
255
- const result = await resolver.resolve(value, context);
256
- expect(result).toEqual(["item1", "item2", "static"]);
257
- });
258
-
259
- it("should resolve template variables in array of objects", async () => {
260
- context.setOutput("id1", "1");
261
- context.setOutput("name1", "First");
262
- context.setOutput("id2", "2");
263
- context.setOutput("name2", "Second");
264
-
265
- const value: ResolveJsonValue = {
266
- type: "resolve-json",
267
- arguments: [
268
- { id: "{{id1}}", name: "{{name1}}" },
269
- { id: "{{id2}}", name: "{{name2}}" },
270
- ],
271
- };
272
-
273
- const result = await resolver.resolve(value, context);
274
- expect(result).toEqual([
275
- { id: "1", name: "First" },
276
- { id: "2", name: "Second" },
277
- ]);
278
- });
279
-
280
- it("should resolve deeply nested template variables", async () => {
281
- context.setOutput(
282
- "contractAddress",
283
- "0x1234567890123456789012345678901234567890"
284
- );
285
- context.setOutput("functionName", "transfer");
286
- context.setOutput("amount", "1000000000000000000");
287
-
288
- const value: ResolveJsonValue = {
289
- type: "resolve-json",
290
- arguments: {
291
- transaction: {
292
- to: "{{contractAddress}}",
293
- data: {
294
- function: "{{functionName}}",
295
- params: {
296
- amount: "{{amount}}",
297
- },
298
- },
299
- },
300
- },
301
- };
302
-
303
- const result = await resolver.resolve(value, context);
304
- expect(result).toEqual({
305
- transaction: {
306
- to: "0x1234567890123456789012345678901234567890",
307
- data: {
308
- function: "transfer",
309
- params: {
310
- amount: "1000000000000000000",
311
- },
312
- },
313
- },
314
- });
315
- });
316
- });
317
-
318
- describe("complex nested structures", () => {
319
- it("should resolve complex nested structure with arrays and objects", async () => {
320
- const value: ResolveJsonValue = {
321
- type: "resolve-json",
322
- arguments: {
323
- blockchain: {
324
- ethereum: {
325
- mainnet: {
326
- contracts: {
327
- erc20: [
328
- {
329
- address: "0xA0b86a33E6441e6e80D0c4C6C7527d72e1d7e4e1",
330
- symbol: "USDC",
331
- decimals: 6,
332
- },
333
- {
334
- address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
335
- symbol: "DAI",
336
- decimals: 18,
337
- },
338
- ],
339
- },
340
- },
341
- },
342
- },
343
- },
344
- };
345
-
346
- const result = await resolver.resolve(value, context);
347
- expect(result).toEqual({
348
- blockchain: {
349
- ethereum: {
350
- mainnet: {
351
- contracts: {
352
- erc20: [
353
- {
354
- address: "0xA0b86a33E6441e6e80D0c4C6C7527d72e1d7e4e1",
355
- symbol: "USDC",
356
- decimals: 6,
357
- },
358
- {
359
- address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
360
- symbol: "DAI",
361
- decimals: 18,
362
- },
363
- ],
364
- },
365
- },
366
- },
367
- },
368
- });
369
- });
370
-
371
- it("should resolve structure with mixed template variables and static values", async () => {
372
- context.setOutput("networkName", "mainnet");
373
- context.setOutput("chainId", "1");
374
- context.setOutput("rpcUrl", "https://mainnet.infura.io/v3/abc123");
375
-
376
- const value: ResolveJsonValue = {
377
- type: "resolve-json",
378
- arguments: {
379
- network: {
380
- name: "{{networkName}}",
381
- chainId: "{{chainId}}",
382
- rpcUrl: "{{rpcUrl}}",
383
- supports: ["etherscan", "sourcify"],
384
- gasLimit: 10000000,
385
- },
386
- contracts: [
387
- { name: "Token", address: "0x123" },
388
- { name: "Factory", address: "0x456" },
389
- ],
390
- },
391
- };
392
-
393
- const result = await resolver.resolve(value, context);
394
- expect(result).toEqual({
395
- network: {
396
- name: "mainnet",
397
- chainId: "1",
398
- rpcUrl: "https://mainnet.infura.io/v3/abc123",
399
- supports: ["etherscan", "sourcify"],
400
- gasLimit: 10000000,
401
- },
402
- contracts: [
403
- { name: "Token", address: "0x123" },
404
- { name: "Factory", address: "0x456" },
405
- ],
406
- });
407
- });
408
- });
409
-
410
- describe("edge cases", () => {
411
- it("should handle empty object", async () => {
412
- const value: ResolveJsonValue = {
413
- type: "resolve-json",
414
- arguments: {},
415
- };
416
-
417
- const result = await resolver.resolve(value, context);
418
- expect(result).toEqual({});
419
- });
420
-
421
- it("should handle empty array", async () => {
422
- const value: ResolveJsonValue = {
423
- type: "resolve-json",
424
- arguments: [],
425
- };
426
-
427
- const result = await resolver.resolve(value, context);
428
- expect(result).toEqual([]);
429
- });
430
-
431
- it("should handle null values", async () => {
432
- const value: ResolveJsonValue = {
433
- type: "resolve-json",
434
- arguments: {
435
- nullValue: null,
436
- undefinedValue: undefined,
437
- emptyString: "",
438
- zero: 0,
439
- falseValue: false,
440
- },
441
- };
442
-
443
- const result = await resolver.resolve(value, context);
444
- expect(result).toEqual({
445
- nullValue: null,
446
- undefinedValue: undefined,
447
- emptyString: "",
448
- zero: 0,
449
- falseValue: false,
450
- });
451
- });
452
-
453
- it("should handle primitive values directly", async () => {
454
- const stringValue: ResolveJsonValue = {
455
- type: "resolve-json",
456
- arguments: "hello world",
457
- };
458
-
459
- const numberValue: ResolveJsonValue = {
460
- type: "resolve-json",
461
- arguments: 42,
462
- };
463
-
464
- const booleanValue: ResolveJsonValue = {
465
- type: "resolve-json",
466
- arguments: true,
467
- };
468
-
469
- expect(await resolver.resolve(stringValue, context)).toBe("hello world");
470
- expect(await resolver.resolve(numberValue, context)).toBe(42);
471
- expect(await resolver.resolve(booleanValue, context)).toBe(true);
472
- });
473
-
474
- it("should handle deeply nested arrays", async () => {
475
- const value: ResolveJsonValue = {
476
- type: "resolve-json",
477
- arguments: [
478
- [
479
- [1, 2, 3],
480
- ["a", "b", "c"],
481
- ],
482
- [[{ id: 1 }, { id: 2 }], [{ name: "test" }]],
483
- ],
484
- };
485
-
486
- const result = await resolver.resolve(value, context);
487
- expect(result).toEqual([
488
- [
489
- [1, 2, 3],
490
- ["a", "b", "c"],
491
- ],
492
- [[{ id: 1 }, { id: 2 }], [{ name: "test" }]],
493
- ]);
494
- });
495
-
496
- it("should handle large numbers and special values", async () => {
497
- const value: ResolveJsonValue = {
498
- type: "resolve-json",
499
- arguments: {
500
- largeNumber:
501
- 115792089237316195423570985008687907853269984665640564039457584007913129639935n, // max uint256
502
- floatNumber: 3.14159,
503
- negativeNumber: -42,
504
- scientificNotation: 1e18,
505
- },
506
- };
507
-
508
- const result = await resolver.resolve(value, context);
509
- expect(result).toEqual({
510
- largeNumber:
511
- 115792089237316195423570985008687907853269984665640564039457584007913129639935n,
512
- floatNumber: 3.14159,
513
- negativeNumber: -42,
514
- scientificNotation: 1e18,
515
- });
516
- });
517
- });
518
-
519
- describe("recursive resolution", () => {
520
- it("should recursively resolve all nested values", async () => {
521
- context.setOutput("level1", "resolved1");
522
- context.setOutput("level2", "resolved2");
523
- context.setOutput("level3", "resolved3");
524
-
525
- const value: ResolveJsonValue = {
526
- type: "resolve-json",
527
- arguments: {
528
- level1: "{{level1}}",
529
- nested: {
530
- level2: "{{level2}}",
531
- deeper: {
532
- level3: "{{level3}}",
533
- array: ["{{level1}}", { value: "{{level2}}" }],
534
- },
535
- },
536
- },
537
- };
538
-
539
- const result = await resolver.resolve(value, context);
540
- expect(result).toEqual({
541
- level1: "resolved1",
542
- nested: {
543
- level2: "resolved2",
544
- deeper: {
545
- level3: "resolved3",
546
- array: ["resolved1", { value: "resolved2" }],
547
- },
548
- },
549
- });
550
- });
551
-
552
- it("should handle circular-like structures without infinite recursion", async () => {
553
- // This tests that the resolver can handle complex nested structures
554
- // without getting stuck in infinite loops
555
- const value: ResolveJsonValue = {
556
- type: "resolve-json",
557
- arguments: {
558
- a: {
559
- b: {
560
- c: {
561
- d: "value",
562
- },
563
- },
564
- },
565
- e: [
566
- {
567
- f: {
568
- g: "another value",
569
- },
570
- },
571
- ],
572
- },
573
- };
574
-
575
- const result = await resolver.resolve(value, context);
576
- expect(result).toEqual({
577
- a: {
578
- b: {
579
- c: {
580
- d: "value",
581
- },
582
- },
583
- },
584
- e: [
585
- {
586
- f: {
587
- g: "another value",
588
- },
589
- },
590
- ],
591
- });
592
- });
593
- });
594
-
595
- describe("integration with other value types", () => {
596
- it("should work with basic-arithmetic values in JSON", async () => {
597
- const value: ResolveJsonValue = {
598
- type: "resolve-json",
599
- arguments: {
600
- calculation: {
601
- type: "basic-arithmetic",
602
- arguments: { operation: "add", values: [10, 20] },
603
- },
604
- static: "value",
605
- },
606
- };
607
-
608
- const result = await resolver.resolve(value, context);
609
- expect(result).toEqual({
610
- calculation: "30",
611
- static: "value",
612
- });
613
- });
614
-
615
- it("should work with read-json values in JSON", async () => {
616
- const value: ResolveJsonValue = {
617
- type: "resolve-json",
618
- arguments: {
619
- data: {
620
- type: "read-json",
621
- arguments: {
622
- json: { name: "John", age: 30 },
623
- path: "name",
624
- },
625
- },
626
- metadata: "extracted",
627
- },
628
- };
629
-
630
- const result = await resolver.resolve(value, context);
631
- expect(result).toEqual({
632
- data: "John",
633
- metadata: "extracted",
634
- });
635
- });
636
-
637
- it("should work with nested resolve-json values", async () => {
638
- const value: ResolveJsonValue = {
639
- type: "resolve-json",
640
- arguments: {
641
- outer: {
642
- type: "resolve-json",
643
- arguments: {
644
- inner: {
645
- type: "resolve-json",
646
- arguments: {
647
- value: "deeply nested",
648
- },
649
- },
650
- },
651
- },
652
- },
653
- };
654
-
655
- const result = await resolver.resolve(value, context);
656
- expect(result).toEqual({
657
- outer: {
658
- inner: {
659
- value: "deeply nested",
660
- },
661
- },
662
- });
663
- });
664
-
665
- it("should work with Network() expressions in JSON", async () => {
666
- const value: ResolveJsonValue = {
667
- type: "resolve-json",
668
- arguments: {
669
- network: {
670
- chainId: "{{Network().chainId}}",
671
- name: "{{Network().name}}",
672
- rpcUrl: "{{Network().rpcUrl}}",
673
- },
674
- static: "value",
675
- },
676
- };
677
-
678
- const result = await resolver.resolve(value, context);
679
- expect(result).toEqual({
680
- network: {
681
- chainId: 999,
682
- name: "testnet",
683
- rpcUrl: "http://127.0.0.1:8545",
684
- },
685
- static: "value",
686
- });
687
- });
688
-
689
- it("should work with Network() expressions deeply nested in JSON", async () => {
690
- const value: ResolveJsonValue = {
691
- type: "resolve-json",
692
- arguments: {
693
- config: {
694
- blockchain: {
695
- ethereum: {
696
- networks: {
697
- mainnet: {
698
- chainId: "{{Network().chainId}}",
699
- name: "{{Network().name}}",
700
- rpcUrl: "{{Network().rpcUrl}}",
701
- supports: "{{Network().supports}}",
702
- gasLimit: "{{Network().gasLimit}}",
703
- },
704
- },
705
- settings: {
706
- evmVersion: "{{Network().evmVersion}}",
707
- testnet: "{{Network().testnet}}",
708
- },
709
- },
710
- },
711
- metadata: {
712
- source: "catapult",
713
- version: "1.0.0",
714
- },
715
- },
716
- contracts: [
717
- {
718
- name: "Token",
719
- network: "{{Network().name}}",
720
- chainId: "{{Network().chainId}}",
721
- },
722
- {
723
- name: "Factory",
724
- rpcUrl: "{{Network().rpcUrl}}",
725
- },
726
- ],
727
- },
728
- };
729
-
730
- const result = await resolver.resolve(value, context);
731
- expect(result).toEqual({
732
- config: {
733
- blockchain: {
734
- ethereum: {
735
- networks: {
736
- mainnet: {
737
- chainId: 999,
738
- name: "testnet",
739
- rpcUrl: "http://127.0.0.1:8545",
740
- supports: ["sourcify", "etherscan_v2"],
741
- gasLimit: 10000000,
742
- },
743
- },
744
- settings: {
745
- evmVersion: "cancun",
746
- testnet: false,
747
- },
748
- },
749
- },
750
- metadata: {
751
- source: "catapult",
752
- version: "1.0.0",
753
- },
754
- },
755
- contracts: [
756
- {
757
- name: "Token",
758
- network: "testnet",
759
- chainId: 999,
760
- },
761
- {
762
- name: "Factory",
763
- rpcUrl: "http://127.0.0.1:8545",
764
- },
765
- ],
766
- });
767
- });
768
- });
769
- });