@algorandfoundation/algokit-client-generator 3.0.6 → 4.0.0-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 (90) hide show
  1. package/README.md +4 -2
  2. package/cli.js +1 -1
  3. package/cli.js.map +1 -1
  4. package/cli.mjs +1 -1
  5. package/cli.mjs.map +1 -1
  6. package/client/{call-factory.d.ts → app-client.d.ts} +1 -1
  7. package/client/app-client.js +288 -0
  8. package/client/app-client.js.map +1 -0
  9. package/client/app-client.mjs +286 -0
  10. package/client/app-client.mjs.map +1 -0
  11. package/client/{call-client.d.ts → app-factory.d.ts} +1 -1
  12. package/client/app-factory.js +238 -0
  13. package/client/app-factory.js.map +1 -0
  14. package/client/app-factory.mjs +236 -0
  15. package/client/app-factory.mjs.map +1 -0
  16. package/client/app-types.js +196 -98
  17. package/client/app-types.js.map +1 -1
  18. package/client/app-types.mjs +196 -79
  19. package/client/app-types.mjs.map +1 -1
  20. package/client/call-composer-types.js +23 -53
  21. package/client/call-composer-types.js.map +1 -1
  22. package/client/call-composer-types.mjs +23 -34
  23. package/client/call-composer-types.mjs.map +1 -1
  24. package/client/call-composer.js +43 -57
  25. package/client/call-composer.js.map +1 -1
  26. package/client/call-composer.mjs +45 -40
  27. package/client/call-composer.mjs.map +1 -1
  28. package/client/deploy-types.d.ts +8 -4
  29. package/client/deploy-types.js +52 -34
  30. package/client/deploy-types.js.map +1 -1
  31. package/client/deploy-types.mjs +53 -36
  32. package/client/deploy-types.mjs.map +1 -1
  33. package/client/generate.d.ts +2 -2
  34. package/client/generate.js +18 -6
  35. package/client/generate.js.map +1 -1
  36. package/client/generate.mjs +18 -6
  37. package/client/generate.mjs.map +1 -1
  38. package/client/generator-context.d.ts +4 -4
  39. package/client/generator-context.js +5 -24
  40. package/client/generator-context.js.map +1 -1
  41. package/client/generator-context.mjs +5 -5
  42. package/client/generator-context.mjs.map +1 -1
  43. package/client/helpers/get-call-config-summary.d.ts +8 -3
  44. package/client/helpers/get-call-config-summary.js +22 -20
  45. package/client/helpers/get-call-config-summary.js.map +1 -1
  46. package/client/helpers/get-call-config-summary.mjs +22 -20
  47. package/client/helpers/get-call-config-summary.mjs.map +1 -1
  48. package/client/helpers/get-equivalent-type.d.ts +6 -1
  49. package/client/helpers/get-equivalent-type.js +10 -6
  50. package/client/helpers/get-equivalent-type.js.map +1 -1
  51. package/client/helpers/get-equivalent-type.mjs +10 -6
  52. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  53. package/client/imports.js +18 -24
  54. package/client/imports.js.map +1 -1
  55. package/client/imports.mjs +18 -24
  56. package/client/imports.mjs.map +1 -1
  57. package/client/params-factory.d.ts +3 -0
  58. package/client/params-factory.js +126 -0
  59. package/client/params-factory.js.map +1 -0
  60. package/client/params-factory.mjs +124 -0
  61. package/client/params-factory.mjs.map +1 -0
  62. package/client/utility-types.d.ts +0 -7
  63. package/client/utility-types.js +37 -50
  64. package/client/utility-types.js.map +1 -1
  65. package/client/utility-types.mjs +38 -50
  66. package/client/utility-types.mjs.map +1 -1
  67. package/output/writer.js +17 -3
  68. package/output/writer.js.map +1 -1
  69. package/output/writer.mjs +17 -3
  70. package/output/writer.mjs.map +1 -1
  71. package/package.json +4 -3
  72. package/schema/application.schema.json.js +2 -2
  73. package/schema/application.schema.json.mjs +2 -2
  74. package/schema/arc56.schema.json.js +787 -0
  75. package/schema/arc56.schema.json.js.map +1 -0
  76. package/schema/arc56.schema.json.mjs +780 -0
  77. package/schema/arc56.schema.json.mjs.map +1 -0
  78. package/schema/load.d.ts +3 -3
  79. package/schema/load.js +21 -7
  80. package/schema/load.js.map +1 -1
  81. package/schema/load.mjs +22 -8
  82. package/schema/load.mjs.map +1 -1
  83. package/client/call-client.js +0 -341
  84. package/client/call-client.js.map +0 -1
  85. package/client/call-client.mjs +0 -320
  86. package/client/call-client.mjs.map +0 -1
  87. package/client/call-factory.js +0 -142
  88. package/client/call-factory.js.map +0 -1
  89. package/client/call-factory.mjs +0 -121
  90. package/client/call-factory.mjs.map +0 -1
@@ -0,0 +1,286 @@
1
+ import { jsDoc, IncIndent, NewLine, DecIndentAndCloseBlock, DecIndent, indent } from '../output/writer.mjs';
2
+ import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
3
+ import { getCreateOnCompleteOptions, getCallOnCompleteOptions } from './deploy-types.mjs';
4
+ import { composeMethod } from './call-composer.mjs';
5
+ import { ABIMethod } from 'algosdk';
6
+ import { getEquivalentType } from './helpers/get-equivalent-type.mjs';
7
+
8
+ function* appClient(ctx) {
9
+ const { app, name } = ctx;
10
+ yield* jsDoc(`A client to make calls to the ${app.name} smart contract`);
11
+ yield `export class ${name}Client {`;
12
+ yield IncIndent;
13
+ yield* jsDoc(`The underlying \`AppClient\` for when you want to have more flexibility`);
14
+ yield 'public readonly appClient: AppClient';
15
+ yield NewLine;
16
+ yield `
17
+ /**
18
+ * Creates a new instance of \`${name}Client\`
19
+ *
20
+ * @param appClient An \`AppClient\` instance which has been created with the ${name} app spec
21
+ */
22
+ constructor(appClient: AppClient)
23
+ /**
24
+ * Creates a new instance of \`${name}Client\`
25
+ *
26
+ * @param params The parameters to initialise the app client with
27
+ */
28
+ constructor(params: Expand<Omit<AppClientParams, 'appSpec'>>)
29
+ constructor(appClientOrParams: AppClient | Expand<Omit<AppClientParams, 'appSpec'>>) {
30
+ this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({
31
+ ...appClientOrParams,
32
+ appSpec: APP_SPEC,
33
+ })
34
+ }
35
+
36
+ /**
37
+ * Checks for decode errors on the given return value and maps the return value to the return type for the given method
38
+ * @returns The typed return value or undefined if there was no value
39
+ */
40
+ decodeReturnValue<TSignature extends ${name}NonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {
41
+ return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined
42
+ }
43
+
44
+ /**
45
+ * Returns a new \`${name}Client\` client, resolving the app by creator address and name
46
+ * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
47
+ * @param params The parameters to create the app client
48
+ */
49
+ public static async fromCreatorAndName(params: Expand<Omit<ResolveAppClientByCreatorAndName, 'appSpec'>>): Promise<${name}Client> {
50
+ return new ${name}Client(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
51
+ }
52
+
53
+ /**
54
+ * Returns an \`${name}Client\` instance for the current network based on
55
+ * pre-determined network-specific app IDs specified in the ARC-56 app spec.
56
+ *
57
+ * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
58
+ * @param params The parameters to create the app client
59
+ */
60
+ static async fromNetwork(
61
+ params: Expand<Omit<AppClientParams, 'appSpec' | 'appId'>>
62
+ ): Promise<${name}Client> {
63
+ return new ${name}Client(await AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
64
+ }
65
+
66
+ `;
67
+ yield* params(ctx);
68
+ yield* transactions(ctx);
69
+ yield* send(ctx);
70
+ yield* getStateMethods(ctx);
71
+ yield* composeMethod(ctx);
72
+ yield DecIndentAndCloseBlock;
73
+ }
74
+ function* params(ctx) {
75
+ yield* jsDoc(`Get parameters to define transactions to the current app`);
76
+ yield `readonly params = (($this) => {`;
77
+ yield IncIndent;
78
+ yield `return {`;
79
+ yield IncIndent;
80
+ yield* opMethods(ctx, 'params');
81
+ yield* clearState(ctx, 'params');
82
+ yield* call(ctx, 'params');
83
+ yield* noopMethods(ctx, 'params');
84
+ yield DecIndentAndCloseBlock;
85
+ yield DecIndent;
86
+ yield `})(this)`;
87
+ yield NewLine;
88
+ }
89
+ function* transactions(ctx) {
90
+ yield* jsDoc(`Get parameters to define transactions to the current app`);
91
+ yield `readonly transactions = (($this) => {`;
92
+ yield IncIndent;
93
+ yield `return {`;
94
+ yield IncIndent;
95
+ yield* opMethods(ctx, 'transactions');
96
+ yield* clearState(ctx, 'transactions');
97
+ yield* call(ctx, 'transactions');
98
+ yield* noopMethods(ctx, 'transactions');
99
+ yield DecIndentAndCloseBlock;
100
+ yield DecIndent;
101
+ yield `})(this)`;
102
+ yield NewLine;
103
+ }
104
+ function* send(ctx) {
105
+ yield* jsDoc(`Send calls to the current app`);
106
+ yield `readonly send = (($this) => {`;
107
+ yield IncIndent;
108
+ yield `return {`;
109
+ yield IncIndent;
110
+ yield* opMethods(ctx, 'send');
111
+ yield* clearState(ctx, 'send');
112
+ yield* call(ctx, 'send');
113
+ yield* noopMethods(ctx, 'send');
114
+ yield DecIndentAndCloseBlock;
115
+ yield DecIndent;
116
+ yield `})(this)`;
117
+ yield NewLine;
118
+ }
119
+ function* opMethods(ctx, type) {
120
+ const { app, callConfig } = ctx;
121
+ yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'update', type, true);
122
+ yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete', type);
123
+ yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn', type);
124
+ yield* operationMethods(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut', type);
125
+ }
126
+ function* bareMethodCall({ generator: { app }, name, description, verb, type, includeCompilation, }) {
127
+ const onComplete = verb === 'create' ? getCreateOnCompleteOptions(BARE_CALL, app) : verb === 'call' ? getCallOnCompleteOptions(BARE_CALL, app) : undefined;
128
+ yield* jsDoc({
129
+ description: `${description}.`,
130
+ params: {
131
+ params: `The params for the bare (non-ABI) call`,
132
+ },
133
+ returns: `The ${verb} result`,
134
+ });
135
+ yield `${name}(params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>) {`;
136
+ yield* indent(`return $this.appClient.${type}.bare.${verb}(params)`);
137
+ yield '},';
138
+ }
139
+ function* abiMethodCall({ generator: { app, methodSignatureToUniqueName, name, sanitizer }, method, description, verb, type, includeCompilation, }) {
140
+ const methodSig = new ABIMethod(method).getSignature();
141
+ const uniqueName = methodSignatureToUniqueName[methodSig];
142
+ const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : verb === 'call' ? getCallOnCompleteOptions(methodSig, app) : undefined;
143
+ yield* jsDoc({
144
+ description: `${description} using the ${methodSig} ABI method.`,
145
+ abiDescription: method?.desc,
146
+ params: {
147
+ params: `The params for the smart contract call`,
148
+ },
149
+ returns: `The ${verb} ${type === 'params' ? 'params' : type === 'transactions' ? 'transaction' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,
150
+ });
151
+ const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
152
+ const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
153
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
154
+ yield `${type === 'send' ? 'async ' : ''}${methodName}(params: Expand<CallParams<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''}) {`;
155
+ if (type === 'send') {
156
+ yield* indent(`const result = await $this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`, `return {...result, return: result.return as undefined | MethodReturn<'${methodSigSafe}'>}`);
157
+ }
158
+ else {
159
+ yield* indent(`return $this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`);
160
+ }
161
+ yield '},';
162
+ }
163
+ function* operationMethods(generator, description, methods, verb, type, includeCompilation) {
164
+ if (methods.length) {
165
+ yield* jsDoc(`Gets available ${verb} methods`);
166
+ yield `get ${verb}() {`;
167
+ yield IncIndent;
168
+ yield `return {`;
169
+ yield IncIndent;
170
+ for (const methodSig of methods) {
171
+ if (methodSig === BARE_CALL) {
172
+ yield* bareMethodCall({
173
+ generator,
174
+ name: 'bare',
175
+ description: `${description} using a bare call`,
176
+ verb,
177
+ type,
178
+ includeCompilation,
179
+ });
180
+ }
181
+ else {
182
+ const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig);
183
+ yield* abiMethodCall({
184
+ generator,
185
+ method,
186
+ description,
187
+ verb,
188
+ type,
189
+ includeCompilation,
190
+ });
191
+ }
192
+ }
193
+ yield DecIndentAndCloseBlock;
194
+ yield DecIndent;
195
+ yield '},';
196
+ yield NewLine;
197
+ }
198
+ }
199
+ function* clearState(generator, type) {
200
+ yield* bareMethodCall({
201
+ generator,
202
+ name: 'clearState',
203
+ description: `Makes a clear_state call to an existing instance of the ${generator.app.name} smart contract`,
204
+ verb: 'clearState',
205
+ type,
206
+ });
207
+ yield NewLine;
208
+ }
209
+ function* call(generator, type) {
210
+ if (generator.callConfig.callMethods.includes(BARE_CALL)) {
211
+ yield* bareMethodCall({
212
+ generator,
213
+ name: 'bare',
214
+ description: `Makes a call to the ${generator.app.name} smart contract using a bare call`,
215
+ verb: 'call',
216
+ type,
217
+ });
218
+ yield NewLine;
219
+ }
220
+ }
221
+ function* noopMethods(generator, type) {
222
+ const { app, callConfig } = generator;
223
+ for (const method of app.methods) {
224
+ const methodSignature = new ABIMethod(method).getSignature();
225
+ // Skip methods which don't support a no_op call config
226
+ if (!callConfig.callMethods.includes(methodSignature))
227
+ continue;
228
+ yield* abiMethodCall({
229
+ generator,
230
+ description: `Makes a call to the ${generator.app.name} smart contract`,
231
+ method,
232
+ verb: 'call',
233
+ type,
234
+ includeCompilation: false,
235
+ });
236
+ }
237
+ }
238
+ function* getStateMethods({ app, sanitizer }) {
239
+ if (Object.keys(app.state).length === 0)
240
+ return;
241
+ yield* jsDoc(`Methods to access state for the current ${app.name} app`);
242
+ yield 'state = {';
243
+ yield IncIndent;
244
+ const storageTypes = ['global', 'local', 'box'];
245
+ for (const storageType of storageTypes) {
246
+ const hasKeys = Object.keys(app.state.keys[storageType]).length > 0;
247
+ const hasMaps = Object.keys(app.state.maps[storageType]).length > 0;
248
+ if (!hasKeys && !hasMaps)
249
+ continue;
250
+ yield* jsDoc(`Methods to access ${storageType} state for the current ${app.name} app`);
251
+ yield `${storageType}${storageType === 'local' ? ': (address: string) => ({' : ': {'}`;
252
+ yield IncIndent;
253
+ yield* jsDoc(`Get all current keyed values from ${storageType} state`);
254
+ yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`;
255
+ yield* indent(`const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getAll()`, `return {`, ...Object.keys(app.state.keys[storageType]).map((n) => {
256
+ return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType === 'bytes' ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`;
257
+ }), `}`);
258
+ yield `},`;
259
+ for (const n of Object.keys(app.state.keys[storageType])) {
260
+ const name = sanitizer.makeSafePropertyIdentifier(n);
261
+ const k = app.state.keys[storageType][n];
262
+ yield* jsDoc(`Get the current value of the ${n} key in ${storageType} state`);
263
+ yield `${name}: async (): Promise<${k.valueType === 'bytes' ? 'BinaryState' : `${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`}> => { return ${k.valueType === 'bytes' ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getValue("${name}"))${k.valueType === 'bytes' ? ' as Uint8Array | undefined)' : ` as ${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`} },`;
264
+ }
265
+ for (const n of Object.keys(app.state.maps[storageType])) {
266
+ const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n);
267
+ const m = app.state.maps[storageType][n];
268
+ yield* jsDoc(`Get values from the ${n} map in ${storageType} state`);
269
+ yield `${name}: {`;
270
+ yield IncIndent;
271
+ yield* jsDoc(`Get all current values of the ${n} map in ${storageType} state`);
272
+ yield `getMap: async (): Promise<Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getMap("${sanitizer.makeSafeStringTypeLiteral(n)}")) as Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}> },`;
273
+ yield* jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`);
274
+ yield `value: async (key: ${getEquivalentType(m.keyType, 'input', { app, sanitizer })}): Promise<${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getMapValue("${sanitizer.makeSafeStringTypeLiteral(n)}", key) as ${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined },`;
275
+ yield DecIndent;
276
+ yield `},`;
277
+ }
278
+ yield DecIndent;
279
+ yield `}${storageType === 'local' ? ')' : ''},`;
280
+ }
281
+ yield DecIndentAndCloseBlock;
282
+ yield NewLine;
283
+ }
284
+
285
+ export { appClient };
286
+ //# sourceMappingURL=app-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-client.mjs","sources":["../../src/client/app-client.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { getCallOnCompleteOptions, getCreateOnCompleteOptions } from './deploy-types'\nimport { composeMethod } from './call-composer'\nimport { ABIMethod } from 'algosdk'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { getEquivalentType } from './helpers/get-equivalent-type'\n\nexport function* appClient(ctx: GeneratorContext): DocumentParts {\n const { app, name } = ctx\n\n yield* jsDoc(`A client to make calls to the ${app.name} smart contract`)\n yield `export class ${name}Client {`\n yield IncIndent\n yield* jsDoc(`The underlying \\`AppClient\\` for when you want to have more flexibility`)\n yield 'public readonly appClient: AppClient'\n yield NewLine\n\n yield `\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param appClient An \\`AppClient\\` instance which has been created with the ${name} app spec\n */\n constructor(appClient: AppClient)\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param params The parameters to initialise the app client with\n */\n constructor(params: Expand<Omit<AppClientParams, 'appSpec'>>)\n constructor(appClientOrParams: AppClient | Expand<Omit<AppClientParams, 'appSpec'>>) {\n this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({\n ...appClientOrParams,\n appSpec: APP_SPEC,\n })\n }\n\n /**\n * Checks for decode errors on the given return value and maps the return value to the return type for the given method\n * @returns The typed return value or undefined if there was no value\n */\n decodeReturnValue<TSignature extends ${name}NonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {\n return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined\n }\n\n /**\n * Returns a new \\`${name}Client\\` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n */\n public static async fromCreatorAndName(params: Expand<Omit<ResolveAppClientByCreatorAndName, 'appSpec'>>): Promise<${name}Client> {\n return new ${name}Client(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))\n }\n\n /**\n * Returns an \\`${name}Client\\` instance for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n */\n static async fromNetwork(\n params: Expand<Omit<AppClientParams, 'appSpec' | 'appId'>>\n ): Promise<${name}Client> {\n return new ${name}Client(await AppClient.fromNetwork({...params, appSpec: APP_SPEC}))\n }\n\n `\n\n yield* params(ctx)\n yield* transactions(ctx)\n yield* send(ctx)\n\n yield* getStateMethods(ctx)\n yield* composeMethod(ctx)\n yield DecIndentAndCloseBlock\n}\n\nfunction* params(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Get parameters to define transactions to the current app`)\n yield `readonly params = (($this) => {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield* opMethods(ctx, 'params')\n yield* clearState(ctx, 'params')\n yield* call(ctx, 'params')\n yield* noopMethods(ctx, 'params')\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `})(this)`\n yield NewLine\n}\n\nfunction* transactions(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Get parameters to define transactions to the current app`)\n yield `readonly transactions = (($this) => {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield* opMethods(ctx, 'transactions')\n yield* clearState(ctx, 'transactions')\n yield* call(ctx, 'transactions')\n yield* noopMethods(ctx, 'transactions')\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `})(this)`\n yield NewLine\n}\n\nfunction* send(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Send calls to the current app`)\n yield `readonly send = (($this) => {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield* opMethods(ctx, 'send')\n yield* clearState(ctx, 'send')\n yield* call(ctx, 'send')\n yield* noopMethods(ctx, 'send')\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `})(this)`\n yield NewLine\n}\n\nfunction* opMethods(ctx: GeneratorContext, type: 'params' | 'transactions' | 'send'): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethods(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n type,\n true,\n )\n yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete', type)\n yield* operationMethods(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n callConfig.optInMethods,\n 'optIn',\n type,\n )\n yield* operationMethods(\n ctx,\n `Makes a close out call to an existing instance of the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n type,\n )\n}\n\nfunction* bareMethodCall({\n generator: { app },\n name,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n name: string\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'clearState' | 'call'\n type: 'params' | 'transactions' | 'send'\n includeCompilation?: boolean\n}): DocumentParts {\n const onComplete =\n verb === 'create' ? getCreateOnCompleteOptions(BARE_CALL, app) : verb === 'call' ? getCallOnCompleteOptions(BARE_CALL, app) : undefined\n yield* jsDoc({\n description: `${description}.`,\n params: {\n params: `The params for the bare (non-ABI) call`,\n },\n returns: `The ${verb} result`,\n })\n yield `${name}(params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>) {`\n yield* indent(`return $this.appClient.${type}.bare.${verb}(params)`)\n yield '},'\n}\n\nfunction* abiMethodCall({\n generator: { app, methodSignatureToUniqueName, name, sanitizer },\n method,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n method: Method\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'call'\n type: 'params' | 'transactions' | 'send'\n includeCompilation?: boolean\n}) {\n const methodSig = new ABIMethod(method).getSignature()\n const uniqueName = methodSignatureToUniqueName[methodSig]\n const onComplete =\n verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : verb === 'call' ? getCallOnCompleteOptions(methodSig, app) : undefined\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n abiDescription: method?.desc,\n params: {\n params: `The params for the smart contract call`,\n },\n returns: `The ${verb} ${type === 'params' ? 'params' : type === 'transactions' ? 'transaction' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,\n })\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${type === 'send' ? 'async ' : ''}${methodName}(params: Expand<CallParams<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''}) {`\n if (type === 'send') {\n yield* indent(\n `const result = await $this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n `return {...result, return: result.return as undefined | MethodReturn<'${methodSigSafe}'>}`,\n )\n } else {\n yield* indent(\n `return $this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n )\n }\n yield '},'\n}\n\nfunction* operationMethods(\n generator: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n type: 'params' | 'transactions' | 'send',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `${description} using a bare call`,\n verb,\n type,\n includeCompilation,\n })\n } else {\n const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n yield* abiMethodCall({\n generator,\n method,\n description,\n verb,\n type,\n includeCompilation,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n yield NewLine\n }\n}\n\nfunction* clearState(generator: GeneratorContext, type: 'params' | 'transactions' | 'send'): DocumentParts {\n yield* bareMethodCall({\n generator,\n name: 'clearState',\n description: `Makes a clear_state call to an existing instance of the ${generator.app.name} smart contract`,\n verb: 'clearState',\n type,\n })\n yield NewLine\n}\n\nfunction* call(generator: GeneratorContext, type: 'params' | 'transactions' | 'send'): DocumentParts {\n if (generator.callConfig.callMethods.includes(BARE_CALL)) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `Makes a call to the ${generator.app.name} smart contract using a bare call`,\n verb: 'call',\n type,\n })\n yield NewLine\n }\n}\n\nfunction* noopMethods(generator: GeneratorContext, type: 'params' | 'transactions' | 'send'): DocumentParts {\n const { app, callConfig } = generator\n for (const method of app.methods) {\n const methodSignature = new ABIMethod(method).getSignature()\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n\n yield* abiMethodCall({\n generator,\n description: `Makes a call to the ${generator.app.name} smart contract`,\n method,\n verb: 'call',\n type,\n includeCompilation: false,\n })\n }\n}\n\nfunction* getStateMethods({ app, sanitizer }: GeneratorContext): DocumentParts {\n if (Object.keys(app.state).length === 0) return\n\n yield* jsDoc(`Methods to access state for the current ${app.name} app`)\n yield 'state = {'\n yield IncIndent\n\n const storageTypes = ['global', 'local', 'box'] as const\n\n for (const storageType of storageTypes) {\n const hasKeys = Object.keys(app.state.keys[storageType]).length > 0\n const hasMaps = Object.keys(app.state.maps[storageType]).length > 0\n if (!hasKeys && !hasMaps) continue\n\n yield* jsDoc(`Methods to access ${storageType} state for the current ${app.name} app`)\n yield `${storageType}${storageType === 'local' ? ': (address: string) => ({' : ': {'}`\n yield IncIndent\n\n yield* jsDoc(`Get all current keyed values from ${storageType} state`)\n yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`\n yield* indent(\n `const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getAll()`,\n `return {`,\n ...Object.keys(app.state.keys[storageType]).map((n) => {\n return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType === 'bytes' ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`\n }),\n `}`,\n )\n yield `},`\n\n for (const n of Object.keys(app.state.keys[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(n)\n const k = app.state.keys[storageType][n]\n yield* jsDoc(`Get the current value of the ${n} key in ${storageType} state`)\n yield `${name}: async (): Promise<${k.valueType === 'bytes' ? 'BinaryState' : `${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`}> => { return ${k.valueType === 'bytes' ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getValue(\"${name}\"))${k.valueType === 'bytes' ? ' as Uint8Array | undefined)' : ` as ${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`} },`\n }\n\n for (const n of Object.keys(app.state.maps[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n)\n const m = app.state.maps[storageType][n]\n yield* jsDoc(`Get values from the ${n} map in ${storageType} state`)\n yield `${name}: {`\n yield IncIndent\n\n yield* jsDoc(`Get all current values of the ${n} map in ${storageType} state`)\n yield `getMap: async (): Promise<Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getMap(\"${sanitizer.makeSafeStringTypeLiteral(n)}\")) as Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}> },`\n\n yield* jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`)\n yield `value: async (key: ${getEquivalentType(m.keyType, 'input', { app, sanitizer })}): Promise<${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(address)' : ''}.getMapValue(\"${sanitizer.makeSafeStringTypeLiteral(n)}\", key) as ${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined },`\n\n yield DecIndent\n yield `},`\n }\n\n yield DecIndent\n yield `}${storageType === 'local' ? ')' : ''},`\n }\n\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n"],"names":[],"mappings":";;;;;;;AASe,UAAE,SAAS,CAAC,GAAqB,EAAA;AAC9C,IAAA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;IAEzB,OAAO,KAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC,CAAA;IACxE,MAAM,CAAA,aAAA,EAAgB,IAAI,CAAA,QAAA,CAAU,CAAA;AACpC,IAAA,MAAM,SAAS,CAAA;AACf,IAAA,OAAO,KAAK,CAAC,CAAA,uEAAA,CAAyE,CAAC,CAAA;AACvF,IAAA,MAAM,sCAAsC,CAAA;AAC5C,IAAA,MAAM,OAAO,CAAA;IAEb,MAAM,CAAA;;qCAE6B,IAAI,CAAA;;oFAE2C,IAAI,CAAA;;;;qCAInD,IAAI,CAAA;;;;;;;;;;;;;;;;2CAgBE,IAAI,CAAA;;;;;yBAKtB,IAAI,CAAA;;;;yHAI4F,IAAI,CAAA;mBAC1G,IAAI,CAAA;;;;sBAID,IAAI,CAAA;;;;;;;;iBAQT,IAAI,CAAA;mBACF,IAAI,CAAA;;;GAGpB,CAAA;AAED,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;AAClB,IAAA,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;AACxB,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAEhB,IAAA,OAAO,eAAe,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;"}
@@ -1,3 +1,3 @@
1
1
  import { DocumentParts } from '../output/writer';
2
2
  import { GeneratorContext } from './generator-context';
3
- export declare function callClient(ctx: GeneratorContext): DocumentParts;
3
+ export declare function appFactory(ctx: GeneratorContext): DocumentParts;
@@ -0,0 +1,238 @@
1
+ 'use strict';
2
+
3
+ var writer = require('../output/writer.js');
4
+ var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
5
+ var deployTypes = require('./deploy-types.js');
6
+ var algosdk = require('algosdk');
7
+
8
+ function* appFactory(ctx) {
9
+ const { app, name } = ctx;
10
+ yield* writer.jsDoc(`A factory to create and deploy one or more instance of the ${app.name} smart contract and to create one or more app clients to interact with those (or other) app instances`);
11
+ yield `export class ${name}Factory {`;
12
+ yield writer.IncIndent;
13
+ yield* writer.jsDoc(`The underlying \`AppFactory\` for when you want to have more flexibility`);
14
+ yield 'public readonly appFactory: AppFactory';
15
+ yield writer.NewLine;
16
+ yield* writer.jsDoc({
17
+ description: `Creates a new instance of \`${name}Factory\``,
18
+ params: {
19
+ params: 'The parameters to initialise the app factory with',
20
+ },
21
+ });
22
+ yield `
23
+ constructor(params: Expand<Omit<AppFactoryParams, 'appSpec'>>) {
24
+ this.appFactory = new AppFactory({
25
+ ...params,
26
+ appSpec: APP_SPEC,
27
+ })
28
+ }
29
+
30
+ /**
31
+ * Returns a new \`AppClient\` client for an app instance of the given ID.
32
+ *
33
+ * Automatically populates appName, defaultSender and source maps from the factory
34
+ * if not specified in the params.
35
+ * @param params The parameters to create the app client
36
+ * @returns The \`AppClient\`
37
+ */
38
+ public getAppClientById(params: Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>) {
39
+ return new ${name}Client(this.appFactory.getAppClientById(params))
40
+ }
41
+
42
+ /**
43
+ * Returns a new \`AppClient\` client, resolving the app by creator address and name
44
+ * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
45
+ *
46
+ * Automatically populates appName, defaultSender and source maps from the factory
47
+ * if not specified in the params.
48
+ * @param params The parameters to create the app client
49
+ * @returns The \`AppClient\`
50
+ */
51
+ public async getAppClientByCreatorAddressAndName(
52
+ params: Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'> & ResolveAppClientByCreatorAndName>,
53
+ ) {
54
+ return new ${name}Client(await this.appFactory.getAppClientByCreatorAddressAndName(params))
55
+ }
56
+ `;
57
+ yield* deployMethod(ctx);
58
+ yield* params(ctx);
59
+ yield* send(ctx);
60
+ yield writer.DecIndentAndCloseBlock;
61
+ }
62
+ function* params(ctx) {
63
+ yield* writer.jsDoc(`Get parameters to define transactions to the current app`);
64
+ yield `readonly params = (($this) => {`;
65
+ yield writer.IncIndent;
66
+ yield `return {`;
67
+ yield writer.IncIndent;
68
+ yield* paramMethods(ctx);
69
+ yield writer.DecIndentAndCloseBlock;
70
+ yield writer.DecIndent;
71
+ yield `})(this)`;
72
+ yield writer.NewLine;
73
+ }
74
+ function* send(ctx) {
75
+ yield* writer.jsDoc(`Send calls to the current app`);
76
+ yield `readonly send = (($this) => {`;
77
+ yield writer.IncIndent;
78
+ yield `return {`;
79
+ yield writer.IncIndent;
80
+ yield* createMethods(ctx);
81
+ yield writer.DecIndentAndCloseBlock;
82
+ yield writer.DecIndent;
83
+ yield `})(this)`;
84
+ yield writer.NewLine;
85
+ }
86
+ function* createMethods(generator) {
87
+ const { app } = generator;
88
+ if (generator.callConfig.createMethods.length) {
89
+ yield* writer.jsDoc(`Gets available create methods`);
90
+ yield `get create() {`;
91
+ yield writer.IncIndent;
92
+ yield `return {`;
93
+ yield writer.IncIndent;
94
+ for (const methodSig of generator.callConfig.createMethods) {
95
+ if (methodSig === getCallConfigSummary.BARE_CALL) {
96
+ yield* bareMethodCallParams({
97
+ generator,
98
+ name: 'bare',
99
+ description: `Creates a new instance of the ${app.name} smart contract using a bare call`,
100
+ verb: 'create',
101
+ type: 'send',
102
+ includeCompilation: true,
103
+ });
104
+ }
105
+ else {
106
+ const method = generator.app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig);
107
+ yield* abiMethodCallParams({
108
+ generator,
109
+ method,
110
+ description: `Creates a new instance of the ${app.name} smart contract using an ABI method call`,
111
+ verb: 'create',
112
+ type: 'send',
113
+ includeCompilation: true,
114
+ });
115
+ }
116
+ }
117
+ yield writer.DecIndentAndCloseBlock;
118
+ yield writer.DecIndent;
119
+ yield '},';
120
+ yield writer.NewLine;
121
+ }
122
+ }
123
+ function* paramMethods(ctx) {
124
+ const { app, callConfig } = ctx;
125
+ yield* operationMethods(ctx, `Creates a new instance of the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
126
+ yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'deployUpdate', true);
127
+ yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'deployDelete');
128
+ }
129
+ function* bareMethodCallParams({ generator: { app, name: clientName }, name, description, verb, type, includeCompilation, }) {
130
+ const onComplete = verb === 'create' ? deployTypes.getCreateOnCompleteOptions(getCallConfigSummary.BARE_CALL, app) : undefined;
131
+ yield* writer.jsDoc({
132
+ description: `${description}.`,
133
+ params: {
134
+ params: `The params for the bare (non-ABI) call`,
135
+ },
136
+ returns: type === 'params' ? `The params for a ${verb} call` : `The ${verb} result`,
137
+ });
138
+ yield `${type === 'send' ? 'async ' : ''}${name}(params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>) {`;
139
+ if (type === 'params') {
140
+ yield* writer.indent(`return $this.appFactory.params.bare.${verb}(params)`);
141
+ }
142
+ else {
143
+ yield* writer.indent(`const result = await $this.appFactory.create(params)`, `return { result: result.result, app: new ${clientName}Client(result.app) }`);
144
+ }
145
+ yield '},';
146
+ }
147
+ function* abiMethodCallParams({ generator: { app, methodSignatureToUniqueName, name, sanitizer }, method, description, verb, type, includeCompilation, }) {
148
+ const methodSig = new algosdk.ABIMethod(method).getSignature();
149
+ const uniqueName = methodSignatureToUniqueName[methodSig];
150
+ const onComplete = verb === 'create' ? deployTypes.getCreateOnCompleteOptions(methodSig, app) : undefined;
151
+ yield* writer.jsDoc({
152
+ description: `${description} using the ${methodSig} ABI method.`,
153
+ abiDescription: method?.desc,
154
+ params: {
155
+ params: `The params for the smart contract call`,
156
+ },
157
+ returns: `The ${verb} ${type === 'params' ? 'params' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,
158
+ });
159
+ const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
160
+ const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
161
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
162
+ yield `${type === 'send' ? 'async ' : ''}${methodName}(params: Expand<CallParams<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''}) {`;
163
+ if (type === 'params') {
164
+ yield* writer.indent(`return $this.appFactory.params.${verb}(${name}ParamsFactory.${verb == 'deployDelete' ? 'delete' : verb === 'deployUpdate' ? 'update' : verb}${methodNameAccessor}(params))`);
165
+ }
166
+ else {
167
+ yield* writer.indent(`const result = await $this.appFactory.create(${name}ParamsFactory.${verb}${methodNameAccessor}(params))`, `return { result: { ...result.result, return: result.result.return as undefined | MethodReturn<'${methodSigSafe}'> }, app: new ${name}Client(result.app) }`);
168
+ }
169
+ yield '},';
170
+ }
171
+ function* operationMethods(generator, description, methods, verb, includeCompilation) {
172
+ if (methods.length) {
173
+ yield* writer.jsDoc(`Gets available ${verb} methods`);
174
+ yield `get ${verb}() {`;
175
+ yield writer.IncIndent;
176
+ yield `return {`;
177
+ yield writer.IncIndent;
178
+ for (const methodSig of methods) {
179
+ if (methodSig === getCallConfigSummary.BARE_CALL) {
180
+ yield* bareMethodCallParams({
181
+ generator,
182
+ name: 'bare',
183
+ description: `${description} using a bare call`,
184
+ verb,
185
+ type: 'params',
186
+ includeCompilation,
187
+ });
188
+ }
189
+ else {
190
+ const method = generator.app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig);
191
+ yield* abiMethodCallParams({
192
+ generator,
193
+ method,
194
+ description,
195
+ verb,
196
+ type: 'params',
197
+ includeCompilation,
198
+ });
199
+ }
200
+ }
201
+ yield writer.DecIndentAndCloseBlock;
202
+ yield writer.DecIndent;
203
+ yield '},';
204
+ yield writer.NewLine;
205
+ }
206
+ }
207
+ function* deployMethod(ctx) {
208
+ const { app, callConfig, name } = ctx;
209
+ yield* writer.jsDoc({
210
+ description: `Idempotently deploys the ${app.name} smart contract.`,
211
+ params: {
212
+ params: 'The arguments for the contract calls and any additional parameters for the call',
213
+ },
214
+ returns: 'The deployment result',
215
+ });
216
+ yield `public async deploy(params: ${name}DeployParams = {}) {`;
217
+ yield writer.IncIndent;
218
+ yield `const result = await this.appFactory.deploy({`;
219
+ yield writer.IncIndent;
220
+ yield `...params,`;
221
+ if (callConfig.createMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).length) {
222
+ yield `createParams: params.createParams?.method ? ${name}ParamsFactory.create._resolveByMethod(params.createParams) : params.createParams,`;
223
+ }
224
+ if (callConfig.updateMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).length) {
225
+ yield `updateParams: params.updateParams?.method ? ${name}ParamsFactory.update._resolveByMethod(params.updateParams) : params.updateParams,`;
226
+ }
227
+ if (callConfig.deleteMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).length) {
228
+ yield `deleteParams: params.deleteParams?.method ? ${name}ParamsFactory.delete._resolveByMethod(params.deleteParams) : params.deleteParams,`;
229
+ }
230
+ yield writer.DecIndent;
231
+ yield `})`;
232
+ yield `return { result: result.result, app: new ${name}Client(result.app) }`;
233
+ yield writer.DecIndentAndCloseBlock;
234
+ yield writer.NewLine;
235
+ }
236
+
237
+ exports.appFactory = appFactory;
238
+ //# sourceMappingURL=app-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-factory.js","sources":["../../src/client/app-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { ABIMethod } from 'algosdk'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\n\nexport function* appFactory(ctx: GeneratorContext): DocumentParts {\n const { app, name } = ctx\n\n yield* jsDoc(\n `A factory to create and deploy one or more instance of the ${app.name} smart contract and to create one or more app clients to interact with those (or other) app instances`,\n )\n yield `export class ${name}Factory {`\n yield IncIndent\n yield* jsDoc(`The underlying \\`AppFactory\\` for when you want to have more flexibility`)\n yield 'public readonly appFactory: AppFactory'\n yield NewLine\n\n yield* jsDoc({\n description: `Creates a new instance of \\`${name}Factory\\``,\n params: {\n params: 'The parameters to initialise the app factory with',\n },\n })\n\n yield `\n constructor(params: Expand<Omit<AppFactoryParams, 'appSpec'>>) {\n this.appFactory = new AppFactory({\n ...params,\n appSpec: APP_SPEC,\n })\n }\n\n /**\n * Returns a new \\`AppClient\\` client for an app instance of the given ID.\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The \\`AppClient\\`\n */\n public getAppClientById(params: Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>) {\n return new ${name}Client(this.appFactory.getAppClientById(params))\n }\n\n /**\n * Returns a new \\`AppClient\\` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n *\n * Automatically populates appName, defaultSender and source maps from the factory\n * if not specified in the params.\n * @param params The parameters to create the app client\n * @returns The \\`AppClient\\`\n */\n public async getAppClientByCreatorAddressAndName(\n params: Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'> & ResolveAppClientByCreatorAndName>,\n ) {\n return new ${name}Client(await this.appFactory.getAppClientByCreatorAddressAndName(params))\n }\n `\n\n yield* deployMethod(ctx)\n yield* params(ctx)\n yield* send(ctx)\n yield DecIndentAndCloseBlock\n}\n\nfunction* params(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Get parameters to define transactions to the current app`)\n yield `readonly params = (($this) => {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield* paramMethods(ctx)\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `})(this)`\n yield NewLine\n}\n\nfunction* send(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Send calls to the current app`)\n yield `readonly send = (($this) => {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield* createMethods(ctx)\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `})(this)`\n yield NewLine\n}\n\nfunction* createMethods(generator: GeneratorContext): DocumentParts {\n const { app } = generator\n if (generator.callConfig.createMethods.length) {\n yield* jsDoc(`Gets available create methods`)\n yield `get create() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const methodSig of generator.callConfig.createMethods) {\n if (methodSig === BARE_CALL) {\n yield* bareMethodCallParams({\n generator,\n name: 'bare',\n description: `Creates a new instance of the ${app.name} smart contract using a bare call`,\n verb: 'create',\n type: 'send',\n includeCompilation: true,\n })\n } else {\n const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n yield* abiMethodCallParams({\n generator,\n method,\n description: `Creates a new instance of the ${app.name} smart contract using an ABI method call`,\n verb: 'create',\n type: 'send',\n includeCompilation: true,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n yield NewLine\n }\n}\n\nfunction* paramMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethods(ctx, `Creates a new instance of the ${app.name} smart contract`, callConfig.createMethods, 'create', true)\n\n yield* operationMethods(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'deployUpdate',\n true,\n )\n yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'deployDelete')\n}\n\nfunction* bareMethodCallParams({\n generator: { app, name: clientName },\n name,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n name: string\n description: string\n verb: 'create' | 'deployUpdate' | 'deployDelete'\n type: 'params' | 'send'\n includeCompilation?: boolean\n}): DocumentParts {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(BARE_CALL, app) : undefined\n yield* jsDoc({\n description: `${description}.`,\n params: {\n params: `The params for the bare (non-ABI) call`,\n },\n returns: type === 'params' ? `The params for a ${verb} call` : `The ${verb} result`,\n })\n yield `${type === 'send' ? 'async ' : ''}${name}(params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>) {`\n if (type === 'params') {\n yield* indent(`return $this.appFactory.params.bare.${verb}(params)`)\n } else {\n yield* indent(\n `const result = await $this.appFactory.create(params)`,\n `return { result: result.result, app: new ${clientName}Client(result.app) }`,\n )\n }\n yield '},'\n}\n\nfunction* abiMethodCallParams({\n generator: { app, methodSignatureToUniqueName, name, sanitizer },\n method,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n method: Method\n description: string\n verb: 'create' | 'deployUpdate' | 'deployDelete'\n type: 'params' | 'send'\n includeCompilation?: boolean\n}) {\n const methodSig = new ABIMethod(method).getSignature()\n const uniqueName = methodSignatureToUniqueName[methodSig]\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n abiDescription: method?.desc,\n params: {\n params: `The params for the smart contract call`,\n },\n returns: `The ${verb} ${type === 'params' ? 'params' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,\n })\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${type === 'send' ? 'async ' : ''}${methodName}(params: Expand<CallParams<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & ExecuteParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''}) {`\n if (type === 'params') {\n yield* indent(\n `return $this.appFactory.params.${verb}(${name}ParamsFactory.${verb == 'deployDelete' ? 'delete' : verb === 'deployUpdate' ? 'update' : verb}${methodNameAccessor}(params))`,\n )\n } else {\n yield* indent(\n `const result = await $this.appFactory.create(${name}ParamsFactory.${verb}${methodNameAccessor}(params))`,\n `return { result: { ...result.result, return: result.result.return as undefined | MethodReturn<'${methodSigSafe}'> }, app: new ${name}Client(result.app) }`,\n )\n }\n yield '},'\n}\n\nfunction* operationMethods(\n generator: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'deployUpdate' | 'deployDelete',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) {\n yield* bareMethodCallParams({\n generator,\n name: 'bare',\n description: `${description} using a bare call`,\n verb,\n type: 'params',\n includeCompilation,\n })\n } else {\n const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n yield* abiMethodCallParams({\n generator,\n method,\n description,\n verb,\n type: 'params',\n includeCompilation,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n yield NewLine\n }\n}\n\nfunction* deployMethod(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig, name } = ctx\n yield* jsDoc({\n description: `Idempotently deploys the ${app.name} smart contract.`,\n params: {\n params: 'The arguments for the contract calls and any additional parameters for the call',\n },\n returns: 'The deployment result',\n })\n yield `public async deploy(params: ${name}DeployParams = {}) {`\n yield IncIndent\n\n yield `const result = await this.appFactory.deploy({`\n yield IncIndent\n yield `...params,`\n if (callConfig.createMethods.filter((m) => m !== BARE_CALL).length) {\n yield `createParams: params.createParams?.method ? ${name}ParamsFactory.create._resolveByMethod(params.createParams) : params.createParams,`\n }\n if (callConfig.updateMethods.filter((m) => m !== BARE_CALL).length) {\n yield `updateParams: params.updateParams?.method ? ${name}ParamsFactory.update._resolveByMethod(params.updateParams) : params.updateParams,`\n }\n if (callConfig.deleteMethods.filter((m) => m !== BARE_CALL).length) {\n yield `deleteParams: params.deleteParams?.method ? ${name}ParamsFactory.delete._resolveByMethod(params.deleteParams) : params.deleteParams,`\n }\n yield DecIndent\n yield `})`\n yield `return { result: result.result, app: new ${name}Client(result.app) }`\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n"],"names":["jsDoc","IncIndent","NewLine","DecIndentAndCloseBlock","DecIndent","BARE_CALL","ABIMethod","getCreateOnCompleteOptions","indent"],"mappings":";;;;;;;AAOe,UAAE,UAAU,CAAC,GAAqB,EAAA;AAC/C,IAAA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;IAEzB,OAAOA,YAAK,CACV,CAAA,2DAAA,EAA8D,GAAG,CAAC,IAAI,CAAuG,qGAAA,CAAA,CAC9K,CAAA;IACD,MAAM,CAAA,aAAA,EAAgB,IAAI,CAAA,SAAA,CAAW,CAAA;AACrC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