@algorandfoundation/algokit-client-generator 2.6.0-beta.1 → 2.6.1-beta.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 (128) hide show
  1. package/bin/cli.mjs +4 -0
  2. package/cli.cjs +75 -0
  3. package/cli.d.ts +0 -1
  4. package/cli.mjs +54 -0
  5. package/client/app-types.cjs +152 -0
  6. package/client/app-types.d.ts +0 -1
  7. package/client/app-types.mjs +131 -0
  8. package/client/call-client.cjs +332 -0
  9. package/client/call-client.d.ts +0 -1
  10. package/client/{call-client.js → call-client.mjs} +107 -135
  11. package/client/call-composer-types.cjs +141 -0
  12. package/client/call-composer-types.d.ts +0 -1
  13. package/client/{call-composer-types.js → call-composer-types.mjs} +33 -58
  14. package/client/call-composer.cjs +145 -0
  15. package/client/call-composer.d.ts +0 -1
  16. package/client/call-composer.mjs +124 -0
  17. package/client/call-factory.cjs +138 -0
  18. package/client/call-factory.d.ts +0 -1
  19. package/client/{call-factory.js → call-factory.mjs} +31 -56
  20. package/client/deploy-types.cjs +94 -0
  21. package/client/deploy-types.d.ts +0 -1
  22. package/client/deploy-types.mjs +91 -0
  23. package/client/generate.cjs +37 -0
  24. package/client/generate.d.ts +0 -1
  25. package/client/generate.mjs +35 -0
  26. package/client/generator-context.cjs +37 -0
  27. package/client/generator-context.d.ts +0 -1
  28. package/client/generator-context.mjs +16 -0
  29. package/client/helpers/{get-call-config-summary.js → get-call-config-summary.cjs} +7 -25
  30. package/client/helpers/get-call-config-summary.d.ts +1 -2
  31. package/client/helpers/get-call-config-summary.mjs +54 -0
  32. package/client/helpers/{get-equivalent-type.js → get-equivalent-type.cjs} +20 -20
  33. package/client/helpers/get-equivalent-type.d.ts +0 -1
  34. package/client/helpers/get-equivalent-type.mjs +56 -0
  35. package/client/{imports.js → imports.cjs} +3 -4
  36. package/client/imports.d.ts +0 -1
  37. package/client/imports.mjs +27 -0
  38. package/client/{utility-types.js → utility-types.cjs} +26 -25
  39. package/client/utility-types.d.ts +0 -1
  40. package/client/utility-types.mjs +47 -0
  41. package/dev.d.ts +0 -1
  42. package/index.cjs +13 -0
  43. package/index.d.ts +0 -1
  44. package/index.mjs +3 -0
  45. package/output/{writer.js → writer.cjs} +44 -38
  46. package/output/writer.d.ts +0 -1
  47. package/output/writer.mjs +139 -0
  48. package/package.json +7 -4
  49. package/schema/application.schema.json.cjs +374 -0
  50. package/schema/application.schema.json.mjs +363 -0
  51. package/schema/contract.schema.json.cjs +159 -0
  52. package/schema/contract.schema.json.mjs +148 -0
  53. package/schema/load.cjs +25 -0
  54. package/schema/load.d.ts +0 -1
  55. package/schema/load.mjs +22 -0
  56. package/tests/approval-tests.spec.d.ts +0 -1
  57. package/tests/util.d.ts +1 -0
  58. package/util/boom.cjs +7 -0
  59. package/util/boom.d.ts +0 -1
  60. package/util/boom.mjs +5 -0
  61. package/util/color-console.cjs +18 -0
  62. package/util/color-console.d.ts +0 -1
  63. package/util/color-console.mjs +16 -0
  64. package/util/not-falsy.d.ts +0 -1
  65. package/util/sanitization.cjs +17 -0
  66. package/util/sanitization.d.ts +0 -1
  67. package/util/sanitization.mjs +11 -0
  68. package/bin/cli.js +0 -4
  69. package/cli.d.ts.map +0 -1
  70. package/cli.js +0 -79
  71. package/cli.js.map +0 -1
  72. package/client/app-types.d.ts.map +0 -1
  73. package/client/app-types.js +0 -161
  74. package/client/app-types.js.map +0 -1
  75. package/client/call-client.d.ts.map +0 -1
  76. package/client/call-client.js.map +0 -1
  77. package/client/call-composer-types.d.ts.map +0 -1
  78. package/client/call-composer-types.js.map +0 -1
  79. package/client/call-composer.d.ts.map +0 -1
  80. package/client/call-composer.js +0 -151
  81. package/client/call-composer.js.map +0 -1
  82. package/client/call-factory.d.ts.map +0 -1
  83. package/client/call-factory.js.map +0 -1
  84. package/client/deploy-types.d.ts.map +0 -1
  85. package/client/deploy-types.js +0 -95
  86. package/client/deploy-types.js.map +0 -1
  87. package/client/generate.d.ts.map +0 -1
  88. package/client/generate.js +0 -37
  89. package/client/generate.js.map +0 -1
  90. package/client/generator-context.d.ts.map +0 -1
  91. package/client/generator-context.js +0 -41
  92. package/client/generator-context.js.map +0 -1
  93. package/client/helpers/get-call-config-summary.d.ts.map +0 -1
  94. package/client/helpers/get-call-config-summary.js.map +0 -1
  95. package/client/helpers/get-equivalent-type.d.ts.map +0 -1
  96. package/client/helpers/get-equivalent-type.js.map +0 -1
  97. package/client/imports.d.ts.map +0 -1
  98. package/client/imports.js.map +0 -1
  99. package/client/utility-types.d.ts.map +0 -1
  100. package/client/utility-types.js.map +0 -1
  101. package/dev.d.ts.map +0 -1
  102. package/dev.js +0 -5
  103. package/dev.js.map +0 -1
  104. package/index.d.ts.map +0 -1
  105. package/index.js +0 -12
  106. package/index.js.map +0 -1
  107. package/output/writer.d.ts.map +0 -1
  108. package/output/writer.js.map +0 -1
  109. package/schema/application.schema.json +0 -354
  110. package/schema/contract.schema.json +0 -139
  111. package/schema/load.d.ts.map +0 -1
  112. package/schema/load.js +0 -51
  113. package/schema/load.js.map +0 -1
  114. package/tests/approval-tests.spec.d.ts.map +0 -1
  115. package/tests/approval-tests.spec.js +0 -24
  116. package/tests/approval-tests.spec.js.map +0 -1
  117. package/util/boom.d.ts.map +0 -1
  118. package/util/boom.js +0 -8
  119. package/util/boom.js.map +0 -1
  120. package/util/color-console.d.ts.map +0 -1
  121. package/util/color-console.js +0 -20
  122. package/util/color-console.js.map +0 -1
  123. package/util/not-falsy.d.ts.map +0 -1
  124. package/util/not-falsy.js +0 -6
  125. package/util/not-falsy.js.map +0 -1
  126. package/util/sanitization.d.ts.map +0 -1
  127. package/util/sanitization.js +0 -17
  128. package/util/sanitization.js.map +0 -1
@@ -0,0 +1,363 @@
1
+ var $schema = "http://json-schema.org/draft-07/schema";
2
+ var title = "AlgoAppSpec";
3
+ var type = "object";
4
+ var required = [
5
+ "contract",
6
+ "schema",
7
+ "source",
8
+ "state"
9
+ ];
10
+ var additionalProperties = true;
11
+ var properties = {
12
+ hints: {
13
+ type: "object",
14
+ additionalProperties: {
15
+ $ref: "#/definitions/Hint"
16
+ }
17
+ },
18
+ source: {
19
+ $ref: "#/definitions/AppSources"
20
+ },
21
+ contract: {
22
+ $ref: "contract.schema.json"
23
+ },
24
+ schema: {
25
+ $ref: "#/definitions/SchemaSpec"
26
+ },
27
+ state: {
28
+ $ref: "#/definitions/StateSchemaSpec"
29
+ },
30
+ bare_call_config: {
31
+ $ref: "#/definitions/CallConfig"
32
+ }
33
+ };
34
+ var definitions = {
35
+ AVMType: {
36
+ description: "AVM data type",
37
+ "enum": [
38
+ "uint64",
39
+ "bytes"
40
+ ]
41
+ },
42
+ DeclaredSchemaValueSpec: {
43
+ type: "object",
44
+ required: [
45
+ "type",
46
+ "key"
47
+ ],
48
+ additionalProperties: true,
49
+ properties: {
50
+ type: {
51
+ description: "The type of the value",
52
+ $ref: "#/definitions/AVMType"
53
+ },
54
+ key: {
55
+ description: "The name of the key",
56
+ type: "string"
57
+ },
58
+ descr: {
59
+ description: "A description of the variable",
60
+ type: "string"
61
+ },
62
+ "static": {
63
+ description: "Whether the value is set statically (at create time only) or dynamically",
64
+ type: "boolean"
65
+ }
66
+ }
67
+ },
68
+ ReservedSchemaValueSpec: {
69
+ type: "object",
70
+ required: [
71
+ "type"
72
+ ],
73
+ properties: {
74
+ type: {
75
+ description: "The type of the value",
76
+ $ref: "#/definitions/AVMType"
77
+ },
78
+ descr: {
79
+ description: "A description of the variable",
80
+ type: "string"
81
+ },
82
+ max_keys: {
83
+ description: "The maximum number of slots to reserve",
84
+ type: "integer"
85
+ }
86
+ }
87
+ },
88
+ StateSchemaSpec: {
89
+ type: "object",
90
+ additionalProperties: true,
91
+ required: [
92
+ "global",
93
+ "local"
94
+ ],
95
+ properties: {
96
+ global: {
97
+ $ref: "#/definitions/StateSchema"
98
+ },
99
+ local: {
100
+ $ref: "#/definitions/StateSchema"
101
+ }
102
+ }
103
+ },
104
+ StateSchema: {
105
+ type: "object",
106
+ additionalProperties: true,
107
+ required: [
108
+ "num_byte_slices",
109
+ "num_uints"
110
+ ],
111
+ properties: {
112
+ num_uints: {
113
+ type: "integer"
114
+ },
115
+ num_byte_slices: {
116
+ type: "integer"
117
+ }
118
+ }
119
+ },
120
+ SchemaSpec: {
121
+ description: "The schema for global and local storage",
122
+ type: "object",
123
+ additionalProperties: true,
124
+ properties: {
125
+ global: {
126
+ $ref: "#/definitions/Schema"
127
+ },
128
+ local: {
129
+ $ref: "#/definitions/Schema"
130
+ }
131
+ }
132
+ },
133
+ Schema: {
134
+ type: "object",
135
+ additionalProperties: true,
136
+ properties: {
137
+ declared: {
138
+ type: "object",
139
+ additionalProperties: {
140
+ $ref: "#/definitions/DeclaredSchemaValueSpec"
141
+ }
142
+ },
143
+ reserved: {
144
+ type: "object",
145
+ additionalProperties: {
146
+ $ref: "#/definitions/ReservedSchemaValueSpec"
147
+ }
148
+ }
149
+ }
150
+ },
151
+ AppSources: {
152
+ type: "object",
153
+ additionalProperties: true,
154
+ properties: {
155
+ approval: {
156
+ type: "string"
157
+ },
158
+ clear: {
159
+ type: "string"
160
+ }
161
+ }
162
+ },
163
+ Hint: {
164
+ type: "object",
165
+ additionalProperties: true,
166
+ properties: {
167
+ read_only: {
168
+ type: "boolean"
169
+ },
170
+ structs: {
171
+ type: "object",
172
+ properties: {
173
+ output: {
174
+ $ref: "#/definitions/Struct"
175
+ }
176
+ },
177
+ additionalProperties: {
178
+ $ref: "#/definitions/Struct"
179
+ }
180
+ },
181
+ default_arguments: {
182
+ additionalProperties: {
183
+ $ref: "#/definitions/DefaultArgument"
184
+ }
185
+ },
186
+ call_config: {
187
+ $ref: "#/definitions/CallConfig"
188
+ }
189
+ }
190
+ },
191
+ CallConfig: {
192
+ type: "object",
193
+ additionalProperties: false,
194
+ properties: {
195
+ no_op: {
196
+ $ref: "#/definitions/CallConfigValue"
197
+ },
198
+ opt_in: {
199
+ $ref: "#/definitions/CallConfigValue"
200
+ },
201
+ close_out: {
202
+ $ref: "#/definitions/CallConfigValue"
203
+ },
204
+ update_application: {
205
+ $ref: "#/definitions/CallConfigValue"
206
+ },
207
+ delete_application: {
208
+ $ref: "#/definitions/CallConfigValue"
209
+ }
210
+ }
211
+ },
212
+ CallConfigValue: {
213
+ "enum": [
214
+ "NEVER",
215
+ "CALL",
216
+ "CREATE",
217
+ "ALL"
218
+ ]
219
+ },
220
+ Struct: {
221
+ type: "object",
222
+ additionalProperties: true,
223
+ required: [
224
+ "name",
225
+ "elements"
226
+ ],
227
+ properties: {
228
+ name: {
229
+ type: "string"
230
+ },
231
+ elements: {
232
+ type: "array",
233
+ items: {
234
+ $ref: "#/definitions/StructElement"
235
+ }
236
+ }
237
+ }
238
+ },
239
+ FieldName: {
240
+ type: "string"
241
+ },
242
+ ABIType: {
243
+ type: "string"
244
+ },
245
+ StructElement: {
246
+ type: "array",
247
+ minItems: 2,
248
+ items: [
249
+ {
250
+ $ref: "#/definitions/FieldName"
251
+ },
252
+ {
253
+ $ref: "#/definitions/ABIType"
254
+ }
255
+ ]
256
+ },
257
+ DefaultArgument: {
258
+ description: "Defines a strategy for obtaining a default value for a given ABI arg.",
259
+ oneOf: [
260
+ {
261
+ type: "object",
262
+ required: [
263
+ "source",
264
+ "data"
265
+ ],
266
+ additionalProperties: true,
267
+ properties: {
268
+ source: {
269
+ description: "The default value should be fetched by invoking an ABI method",
270
+ "enum": [
271
+ "abi-method"
272
+ ]
273
+ },
274
+ data: {
275
+ description: "The contract of the ABI method to invoke.",
276
+ $ref: "contract.schema.json#/definitions/ContractMethod"
277
+ }
278
+ }
279
+ },
280
+ {
281
+ type: "object",
282
+ required: [
283
+ "source",
284
+ "data"
285
+ ],
286
+ additionalProperties: true,
287
+ properties: {
288
+ source: {
289
+ description: "The default value should be fetched from global state",
290
+ "enum": [
291
+ "global-state"
292
+ ]
293
+ },
294
+ data: {
295
+ description: "The key of the state variable",
296
+ type: "string"
297
+ }
298
+ }
299
+ },
300
+ {
301
+ type: "object",
302
+ required: [
303
+ "source",
304
+ "data"
305
+ ],
306
+ additionalProperties: true,
307
+ properties: {
308
+ source: {
309
+ description: "The default value should be fetched from the local state of the sender user",
310
+ "enum": [
311
+ "local-state"
312
+ ]
313
+ },
314
+ data: {
315
+ description: "The key of the state variable",
316
+ type: "string"
317
+ }
318
+ }
319
+ },
320
+ {
321
+ type: "object",
322
+ required: [
323
+ "source",
324
+ "data"
325
+ ],
326
+ additionalProperties: true,
327
+ properties: {
328
+ source: {
329
+ description: "The default value is a constant.",
330
+ "enum": [
331
+ "constant"
332
+ ]
333
+ },
334
+ data: {
335
+ description: "The static default value to use.",
336
+ anyOf: [
337
+ {
338
+ type: "string"
339
+ },
340
+ {
341
+ type: "number"
342
+ },
343
+ {
344
+ type: "integer"
345
+ }
346
+ ]
347
+ }
348
+ }
349
+ }
350
+ ]
351
+ }
352
+ };
353
+ var appJsonSchema = {
354
+ $schema: $schema,
355
+ title: title,
356
+ type: type,
357
+ required: required,
358
+ additionalProperties: additionalProperties,
359
+ properties: properties,
360
+ definitions: definitions
361
+ };
362
+
363
+ export { $schema, additionalProperties, appJsonSchema as default, definitions, properties, required, title, type };
@@ -0,0 +1,159 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var $schema = "http://json-schema.org/draft-07/schema";
6
+ var title = "AbiContract";
7
+ var type = "object";
8
+ var required = [
9
+ "name",
10
+ "methods"
11
+ ];
12
+ var additionalProperties = true;
13
+ var properties = {
14
+ name: {
15
+ type: "string"
16
+ },
17
+ desc: {
18
+ type: "string"
19
+ },
20
+ methods: {
21
+ type: "array",
22
+ items: {
23
+ $ref: "#/definitions/ContractMethod"
24
+ }
25
+ },
26
+ events: {
27
+ type: "array",
28
+ items: {
29
+ $ref: "#/definitions/Event"
30
+ }
31
+ },
32
+ networks: {
33
+ type: "object",
34
+ additionalProperties: {
35
+ type: "object",
36
+ required: [
37
+ "appID"
38
+ ],
39
+ additionalProperties: true,
40
+ properties: {
41
+ appID: {
42
+ type: "number"
43
+ }
44
+ }
45
+ }
46
+ }
47
+ };
48
+ var definitions = {
49
+ ContractMethod: {
50
+ type: "object",
51
+ additionalProperties: true,
52
+ required: [
53
+ "name",
54
+ "args",
55
+ "returns"
56
+ ],
57
+ properties: {
58
+ name: {
59
+ type: "string"
60
+ },
61
+ args: {
62
+ type: "array",
63
+ items: {
64
+ $ref: "#/definitions/ContractMethodArg"
65
+ }
66
+ },
67
+ desc: {
68
+ type: "string"
69
+ },
70
+ returns: {
71
+ type: "object",
72
+ additionalProperties: true,
73
+ required: [
74
+ "type"
75
+ ],
76
+ properties: {
77
+ desc: {
78
+ type: "string"
79
+ },
80
+ type: {
81
+ $ref: "#/definitions/ABIType"
82
+ }
83
+ }
84
+ },
85
+ readonly: {
86
+ type: "boolean"
87
+ },
88
+ events: {
89
+ type: "array",
90
+ items: {
91
+ $ref: "#/definitions/Event"
92
+ }
93
+ }
94
+ }
95
+ },
96
+ Event: {
97
+ type: "object",
98
+ additionalProperties: true,
99
+ required: [
100
+ "name",
101
+ "args"
102
+ ],
103
+ properties: {
104
+ name: {
105
+ type: "string"
106
+ },
107
+ args: {
108
+ type: "array",
109
+ items: {
110
+ $ref: "#/definitions/ContractMethodArg"
111
+ }
112
+ },
113
+ desc: {
114
+ type: "string"
115
+ }
116
+ }
117
+ },
118
+ ContractMethodArg: {
119
+ type: "object",
120
+ additionalProperties: true,
121
+ required: [
122
+ "name",
123
+ "type"
124
+ ],
125
+ properties: {
126
+ desc: {
127
+ type: "string"
128
+ },
129
+ type: {
130
+ $ref: "#/definitions/ABIType"
131
+ },
132
+ name: {
133
+ type: "string"
134
+ }
135
+ }
136
+ },
137
+ ABIType: {
138
+ description: "Catch all for fixed length arrays and tuples",
139
+ type: "string"
140
+ }
141
+ };
142
+ var contractSchema = {
143
+ $schema: $schema,
144
+ title: title,
145
+ type: type,
146
+ required: required,
147
+ additionalProperties: additionalProperties,
148
+ properties: properties,
149
+ definitions: definitions
150
+ };
151
+
152
+ exports.$schema = $schema;
153
+ exports.additionalProperties = additionalProperties;
154
+ exports.default = contractSchema;
155
+ exports.definitions = definitions;
156
+ exports.properties = properties;
157
+ exports.required = required;
158
+ exports.title = title;
159
+ exports.type = type;
@@ -0,0 +1,148 @@
1
+ var $schema = "http://json-schema.org/draft-07/schema";
2
+ var title = "AbiContract";
3
+ var type = "object";
4
+ var required = [
5
+ "name",
6
+ "methods"
7
+ ];
8
+ var additionalProperties = true;
9
+ var properties = {
10
+ name: {
11
+ type: "string"
12
+ },
13
+ desc: {
14
+ type: "string"
15
+ },
16
+ methods: {
17
+ type: "array",
18
+ items: {
19
+ $ref: "#/definitions/ContractMethod"
20
+ }
21
+ },
22
+ events: {
23
+ type: "array",
24
+ items: {
25
+ $ref: "#/definitions/Event"
26
+ }
27
+ },
28
+ networks: {
29
+ type: "object",
30
+ additionalProperties: {
31
+ type: "object",
32
+ required: [
33
+ "appID"
34
+ ],
35
+ additionalProperties: true,
36
+ properties: {
37
+ appID: {
38
+ type: "number"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ };
44
+ var definitions = {
45
+ ContractMethod: {
46
+ type: "object",
47
+ additionalProperties: true,
48
+ required: [
49
+ "name",
50
+ "args",
51
+ "returns"
52
+ ],
53
+ properties: {
54
+ name: {
55
+ type: "string"
56
+ },
57
+ args: {
58
+ type: "array",
59
+ items: {
60
+ $ref: "#/definitions/ContractMethodArg"
61
+ }
62
+ },
63
+ desc: {
64
+ type: "string"
65
+ },
66
+ returns: {
67
+ type: "object",
68
+ additionalProperties: true,
69
+ required: [
70
+ "type"
71
+ ],
72
+ properties: {
73
+ desc: {
74
+ type: "string"
75
+ },
76
+ type: {
77
+ $ref: "#/definitions/ABIType"
78
+ }
79
+ }
80
+ },
81
+ readonly: {
82
+ type: "boolean"
83
+ },
84
+ events: {
85
+ type: "array",
86
+ items: {
87
+ $ref: "#/definitions/Event"
88
+ }
89
+ }
90
+ }
91
+ },
92
+ Event: {
93
+ type: "object",
94
+ additionalProperties: true,
95
+ required: [
96
+ "name",
97
+ "args"
98
+ ],
99
+ properties: {
100
+ name: {
101
+ type: "string"
102
+ },
103
+ args: {
104
+ type: "array",
105
+ items: {
106
+ $ref: "#/definitions/ContractMethodArg"
107
+ }
108
+ },
109
+ desc: {
110
+ type: "string"
111
+ }
112
+ }
113
+ },
114
+ ContractMethodArg: {
115
+ type: "object",
116
+ additionalProperties: true,
117
+ required: [
118
+ "name",
119
+ "type"
120
+ ],
121
+ properties: {
122
+ desc: {
123
+ type: "string"
124
+ },
125
+ type: {
126
+ $ref: "#/definitions/ABIType"
127
+ },
128
+ name: {
129
+ type: "string"
130
+ }
131
+ }
132
+ },
133
+ ABIType: {
134
+ description: "Catch all for fixed length arrays and tuples",
135
+ type: "string"
136
+ }
137
+ };
138
+ var contractSchema = {
139
+ $schema: $schema,
140
+ title: title,
141
+ type: type,
142
+ required: required,
143
+ additionalProperties: additionalProperties,
144
+ properties: properties,
145
+ definitions: definitions
146
+ };
147
+
148
+ export { $schema, additionalProperties, contractSchema as default, definitions, properties, required, title, type };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var jsonschema = require('jsonschema');
4
+ var boom = require('../util/boom.cjs');
5
+ var application_schema = require('./application.schema.json.cjs');
6
+ var contract_schema = require('./contract.schema.json.cjs');
7
+
8
+ async function loadApplicationJson(appJsonPath) {
9
+ const fs = await import('fs');
10
+ if (!fs.existsSync(appJsonPath))
11
+ boom.boom(`Could not find application.json file at ${appJsonPath}`);
12
+ const file = JSON.parse(fs.readFileSync(appJsonPath, 'utf-8'));
13
+ return validateApplicationJson(file);
14
+ }
15
+ function validateApplicationJson(json) {
16
+ const validator = new jsonschema.Validator();
17
+ validator.addSchema(contract_schema.default, '/contract.schema.json');
18
+ const result = validator.validate(json, application_schema.default);
19
+ if (!result.valid)
20
+ boom.boom(result.toString());
21
+ return json;
22
+ }
23
+
24
+ exports.loadApplicationJson = loadApplicationJson;
25
+ exports.validateApplicationJson = validateApplicationJson;
package/schema/load.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { AlgoAppSpec } from './application';
2
2
  export declare function loadApplicationJson(appJsonPath: string): Promise<AlgoAppSpec>;
3
3
  export declare function validateApplicationJson(json: unknown): AlgoAppSpec;
4
- //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { Validator } from 'jsonschema';
2
+ import { boom } from '../util/boom.mjs';
3
+ import appJsonSchema from './application.schema.json.mjs';
4
+ import contractSchema from './contract.schema.json.mjs';
5
+
6
+ async function loadApplicationJson(appJsonPath) {
7
+ const fs = await import('fs');
8
+ if (!fs.existsSync(appJsonPath))
9
+ boom(`Could not find application.json file at ${appJsonPath}`);
10
+ const file = JSON.parse(fs.readFileSync(appJsonPath, 'utf-8'));
11
+ return validateApplicationJson(file);
12
+ }
13
+ function validateApplicationJson(json) {
14
+ const validator = new Validator();
15
+ validator.addSchema(contractSchema, '/contract.schema.json');
16
+ const result = validator.validate(json, appJsonSchema);
17
+ if (!result.valid)
18
+ boom(result.toString());
19
+ return json;
20
+ }
21
+
22
+ export { loadApplicationJson, validateApplicationJson };
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=approval-tests.spec.d.ts.map
@@ -0,0 +1 @@
1
+ export declare const setUpLocalnet: () => Promise<import("@algorandfoundation/algokit-utils/types/testing").AlgorandFixture>;