@algorandfoundation/algokit-client-generator 6.0.0-beta.2 → 6.0.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 (62) hide show
  1. package/README.md +54 -4
  2. package/cli.d.ts +3 -3
  3. package/cli.js +12 -4
  4. package/cli.js.map +1 -1
  5. package/cli.mjs +13 -5
  6. package/cli.mjs.map +1 -1
  7. package/client/app-client.js +4 -2
  8. package/client/app-client.js.map +1 -1
  9. package/client/app-client.mjs +4 -2
  10. package/client/app-client.mjs.map +1 -1
  11. package/client/app-factory.js.map +1 -1
  12. package/client/app-factory.mjs.map +1 -1
  13. package/client/app-types.js.map +1 -1
  14. package/client/app-types.mjs.map +1 -1
  15. package/client/call-composer-types.js +7 -5
  16. package/client/call-composer-types.js.map +1 -1
  17. package/client/call-composer-types.mjs +7 -5
  18. package/client/call-composer-types.mjs.map +1 -1
  19. package/client/call-composer.js +4 -2
  20. package/client/call-composer.js.map +1 -1
  21. package/client/call-composer.mjs +4 -2
  22. package/client/call-composer.mjs.map +1 -1
  23. package/client/deploy-types.js.map +1 -1
  24. package/client/deploy-types.mjs.map +1 -1
  25. package/client/generate.d.ts +1 -1
  26. package/client/generate.js +59 -8
  27. package/client/generate.js.map +1 -1
  28. package/client/generate.mjs +59 -8
  29. package/client/generate.mjs.map +1 -1
  30. package/client/generator-context.d.ts +10 -7
  31. package/client/generator-context.js +7 -0
  32. package/client/generator-context.js.map +1 -1
  33. package/client/generator-context.mjs +7 -1
  34. package/client/generator-context.mjs.map +1 -1
  35. package/client/helpers/get-call-config-summary.js.map +1 -1
  36. package/client/helpers/get-call-config-summary.mjs.map +1 -1
  37. package/client/helpers/get-equivalent-type.js.map +1 -1
  38. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  39. package/client/imports.d.ts +2 -1
  40. package/client/imports.js +2 -3
  41. package/client/imports.js.map +1 -1
  42. package/client/imports.mjs +2 -3
  43. package/client/imports.mjs.map +1 -1
  44. package/client/params-factory.js +5 -3
  45. package/client/params-factory.js.map +1 -1
  46. package/client/params-factory.mjs +5 -3
  47. package/client/params-factory.mjs.map +1 -1
  48. package/output/writer.js.map +1 -1
  49. package/output/writer.mjs.map +1 -1
  50. package/package.json +1 -7
  51. package/schema/load.js.map +1 -1
  52. package/schema/load.mjs.map +1 -1
  53. package/util/boom.js.map +1 -1
  54. package/util/boom.mjs.map +1 -1
  55. package/util/color-console.js.map +1 -1
  56. package/util/color-console.mjs.map +1 -1
  57. package/util/sanitization.d.ts +2 -3
  58. package/util/sanitization.js +1 -1
  59. package/util/sanitization.js.map +1 -1
  60. package/util/sanitization.mjs +1 -1
  61. package/util/sanitization.mjs.map +1 -1
  62. package/tests/approval-tests.spec.d.ts +0 -1
@@ -15,30 +15,81 @@ function convertStructs(s, sanitizer) {
15
15
  type: typeof type === 'string' ? type : convertStructs(type, sanitizer),
16
16
  }));
17
17
  }
18
- function* generate(app, options = { preserveNames: false }) {
19
- const ctx = createGeneratorContext(app, options);
18
+ function shrinkAppSpec(app, options) {
19
+ const strippedAppSpec = structuredClone(app);
20
+ // Only keep the source info if it is needed for error mapping
21
+ const shrinkSourceInfo = (sourceInfo) => {
22
+ return sourceInfo
23
+ .filter((entry) => entry.errorMessage)
24
+ .map((entry) => ({
25
+ pc: entry.pc,
26
+ errorMessage: entry.errorMessage,
27
+ // Keep minimal context for error mapping if available
28
+ ...(entry.teal !== undefined && { teal: entry.teal }),
29
+ }));
30
+ };
31
+ // Keep only source info entries that can be used for approval and clear program error mapping
32
+ if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {
33
+ strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo);
34
+ }
35
+ if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {
36
+ strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo);
37
+ }
38
+ if (strippedAppSpec.compilerInfo) {
39
+ delete strippedAppSpec.compilerInfo;
40
+ }
41
+ // These are used for deploying but not for calling deployed apps
42
+ if (options.mode === 'minimal') {
43
+ if (strippedAppSpec.source) {
44
+ delete strippedAppSpec.source;
45
+ }
46
+ if (strippedAppSpec.byteCode) {
47
+ delete strippedAppSpec.byteCode;
48
+ }
49
+ if (strippedAppSpec.templateVariables) {
50
+ delete strippedAppSpec.templateVariables;
51
+ }
52
+ if (strippedAppSpec.scratchVariables) {
53
+ delete strippedAppSpec.scratchVariables;
54
+ }
55
+ }
56
+ return strippedAppSpec;
57
+ }
58
+ function* generate(app, options) {
59
+ const resolvedOptions = {
60
+ // Set defaults
61
+ preserveNames: false,
62
+ mode: 'full',
63
+ ...options,
64
+ };
65
+ const reduceAppSpec = shrinkAppSpec(app, resolvedOptions);
66
+ const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions);
20
67
  yield `/* eslint-disable */`;
21
68
  yield `/**`;
22
69
  yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`;
23
70
  yield ` * DO NOT MODIFY IT BY HAND.`;
24
71
  yield ` * requires: @algorandfoundation/algokit-utils: ^7`;
25
72
  yield ` */`;
26
- yield* imports();
73
+ yield* imports(ctx);
27
74
  // Change the structs definition to sanitize property names according to the defined rules
28
75
  // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp
29
- app.structs = Object.fromEntries(Object.keys(app.structs).map((key) => [key, convertStructs(app.structs[key], ctx.sanitizer)]));
30
- yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(app), ' as unknown as Arc56Contract');
76
+ reduceAppSpec.structs = Object.fromEntries(Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]));
77
+ yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract');
31
78
  yield NewLine;
32
79
  yield* utilityTypes();
33
80
  yield NewLine;
34
81
  yield* appTypes(ctx);
35
- yield* deployTypes(ctx);
82
+ if (ctx.mode === 'full') {
83
+ yield* deployTypes(ctx);
84
+ }
36
85
  yield NewLine;
37
86
  // Write a call factory
38
87
  yield* paramsFactory(ctx);
39
88
  yield NewLine;
40
- // Write a factory
41
- yield* appFactory(ctx);
89
+ // Write a factory in full mode
90
+ if (ctx.mode === 'full') {
91
+ yield* appFactory(ctx);
92
+ }
42
93
  // Write a client
43
94
  yield* appClient(ctx);
44
95
  yield* callComposerType(ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.mjs","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nexport function* generate(app: Arc56Contract, options: GeneratorOptions = { preserveNames: false }): DocumentParts {\n const ctx = createGeneratorContext(app, options)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports()\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n app.structs = Object.fromEntries(Object.keys(app.structs).map((key) => [key, convertStructs(app.structs[key], ctx.sanitizer)]))\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(app), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n yield* deployTypes(ctx)\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory\n yield* appFactory(ctx)\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,SAAS,cAAc,CAAC,CAAgB,EAAE,SAAoB,EAAA;AAC5D,IAAA,OAAO,CAAC,CAAC,GAAG,CACV,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MACZ;AACC,QAAA,IAAI,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC;AAChD,QAAA,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC;AACxE,KAAA,CAAuB,CAC3B;AACH;AAEe,UAAE,QAAQ,CAAC,GAAkB,EAAE,OAAA,GAA4B,EAAE,aAAa,EAAE,KAAK,EAAE,EAAA;IAChG,MAAM,GAAG,GAAG,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC;AAChD,IAAA,MAAM,sBAAsB;AAC5B,IAAA,MAAM,KAAK;AACX,IAAA,MAAM,2FAA2F;AACjG,IAAA,MAAM,8BAA8B;AACpC,IAAA,MAAM,oDAAoD;AAC1D,IAAA,MAAM,KAAK;AAEX,IAAA,OAAO,OAAO,EAAE;;;AAGhB,IAAA,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC/H,IAAA,OAAO,MAAM,CAAC,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,8BAA8B,CAAC;AAC7G,IAAA,MAAM,OAAO;AAEb,IAAA,OAAO,YAAY,EAAE;AACrB,IAAA,MAAM,OAAO;AACb,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AACpB,IAAA,OAAO,WAAW,CAAC,GAAG,CAAC;AACvB,IAAA,MAAM,OAAO;;AAGb,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAM,OAAO;;AAEb,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC;;AAEtB,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"generate.mjs","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, ProgramSourceInfo, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nfunction shrinkAppSpec(app: Arc56Contract, options: GeneratorOptions): Arc56Contract {\n const strippedAppSpec = structuredClone(app)\n\n // Only keep the source info if it is needed for error mapping\n const shrinkSourceInfo = (sourceInfo: ProgramSourceInfo['sourceInfo']) => {\n return sourceInfo\n .filter((entry) => entry.errorMessage)\n .map((entry) => ({\n pc: entry.pc,\n errorMessage: entry.errorMessage,\n // Keep minimal context for error mapping if available\n ...(entry.teal !== undefined && { teal: entry.teal }),\n }))\n }\n\n // Keep only source info entries that can be used for approval and clear program error mapping\n if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo)\n }\n\n if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo)\n }\n\n if (strippedAppSpec.compilerInfo) {\n delete strippedAppSpec.compilerInfo\n }\n\n // These are used for deploying but not for calling deployed apps\n if (options.mode === 'minimal') {\n if (strippedAppSpec.source) {\n delete strippedAppSpec.source\n }\n if (strippedAppSpec.byteCode) {\n delete strippedAppSpec.byteCode\n }\n if (strippedAppSpec.templateVariables) {\n delete strippedAppSpec.templateVariables\n }\n if (strippedAppSpec.scratchVariables) {\n delete strippedAppSpec.scratchVariables\n }\n }\n return strippedAppSpec\n}\n\nexport function* generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts {\n const resolvedOptions: GeneratorOptions = {\n // Set defaults\n preserveNames: false,\n mode: 'full',\n ...options,\n }\n const reduceAppSpec = shrinkAppSpec(app, resolvedOptions)\n\n const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports(ctx)\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n reduceAppSpec.structs = Object.fromEntries(\n Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]),\n )\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n\n if (ctx.mode === 'full') {\n yield* deployTypes(ctx)\n }\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory in full mode\n if (ctx.mode === 'full') {\n yield* appFactory(ctx)\n }\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,SAAS,cAAc,CAAC,CAAgB,EAAE,SAAoB,EAAA;AAC5D,IAAA,OAAO,CAAC,CAAC,GAAG,CACV,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MACZ;AACC,QAAA,IAAI,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC;AAChD,QAAA,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC;AACxE,KAAA,CAAuB,CAC3B;AACH;AAEA,SAAS,aAAa,CAAC,GAAkB,EAAE,OAAyB,EAAA;AAClE,IAAA,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC;;AAG5C,IAAA,MAAM,gBAAgB,GAAG,CAAC,UAA2C,KAAI;AACvE,QAAA,OAAO;aACJ,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,YAAY;AACpC,aAAA,GAAG,CAAC,CAAC,KAAK,MAAM;YACf,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,YAAY,EAAE,KAAK,CAAC,YAAY;;AAEhC,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,SAA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AC,GAAG,CAAC;AAC9B;;;;"}
@@ -1,20 +1,23 @@
1
1
  import { CallConfigSummary } from './helpers/get-call-config-summary';
2
2
  import { Sanitizer } from '../util/sanitization';
3
3
  import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
4
+ declare const GenerateMode: {
5
+ readonly FULL: "full";
6
+ readonly MINIMAL: "minimal";
7
+ };
8
+ export type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode];
9
+ export declare const generateModes: ("full" | "minimal")[];
4
10
  export type GeneratorContext = {
5
11
  app: Arc56Contract;
6
12
  name: string;
7
13
  callConfig: CallConfigSummary;
8
14
  methodSignatureToUniqueName: Record<string, string>;
9
15
  sanitizer: Sanitizer;
16
+ mode: GenerateMode;
10
17
  };
11
18
  export type GeneratorOptions = {
12
19
  preserveNames: boolean;
20
+ mode: GenerateMode;
13
21
  };
14
- export declare const createGeneratorContext: (app: Arc56Contract, options: GeneratorOptions) => {
15
- sanitizer: Sanitizer;
16
- app: Arc56Contract;
17
- name: string;
18
- callConfig: CallConfigSummary;
19
- methodSignatureToUniqueName: Record<string, string>;
20
- };
22
+ export declare const createGeneratorContext: (app: Arc56Contract, options: GeneratorOptions) => GeneratorContext;
23
+ export {};
@@ -4,6 +4,11 @@ var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
4
4
  var sanitization = require('../util/sanitization.js');
5
5
  var algosdk = require('algosdk');
6
6
 
7
+ const GenerateMode = {
8
+ FULL: 'full',
9
+ MINIMAL: 'minimal',
10
+ };
11
+ const generateModes = Object.values(GenerateMode);
7
12
  const createGeneratorContext = (app, options) => {
8
13
  const sanitizer = sanitization.getSanitizer(options);
9
14
  return {
@@ -16,8 +21,10 @@ const createGeneratorContext = (app, options) => {
16
21
  acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
17
22
  return acc;
18
23
  }, {}),
24
+ mode: options.mode,
19
25
  };
20
26
  };
21
27
 
22
28
  exports.createGeneratorContext = createGeneratorContext;
29
+ exports.generateModes = generateModes;
23
30
  //# sourceMappingURL=generator-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions) => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n }\n}\n"],"names":["getSanitizer","getCallConfigSummary","ABIMethod"],"mappings":";;;;;;MAiBa,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAI;AACtF,IAAA,MAAM,SAAS,GAAGA,yBAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAEC,yCAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAIC,iBAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;SACX,EACD,EAA4B,CAC7B;KACF;AACH;;;;"}
1
+ {"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":["getSanitizer","getCallConfigSummary","ABIMethod"],"mappings":";;;;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAGA,yBAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAEC,yCAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAIC,iBAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;QACZ,CAAC,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;;"}
@@ -2,6 +2,11 @@ import { getCallConfigSummary } from './helpers/get-call-config-summary.mjs';
2
2
  import { getSanitizer } from '../util/sanitization.mjs';
3
3
  import { ABIMethod } from 'algosdk';
4
4
 
5
+ const GenerateMode = {
6
+ FULL: 'full',
7
+ MINIMAL: 'minimal',
8
+ };
9
+ const generateModes = Object.values(GenerateMode);
5
10
  const createGeneratorContext = (app, options) => {
6
11
  const sanitizer = getSanitizer(options);
7
12
  return {
@@ -14,8 +19,9 @@ const createGeneratorContext = (app, options) => {
14
19
  acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
15
20
  return acc;
16
21
  }, {}),
22
+ mode: options.mode,
17
23
  };
18
24
  };
19
25
 
20
- export { createGeneratorContext };
26
+ export { createGeneratorContext, generateModes };
21
27
  //# sourceMappingURL=generator-context.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions) => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n }\n}\n"],"names":[],"mappings":";;;;MAiBa,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAI;AACtF,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;SACX,EACD,EAA4B,CAC7B;KACF;AACH;;;;"}
1
+ {"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;QACZ,CAAC,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-call-config-summary.js","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":["ABIMethod"],"mappings":";;;;MAIa,SAAS,GAAG,MAAM,CAAC,MAAM;AA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AAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEnC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEnC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;;AAElC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;AAC/B,QAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEvC,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IAClE,OAAO,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IACpE,OAAO,CAAC,MAAM,EAAE,MAAuB,EAAC,QAAQ,CAAC,MAAM,CAAC;AAC1D,CAAC;;;;;"}
1
+ {"version":3,"file":"get-call-config-summary.js","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":["ABIMethod"],"mappings":";;;;MAIa,SAAS,GAAG,MAAM,CAAC,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AC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAClC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;AAC/B,QAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IAClE,OAAO,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IACpE,OAAO,CAAC,MAAM,EAAE,MAAuB,EAAC,QAAQ,CAAC,MAAM,CAAC;AAC1D,CAAC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-call-config-summary.mjs","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":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,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEnC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEnC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;;AAElC,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;AAC/B,QAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;AAEvC,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IAClE,OAAO,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IACpE,OAAO,CAAC,MAAM,EAAE,MAAuB,EAAC,QAAQ,CAAC,MAAM,CAAC;AAC1D,CAAC;;;;"}
1
+ {"version":3,"file":"get-call-config-summary.mjs","sources":["../../../src/client/helpers/get-call-config-summary.ts"],"sourcesContent":["import { pascalCase } from 'change-case'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport const BARE_CALL = Symbol('bare')\n\nexport type MethodIdentifier = string | typeof BARE_CALL\n\nexport type MethodList = Array<MethodIdentifier>\n\nexport type OnComplete = 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication'\n\nexport type Actions = {\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n call: OnComplete[]\n}\n\nexport type CallConfigSummary = {\n createMethods: MethodList\n callMethods: MethodList\n deleteMethods: MethodList\n updateMethods: MethodList\n optInMethods: MethodList\n closeOutMethods: MethodList\n}\nexport const getCallConfigSummary = (app: Arc56Contract) => {\n const result: CallConfigSummary = {\n createMethods: [],\n callMethods: [],\n deleteMethods: [],\n updateMethods: [],\n optInMethods: [],\n closeOutMethods: [],\n }\n if (app.bareActions) {\n addToConfig(result, BARE_CALL, app.bareActions)\n }\n if (app.methods) {\n for (const m of app.methods) {\n if (m.actions) {\n addToConfig(result, new ABIMethod(m).getSignature(), m.actions)\n }\n }\n }\n return result\n}\n\nexport const getCreateOnComplete = (app: Arc56Contract, method: MethodIdentifier) => {\n const actions = method === BARE_CALL ? app.bareActions : app.methods?.find((m) => m.name === method)?.actions\n if (!actions) {\n return ''\n }\n const hasNoOp = actions.create.includes('NoOp')\n return `{ onCompleteAction${hasNoOp ? '?' : ''}: ${getCreateOnCompleteTypes(actions)} }`\n}\n\nconst getCreateOnCompleteTypes = (config: Actions) => {\n return config.create.map((oc) => `'${oc}' | OnApplicationComplete.${pascalCase(oc)}OC`).join(' | ')\n}\n\nconst addToConfig = (result: CallConfigSummary, method: MethodIdentifier, config: Actions) => {\n if (hasCall(config, 'NoOp')) {\n result.callMethods.push(method)\n }\n if (\n hasCreate(config, 'NoOp') ||\n hasCreate(config, 'OptIn') ||\n hasCreate(config, 'CloseOut') ||\n hasCreate(config, 'UpdateApplication') ||\n hasCreate(config, 'DeleteApplication')\n ) {\n result.createMethods.push(method)\n }\n if (hasCall(config, 'DeleteApplication')) {\n result.deleteMethods.push(method)\n }\n if (hasCall(config, 'UpdateApplication')) {\n result.updateMethods.push(method)\n }\n if (hasCall(config, 'OptIn')) {\n result.optInMethods.push(method)\n }\n if (hasCall(config, 'CloseOut')) {\n result.closeOutMethods.push(method)\n }\n}\n\nconst hasCall = (config: Actions | undefined, action: OnComplete) => {\n return config?.call.includes(action)\n}\nconst hasCreate = (config: Actions | undefined, action: OnComplete) => {\n return (config?.create as OnComplete[]).includes(action)\n}\n"],"names":[],"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AC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAC5B,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IAClC;AACA,IAAA,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;AAC/B,QAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IAClE,OAAO,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,MAA2B,EAAE,MAAkB,KAAI;IACpE,OAAO,CAAC,MAAM,EAAE,MAAuB,EAAC,QAAQ,CAAC,MAAM,CAAC;AAC1D,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-equivalent-type.js","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":["abiTypeIsTransaction","ABIReferenceType","ABIType","ABIUintType","ABIArrayDynamicType","ABIByteType","ABIArrayStaticType","ABIAddressType","ABIBoolType","ABIUfixedType","ABITupleType","ABIStringType"],"mappings":";;;;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,UAAkB,EAClB,MAA0B,EAC1B,GAAiD,EAAA;AAEjD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG;AAC9B,IAAA,IAAI,UAAU,IAAI,MAAM,EAAE;AACxB,QAAA,OAAO,MAAM;;AAEf,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,MAAM,KAAK,OAAO,GAAG,iBAAiB,GAAG,YAAY;;AAE9D,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;;AAEjB,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;;AAEjB,IAAA,IAAIA,4BAAoB,CAAC,UAAU,CAAC,EAAE;AACpC,QAAA,OAAO,kCAAkC;;AAE3C,IAAA,IAAI,UAAU,IAAIC,wBAAgB,CAAC,OAAO,EAAE;AAC1C,QAAA,OAAO,iBAAiB;;AAE1B,IAAA,IAAI,UAAU,IAAIA,wBAAgB,CAAC,WAAW,IAAI,UAAU,IAAIA,wBAAgB,CAAC,KAAK,EAAE;AACtF,QAAA,OAAO,QAAQ;;AAEjB,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACjD,QAAA,OAAO,SAAS,CAAC,sBAAsB,CAAC,UAAU,CAAC;;IAGrD,MAAM,OAAO,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AAA,IAAI,OAAO,YAAYC,qBAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,IAAI,OAAO,YAAYC,oBAAY,EAAE;YACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;;AAEhF,QAAA,IAAI,OAAO,YAAYL,mBAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,IAAI,OAAO,YAAYM,qBAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,OAAO,SAAS;;AAEpB;;;;"}
1
+ {"version":3,"file":"get-equivalent-type.js","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":["abiTypeIsTransaction","ABIReferenceType","ABIType","ABIUintType","ABIArrayDynamicType","ABIByteType","ABIArrayStaticType","ABIAddressType","ABIBoolType","ABIUfixedType","ABITupleType","ABIStringType"],"mappings":";;;;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,U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A,QAAA,IAAI,OAAO,YAAYL,mBAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAYM,qBAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,OAAO,SAAS;IAClB;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-equivalent-type.mjs","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,UAAkB,EAClB,MAA0B,EAC1B,GAAiD,EAAA;AAEjD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG;AAC9B,IAAA,IAAI,UAAU,IAAI,MAAM,EAAE;AACxB,QAAA,OAAO,MAAM;;AAEf,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,MAAM,KAAK,OAAO,GAAG,iBAAiB,GAAG,YAAY;;AAE9D,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;;AAEjB,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,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AA,EAAA,CAAI;;AAE3B,QAAA,IAAI,OAAO,YAAY,kBAAkB,EAAE;AACzC,YAAA,IAAI,OAAO,CAAC,SAAS,YAAY,WAAW;AAAE,gBAAA,OAAO,YAAY;YACjE,OAAO,CAAA,CAAA,EAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;;AAEvG,QAAA,IAAI,OAAO,YAAY,cAAc,EAAE;AACrC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,YAAA,OAAO,SAAS;;AAElB,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,IAAI,OAAO,YAAY,YAAY,EAAE;YACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;;AAEhF,QAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;;AAEjB,QAAA,OAAO,SAAS;;AAEpB;;;;"}
1
+ {"version":3,"file":"get-equivalent-type.mjs","sources":["../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIUfixedType,\n ABIUintType,\n abiTypeIsTransaction,\n} from 'algosdk'\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n abiTypeStr: string,\n ioType: 'input' | 'output',\n ctx: { app: Arc56Contract; sanitizer: Sanitizer },\n): string {\n const { app, sanitizer } = ctx\n if (abiTypeStr == 'void') {\n return 'void'\n }\n if (abiTypeStr == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (abiTypeStr == 'AVMString') {\n return 'string'\n }\n if (abiTypeStr == 'AVMUint64') {\n return 'bigint'\n }\n if (abiTypeIsTransaction(abiTypeStr)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (abiTypeStr == ABIReferenceType.account) {\n return bytesOrStringType\n }\n if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {\n return 'bigint'\n }\n if (Object.keys(app.structs).includes(abiTypeStr)) {\n return sanitizer.makeSafeTypeIdentifier(abiTypeStr)\n }\n\n const abiType = ABIType.from(abiTypeStr)\n\n return abiTypeToTs(abiType, ioType)\n\n function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output'): string {\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n }\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,UAAkB,EAClB,MAA0B,EAC1B,GAAiD,EAAA;AAEjD,IAAA,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG;AAC9B,IAAA,IAAI,UAAU,IAAI,MAAM,EAAE;AACxB,QAAA,OAAO,MAAM;IACf;AACA,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,MAAM,KAAK,OAAO,GAAG,iBAAiB,GAAG,YAAY;IAC9D;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE;AACpC,QAAA,OAAO,kCAAkC;IAC3C;AACA,IAAA,IAAI,UAAU,IAAI,gBAAgB,CAAC,OAAO,EAAE;AAC1C,QAAA,OAAO,iBAAiB;IAC1B;AACA,IAAA,IAAI,UAAU,IAAI,gBAAgB,CAAC,WAAW,IAAI,UAAU,IAAI,gBAAgB,CAAC,KAAK,EAAE;AACtF,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACjD,QAAA,OAAO,SAAS,CAAC,sBAAsB,CAAC,UAAU,CAAC;IACrD;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AA,OAAO,SAAS;QAClB;AACA,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAY,YAAY,EAAE;YACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;QAChF;AACA,QAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,YAAA,OAAO,QAAQ;QACjB;AACA,QAAA,OAAO,SAAS;IAClB;AACF;;;;"}
@@ -1,2 +1,3 @@
1
1
  import { DocumentParts } from '../output/writer';
2
- export declare function imports(): DocumentParts;
2
+ import { GeneratorContext } from './generator-context';
3
+ export declare function imports(ctx: GeneratorContext): DocumentParts;
package/client/imports.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- function* imports() {
3
+ function* imports(ctx) {
4
4
  yield `
5
5
  import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
6
6
  import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
@@ -16,11 +16,10 @@ function* imports() {
16
16
  ResolveAppClientByNetwork,
17
17
  CloneAppClientParams,
18
18
  } from '@algorandfoundation/algokit-utils/types/app-client'
19
- import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
19
+ ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
20
20
  import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
21
21
  import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
22
22
  import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
23
- import SimulateResponse = modelsv2.SimulateResponse
24
23
  `;
25
24
  }
26
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"imports.js","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* imports(): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n import SimulateResponse = modelsv2.SimulateResponse\n `\n}\n"],"names":[],"mappings":";;AAEM,UAAW,OAAO,GAAA;IACtB,MAAM;;;;;;;;;;;;;;;;;;;;GAoBL;AACH;;;;"}
1
+ {"version":3,"file":"imports.js","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":";;AAGM,UAAW,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAA,oOAAA,CAAsO,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
@@ -1,4 +1,4 @@
1
- function* imports() {
1
+ function* imports(ctx) {
2
2
  yield `
3
3
  import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
4
4
  import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
@@ -14,11 +14,10 @@ function* imports() {
14
14
  ResolveAppClientByNetwork,
15
15
  CloneAppClientParams,
16
16
  } from '@algorandfoundation/algokit-utils/types/app-client'
17
- import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
17
+ ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
18
18
  import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
19
19
  import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
20
20
  import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
21
- import SimulateResponse = modelsv2.SimulateResponse
22
21
  `;
23
22
  }
24
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"imports.mjs","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* imports(): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n import SimulateResponse = modelsv2.SimulateResponse\n `\n}\n"],"names":[],"mappings":"AAEM,UAAW,OAAO,GAAA;IACtB,MAAM;;;;;;;;;;;;;;;;;;;;GAoBL;AACH;;;;"}
1
+ {"version":3,"file":"imports.mjs","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":"AAGM,UAAW,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAA,oOAAA,CAAsO,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
@@ -18,9 +18,11 @@ function* paramsFactory(ctx) {
18
18
  }
19
19
  function* opMethods(ctx) {
20
20
  const { app, callConfig } = ctx;
21
- yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
22
- yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
23
- yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
21
+ if (ctx.mode === 'full') {
22
+ yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
23
+ yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
24
+ yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
25
+ }
24
26
  yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
25
27
  yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
26
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"params-factory.js","sources":["../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${ctx.name}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: Array<{ name?: string }>\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":["jsDoc","IncIndent","DecIndent","BARE_CALL","indent","DecIndentAndCloseBlock","NewLine","getCreateOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAOA,YAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,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,CAAA,4BAAA,EAA+B,oBAAoB,CAAA,EAAA,CAAI;AAC7O,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AACf,IAAA,MAAM,YAAY;IAClB,MAAM,CAAA,SAAA,EAAY,aAAa,CAAA,WAAA,CAAa;AAC5C,IAAA,MAAM,qDAAqD;AACxD,SAAA,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAc,WAAA,EAAA,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,EAAE;AAC5H,SAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AACjB,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,GAAG;AACT,IAAA,MAAMA,gBAAS;IACf,MAAM,CAAA,CAAA,EAAI,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAA,CAAE;AACjC;;;;"}
1
+ {"version":3,"file":"params-factory.js","sources":["../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${ctx.name}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: Array<{ name?: string }>\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":["jsDoc","IncIndent","DecIndent","BARE_CALL","indent","DecIndentAndCloseBlock","NewLine","getCreateOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAQM,UAAW,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAOA,YAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,CAAC;AAC7H,IAAA,MAAM,CAAA,sBAAA,EAAyB,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAMC,gBAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACpC,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;IACvC;AAEA,IAAA,MAAMC,gBAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG;AAE/B,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CACpB,GAAG,EACH,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EACtE,UAAU,CAAC,a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AAE;AAC5H,SAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AACjB,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,GAAG;AACT,IAAA,MAAMA,gBAAS;IACf,MAAM,CAAA,CAAA,EAAI,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAA,CAAE;AACjC;;;;"}
@@ -16,9 +16,11 @@ function* paramsFactory(ctx) {
16
16
  }
17
17
  function* opMethods(ctx) {
18
18
  const { app, callConfig } = ctx;
19
- yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
20
- yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
21
- yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
19
+ if (ctx.mode === 'full') {
20
+ yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
21
+ yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
22
+ yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
23
+ }
22
24
  yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
23
25
  yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
24
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"params-factory.mjs","sources":["../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${ctx.name}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: Array<{ name?: string }>\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":[],"mappings":";;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAO,KAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACpC,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;;AAGvC,IAAA,MAAM,SAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,UAAU,EA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AA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,EAAE;AAC5H,SAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AACjB,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,GAAG;AACT,IAAA,MAAM,SAAS;IACf,MAAM,CAAA,CAAA,EAAI,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAA,CAAE;AACjC;;;;"}
1
+ {"version":3,"file":"params-factory.mjs","sources":["../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${ctx.name}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: Array<{ name?: string }>\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '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