@0xsequence/catapult 1.4.0 → 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 (163) hide show
  1. package/README.md +27 -0
  2. package/dist/lib/__tests__/network-loader.spec.js.map +1 -1
  3. package/dist/lib/core/__tests__/resolver.spec.js +22 -0
  4. package/dist/lib/core/__tests__/resolver.spec.js.map +1 -1
  5. package/dist/lib/core/__tests__/sign-actions.spec.d.ts +2 -0
  6. package/dist/lib/core/__tests__/sign-actions.spec.d.ts.map +1 -0
  7. package/dist/lib/core/__tests__/sign-actions.spec.js +128 -0
  8. package/dist/lib/core/__tests__/sign-actions.spec.js.map +1 -0
  9. package/dist/lib/core/__tests__/signer.spec.d.ts +2 -0
  10. package/dist/lib/core/__tests__/signer.spec.d.ts.map +1 -0
  11. package/dist/lib/core/__tests__/signer.spec.js +40 -0
  12. package/dist/lib/core/__tests__/signer.spec.js.map +1 -0
  13. package/dist/lib/core/context.d.ts +3 -2
  14. package/dist/lib/core/context.d.ts.map +1 -1
  15. package/dist/lib/core/context.js +3 -2
  16. package/dist/lib/core/context.js.map +1 -1
  17. package/dist/lib/core/engine.d.ts +4 -0
  18. package/dist/lib/core/engine.d.ts.map +1 -1
  19. package/dist/lib/core/engine.js +173 -0
  20. package/dist/lib/core/engine.js.map +1 -1
  21. package/dist/lib/core/signer.d.ts +7 -0
  22. package/dist/lib/core/signer.d.ts.map +1 -0
  23. package/dist/lib/core/signer.js +60 -0
  24. package/dist/lib/core/signer.js.map +1 -0
  25. package/dist/lib/parsers/__tests__/source.spec.js +37 -0
  26. package/dist/lib/parsers/__tests__/source.spec.js.map +1 -1
  27. package/dist/lib/parsers/source.js +1 -1
  28. package/dist/lib/parsers/source.js.map +1 -1
  29. package/dist/lib/provenance.js +51 -2
  30. package/dist/lib/provenance.js.map +1 -1
  31. package/dist/lib/types/actions.d.ts +26 -2
  32. package/dist/lib/types/actions.d.ts.map +1 -1
  33. package/dist/lib/types/actions.js +3 -0
  34. package/dist/lib/types/actions.js.map +1 -1
  35. package/dist/lib/types/source.d.ts +2 -0
  36. package/dist/lib/types/source.d.ts.map +1 -1
  37. package/package.json +4 -1
  38. package/.eslintrc.json +0 -29
  39. package/.github/workflows/ci.yml +0 -181
  40. package/CONCEPT.md +0 -24
  41. package/contracts/checked-call.huff +0 -65
  42. package/eslint.config.js +0 -48
  43. package/examples/jobs/guards-v1.yaml +0 -17
  44. package/examples/jobs/sequence-seq-0001-patch.yaml +0 -59
  45. package/examples/jobs/sequence-v1.yaml +0 -59
  46. package/examples/templates/sequence-factory-v1.yaml +0 -56
  47. package/jest.config.js +0 -25
  48. package/src/cli.ts +0 -18
  49. package/src/commands/common.ts +0 -61
  50. package/src/commands/dry.ts +0 -209
  51. package/src/commands/etherscan.ts +0 -360
  52. package/src/commands/index.ts +0 -6
  53. package/src/commands/list.ts +0 -262
  54. package/src/commands/provenance.ts +0 -120
  55. package/src/commands/run.ts +0 -146
  56. package/src/commands/utils.ts +0 -215
  57. package/src/index.ts +0 -67
  58. package/src/lib/__tests__/deployer-events.spec.ts +0 -338
  59. package/src/lib/__tests__/deployer.spec.ts +0 -2269
  60. package/src/lib/__tests__/network-loader.spec.ts +0 -150
  61. package/src/lib/__tests__/network-selection.spec.ts +0 -41
  62. package/src/lib/__tests__/network-utils.spec.ts +0 -230
  63. package/src/lib/__tests__/provenance.spec.ts +0 -208
  64. package/src/lib/artifacts/__tests__/fixtures/contract1.json +0 -19
  65. package/src/lib/artifacts/__tests__/fixtures/contract2.json +0 -19
  66. package/src/lib/artifacts/__tests__/fixtures/duplicate-name.json +0 -19
  67. package/src/lib/artifacts/__tests__/fixtures/nested/nested-contract.json +0 -18
  68. package/src/lib/artifacts/__tests__/fixtures/not-an-artifact.json +0 -8
  69. package/src/lib/artifacts/__tests__/fixtures/readme.txt +0 -2
  70. package/src/lib/contracts/__tests__/repository.spec.ts +0 -612
  71. package/src/lib/contracts/repository.ts +0 -411
  72. package/src/lib/core/__tests__/assert-action.spec.ts +0 -474
  73. package/src/lib/core/__tests__/context.spec.ts +0 -37
  74. package/src/lib/core/__tests__/engine.spec.ts +0 -2005
  75. package/src/lib/core/__tests__/graph.spec.ts +0 -125
  76. package/src/lib/core/__tests__/json-integration.spec.ts +0 -425
  77. package/src/lib/core/__tests__/loader.spec.ts +0 -367
  78. package/src/lib/core/__tests__/multi-platform-verification.spec.ts +0 -406
  79. package/src/lib/core/__tests__/resolver.spec.ts +0 -2496
  80. package/src/lib/core/__tests__/static-action.spec.ts +0 -172
  81. package/src/lib/core/context.ts +0 -127
  82. package/src/lib/core/engine.ts +0 -1834
  83. package/src/lib/core/graph.ts +0 -252
  84. package/src/lib/core/loader.ts +0 -253
  85. package/src/lib/core/resolver.ts +0 -873
  86. package/src/lib/deployer.ts +0 -1005
  87. package/src/lib/events/__tests__/event-system.spec.ts +0 -392
  88. package/src/lib/events/cli-adapter.ts +0 -369
  89. package/src/lib/events/emitter.ts +0 -62
  90. package/src/lib/events/index.ts +0 -3
  91. package/src/lib/events/types.ts +0 -520
  92. package/src/lib/index.ts +0 -17
  93. package/src/lib/network-loader.ts +0 -90
  94. package/src/lib/network-selection.ts +0 -73
  95. package/src/lib/network-utils.ts +0 -64
  96. package/src/lib/parsers/__tests__/buildinfo.spec.ts +0 -122
  97. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-bytecode-buildinfo.json +0 -62
  98. package/src/lib/parsers/__tests__/fixtures/buildinfo/invalid-json.txt +0 -2
  99. package/src/lib/parsers/__tests__/fixtures/buildinfo/multi-contract-buildinfo.json +0 -89
  100. package/src/lib/parsers/__tests__/fixtures/buildinfo/no-contracts-buildinfo.json +0 -17
  101. package/src/lib/parsers/__tests__/fixtures/buildinfo/simple-buildinfo.json +0 -63
  102. package/src/lib/parsers/__tests__/fixtures/buildinfo/wrong-format.json +0 -4
  103. package/src/lib/parsers/__tests__/job.spec.ts +0 -439
  104. package/src/lib/parsers/__tests__/source.spec.ts +0 -134
  105. package/src/lib/parsers/__tests__/template.spec.ts +0 -111
  106. package/src/lib/parsers/artifact/__tests__/artifact.spec.ts +0 -117
  107. package/src/lib/parsers/artifact/__tests__/fixtures/empty-bytecode.json +0 -5
  108. package/src/lib/parsers/artifact/__tests__/fixtures/hardhat-artifact.json +0 -67
  109. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-bytecode.json +0 -5
  110. package/src/lib/parsers/artifact/__tests__/fixtures/invalid-json.txt +0 -11
  111. package/src/lib/parsers/artifact/__tests__/fixtures/minimal-artifact.json +0 -5
  112. package/src/lib/parsers/artifact/__tests__/fixtures/missing-abi.json +0 -4
  113. package/src/lib/parsers/artifact/__tests__/fixtures/missing-bytecode.json +0 -11
  114. package/src/lib/parsers/artifact/__tests__/fixtures/missing-contract-name.json +0 -11
  115. package/src/lib/parsers/artifact/__tests__/fixtures/simple-artifact.json +0 -40
  116. package/src/lib/parsers/artifact/__tests__/fixtures/wrong-types.json +0 -7
  117. package/src/lib/parsers/artifact/foundry-1.2.ts +0 -72
  118. package/src/lib/parsers/artifact/index.ts +0 -27
  119. package/src/lib/parsers/artifact/types.ts +0 -9
  120. package/src/lib/parsers/buildinfo.ts +0 -127
  121. package/src/lib/parsers/constants.ts +0 -56
  122. package/src/lib/parsers/index.ts +0 -6
  123. package/src/lib/parsers/job.ts +0 -160
  124. package/src/lib/parsers/source.ts +0 -129
  125. package/src/lib/parsers/template.ts +0 -135
  126. package/src/lib/provenance.ts +0 -785
  127. package/src/lib/std/templates/arachnid-deterministic-deployment-proxy.yaml +0 -68
  128. package/src/lib/std/templates/assured-deployment.yaml +0 -46
  129. package/src/lib/std/templates/era-evm-predeploy.yaml +0 -35
  130. package/src/lib/std/templates/erc-2470.yaml +0 -70
  131. package/src/lib/std/templates/min-balance.yaml +0 -35
  132. package/src/lib/std/templates/nano-universal-deployer.yaml +0 -61
  133. package/src/lib/std/templates/raw-erc-2470.yaml +0 -62
  134. package/src/lib/std/templates/raw-nano-universal-deployer.yaml +0 -54
  135. package/src/lib/std/templates/raw-sequence-universal-deployer-2.yaml +0 -52
  136. package/src/lib/std/templates/sequence-universal-deployer-2.yaml +0 -61
  137. package/src/lib/types/__tests__/json-request-action.spec.ts +0 -243
  138. package/src/lib/types/__tests__/read-json-value.spec.ts +0 -278
  139. package/src/lib/types/__tests__/resolve-json-value.spec.ts +0 -769
  140. package/src/lib/types/actions.ts +0 -148
  141. package/src/lib/types/artifacts.ts +0 -21
  142. package/src/lib/types/buildinfo.ts +0 -116
  143. package/src/lib/types/conditions.ts +0 -50
  144. package/src/lib/types/contracts.ts +0 -26
  145. package/src/lib/types/definitions.ts +0 -77
  146. package/src/lib/types/index.ts +0 -9
  147. package/src/lib/types/network.ts +0 -33
  148. package/src/lib/types/project.ts +0 -9
  149. package/src/lib/types/source.ts +0 -26
  150. package/src/lib/types/task.ts +0 -9
  151. package/src/lib/types/values.ts +0 -221
  152. package/src/lib/utils/assertion.ts +0 -24
  153. package/src/lib/utils/validation.ts +0 -116
  154. package/src/lib/validation/contract-references.ts +0 -210
  155. package/src/lib/validation/index.ts +0 -1
  156. package/src/lib/verification/__tests__/etherscan.spec.ts +0 -710
  157. package/src/lib/verification/__tests__/sourcify.spec.ts +0 -288
  158. package/src/lib/verification/etherscan.ts +0 -547
  159. package/src/lib/verification/sourcify.ts +0 -248
  160. package/test_validation/artifacts/TestContract.json +0 -9
  161. package/test_validation/jobs/test-missing.yaml +0 -16
  162. package/test_validation/networks.yaml +0 -3
  163. 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
- });