@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.2

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 (68) hide show
  1. package/client/app-client-context.d.ts +122 -0
  2. package/client/app-client-context.js +212 -0
  3. package/client/app-client-context.js.map +1 -0
  4. package/client/app-client-context.mjs +209 -0
  5. package/client/app-client-context.mjs.map +1 -0
  6. package/client/app-client.js +29 -51
  7. package/client/app-client.js.map +1 -1
  8. package/client/app-client.mjs +29 -51
  9. package/client/app-client.mjs.map +1 -1
  10. package/client/app-factory.js +23 -27
  11. package/client/app-factory.js.map +1 -1
  12. package/client/app-factory.mjs +23 -27
  13. package/client/app-factory.mjs.map +1 -1
  14. package/client/app-types.js +31 -60
  15. package/client/app-types.js.map +1 -1
  16. package/client/app-types.mjs +32 -61
  17. package/client/app-types.mjs.map +1 -1
  18. package/client/call-composer-types.js +31 -34
  19. package/client/call-composer-types.js.map +1 -1
  20. package/client/call-composer-types.mjs +31 -34
  21. package/client/call-composer-types.mjs.map +1 -1
  22. package/client/call-composer.js +24 -31
  23. package/client/call-composer.js.map +1 -1
  24. package/client/call-composer.mjs +24 -31
  25. package/client/call-composer.mjs.map +1 -1
  26. package/client/deploy-types.d.ts +1 -11
  27. package/client/deploy-types.js +28 -53
  28. package/client/deploy-types.js.map +1 -1
  29. package/client/deploy-types.mjs +29 -52
  30. package/client/deploy-types.mjs.map +1 -1
  31. package/client/generate.d.ts +1 -1
  32. package/client/generate.js +2 -2
  33. package/client/generate.js.map +1 -1
  34. package/client/generate.mjs +2 -2
  35. package/client/generate.mjs.map +1 -1
  36. package/client/generator-context.d.ts +3 -5
  37. package/client/generator-context.js +4 -10
  38. package/client/generator-context.js.map +1 -1
  39. package/client/generator-context.mjs +4 -10
  40. package/client/generator-context.mjs.map +1 -1
  41. package/client/helpers/contains-non-void-method.d.ts +2 -2
  42. package/client/helpers/contains-non-void-method.js +3 -2
  43. package/client/helpers/contains-non-void-method.js.map +1 -1
  44. package/client/helpers/contains-non-void-method.mjs +3 -2
  45. package/client/helpers/contains-non-void-method.mjs.map +1 -1
  46. package/client/helpers/get-equivalent-type.d.ts +3 -5
  47. package/client/helpers/get-equivalent-type.js +53 -54
  48. package/client/helpers/get-equivalent-type.js.map +1 -1
  49. package/client/helpers/get-equivalent-type.mjs +53 -55
  50. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  51. package/client/imports.d.ts +1 -2
  52. package/client/imports.js +10 -19
  53. package/client/imports.js.map +1 -1
  54. package/client/imports.mjs +10 -19
  55. package/client/imports.mjs.map +1 -1
  56. package/client/params-factory.js +47 -50
  57. package/client/params-factory.js.map +1 -1
  58. package/client/params-factory.mjs +47 -50
  59. package/client/params-factory.mjs.map +1 -1
  60. package/package.json +2 -3
  61. package/schema/load.d.ts +1 -1
  62. package/schema/load.js.map +1 -1
  63. package/schema/load.mjs.map +1 -1
  64. package/client/helpers/get-call-config-summary.d.ts +0 -19
  65. package/client/helpers/get-call-config-summary.js +0 -60
  66. package/client/helpers/get-call-config-summary.js.map +0 -1
  67. package/client/helpers/get-call-config-summary.mjs +0 -57
  68. package/client/helpers/get-call-config-summary.mjs.map +0 -1
@@ -1,64 +1,41 @@
1
1
  import { jsDoc, IncIndent, DecIndent, NewLine } from '../output/writer.mjs';
2
- import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
3
- import { ABIMethod } from 'algosdk';
2
+ import { isAbiMethod } from './app-client-context.mjs';
4
3
 
5
- function getCreateOnCompleteOptions(method, app) {
6
- const validCreateOnCompletes = method === BARE_CALL ? app.bareActions.create : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.create;
7
- const hasNoOp = validCreateOnCompletes?.includes('NoOp');
8
- const onCompleteType = validCreateOnCompletes
9
- ? `{onComplete${hasNoOp ? '?' : ''}: ${validCreateOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`
10
- : {};
11
- return {
12
- type: onCompleteType,
13
- isOptional: hasNoOp,
14
- };
15
- }
16
- function getCallOnCompleteOptions(method, app) {
17
- const validCallOnCompletes = method === BARE_CALL ? app.bareActions.call : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.call;
18
- const hasNoOp = validCallOnCompletes?.includes('NoOp');
19
- const onCompleteType = validCallOnCompletes
20
- ? `{onComplete${hasNoOp ? '?' : ''}: ${validCallOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`
21
- : {};
22
- return {
23
- type: onCompleteType,
24
- isOptional: hasNoOp,
25
- };
26
- }
27
- function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }) {
28
- const name = sanitizer.makeSafeTypeIdentifier(app.name);
29
- if (callConfig.createMethods.length > 0) {
4
+ function* deployTypes({ app, sanitizer }) {
5
+ const name = app.name.makeSafeTypeIdentifier;
6
+ if (app.createMethods.length) {
30
7
  yield* jsDoc('Defines supported create method params for this smart contract');
31
8
  yield `export type ${name}CreateCallParams =`;
32
9
  yield IncIndent;
33
- for (const method of callConfig.createMethods) {
34
- const onComplete = getCreateOnCompleteOptions(method, app);
35
- if (method === BARE_CALL) {
36
- yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.type} & CreateSchema>`;
10
+ for (const method of app.createMethods) {
11
+ const onComplete = method.createActions.inputType;
12
+ if (!isAbiMethod(method)) {
13
+ yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.typeLiteral} & CreateSchema>`;
37
14
  }
38
15
  else {
39
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
40
- const uniqueName = methodSignatureToUniqueName[method];
41
- if (uniqueName !== method) {
16
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
17
+ const uniqueName = method.uniqueName.original;
18
+ if (uniqueName !== method.signature) {
42
19
  const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
43
- yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.type} & CreateSchema>`;
20
+ yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.typeLiteral} & CreateSchema>`;
44
21
  }
45
- yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.type} & CreateSchema>`;
22
+ yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.typeLiteral} & CreateSchema>`;
46
23
  }
47
24
  }
48
25
  yield DecIndent;
49
26
  }
50
- if (callConfig.updateMethods.length > 0) {
27
+ if (app.updateMethods.length) {
51
28
  yield* jsDoc('Defines supported update method params for this smart contract');
52
29
  yield `export type ${name}UpdateCallParams =`;
53
30
  yield IncIndent;
54
- for (const method of callConfig.updateMethods) {
55
- if (method === BARE_CALL) {
31
+ for (const method of app.updateMethods) {
32
+ if (!isAbiMethod(method)) {
56
33
  yield `| Expand<AppClientBareCallParams> & {method?: never}`;
57
34
  }
58
35
  else {
59
- const uniqueName = methodSignatureToUniqueName[method];
60
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
61
- if (uniqueName !== method) {
36
+ const uniqueName = method.uniqueName.original;
37
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
38
+ if (uniqueName !== method.signature) {
62
39
  const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
63
40
  yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`;
64
41
  }
@@ -67,18 +44,18 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
67
44
  }
68
45
  yield DecIndent;
69
46
  }
70
- if (callConfig.deleteMethods.length > 0) {
47
+ if (app.deleteMethods.length) {
71
48
  yield* jsDoc('Defines supported delete method params for this smart contract');
72
49
  yield `export type ${name}DeleteCallParams =`;
73
50
  yield IncIndent;
74
- for (const method of callConfig.deleteMethods) {
75
- if (method === BARE_CALL) {
51
+ for (const method of app.deleteMethods) {
52
+ if (!isAbiMethod(method)) {
76
53
  yield `| Expand<AppClientBareCallParams> & {method?: never}`;
77
54
  }
78
55
  else {
79
- const uniqueName = methodSignatureToUniqueName[method];
80
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
81
- if (uniqueName !== method) {
56
+ const uniqueName = method.uniqueName.original;
57
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
58
+ if (uniqueName !== method.signature) {
82
59
  const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
83
60
  yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`;
84
61
  }
@@ -90,15 +67,15 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
90
67
  yield* jsDoc('Defines arguments required for the deploy method.');
91
68
  yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`;
92
69
  yield IncIndent;
93
- if (callConfig.createMethods.length) {
70
+ if (app.createMethods.length) {
94
71
  yield* jsDoc('Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
95
72
  yield `createParams?: ${name}CreateCallParams`;
96
73
  }
97
- if (callConfig.updateMethods.length) {
74
+ if (app.updateMethods.length) {
98
75
  yield* jsDoc('Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
99
76
  yield `updateParams?: ${name}UpdateCallParams`;
100
77
  }
101
- if (callConfig.deleteMethods.length) {
78
+ if (app.deleteMethods.length) {
102
79
  yield* jsDoc('Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
103
80
  yield `deleteParams?: ${name}DeleteCallParams`;
104
81
  }
@@ -107,5 +84,5 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
107
84
  yield NewLine;
108
85
  }
109
86
 
110
- export { deployTypes, getCallOnCompleteOptions, getCreateOnCompleteOptions };
87
+ export { deployTypes };
111
88
  //# sourceMappingURL=deploy-types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy-types.mjs","sources":["../../src/client/deploy-types.ts"],"sourcesContent":["import { DecIndent, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodIdentifier } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function getCreateOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCreateOnCompletes =\n method === BARE_CALL ? app.bareActions.create : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.create\n const hasNoOp = validCreateOnCompletes?.includes('NoOp')\n const onCompleteType = validCreateOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCreateOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function getCallOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCallOnCompletes =\n method === BARE_CALL ? app.bareActions.call : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.call\n const hasNoOp = validCallOnCompletes?.includes('NoOp')\n const onCompleteType = validCallOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCallOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }: GeneratorContext): DocumentParts {\n const name = sanitizer.makeSafeTypeIdentifier(app.name)\n\n if (callConfig.createMethods.length > 0) {\n yield* jsDoc('Defines supported create method params for this smart contract')\n yield `export type ${name}CreateCallParams =`\n yield IncIndent\n for (const method of callConfig.createMethods) {\n const onComplete = getCreateOnCompleteOptions(method, app)\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.type} & CreateSchema>`\n } else {\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n const uniqueName = methodSignatureToUniqueName[method]\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.type} & CreateSchema>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.type} & CreateSchema>`\n }\n }\n yield DecIndent\n }\n if (callConfig.updateMethods.length > 0) {\n yield* jsDoc('Defines supported update method params for this smart contract')\n yield `export type ${name}UpdateCallParams =`\n yield IncIndent\n for (const method of callConfig.updateMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n if (callConfig.deleteMethods.length > 0) {\n yield* jsDoc('Defines supported delete method params for this smart contract')\n yield `export type ${name}DeleteCallParams =`\n yield IncIndent\n for (const method of callConfig.deleteMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n yield* jsDoc('Defines arguments required for the deploy method.')\n yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`\n yield IncIndent\n if (callConfig.createMethods.length) {\n yield* jsDoc(\n 'Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `createParams?: ${name}CreateCallParams`\n }\n if (callConfig.updateMethods.length) {\n yield* jsDoc(\n 'Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `updateParams?: ${name}UpdateCallParams`\n }\n if (callConfig.deleteMethods.length) {\n yield* jsDoc(\n 'Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `deleteParams?: ${name}DeleteCallParams`\n }\n yield DecIndent\n yield `}>`\n yield NewLine\n}\n"],"names":[],"mappings":";;;;AAMM,SAAU,0BAA0B,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACrF,IAAA,MAAM,sBAAsB,GAC1B,MAAM,KAAK,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,I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,IAAI;AACV,IAAA,MAAM,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"deploy-types.mjs","sources":["../../src/client/deploy-types.ts"],"sourcesContent":["import { DecIndent, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { isAbiMethod } from './app-client-context'\n\nexport function* deployTypes({ app, sanitizer }: GeneratorContext): DocumentParts {\n const name = app.name.makeSafeTypeIdentifier\n\n if (app.createMethods.length) {\n yield* jsDoc('Defines supported create method params for this smart contract')\n yield `export type ${name}CreateCallParams =`\n yield IncIndent\n\n for (const method of app.createMethods) {\n const onComplete = method.createActions.inputType\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.typeLiteral} & CreateSchema>`\n } else {\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n const uniqueName = method.uniqueName.original\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.typeLiteral} & CreateSchema>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.typeLiteral} & CreateSchema>`\n }\n }\n yield DecIndent\n }\n if (app.updateMethods.length) {\n yield* jsDoc('Defines supported update method params for this smart contract')\n yield `export type ${name}UpdateCallParams =`\n yield IncIndent\n\n for (const method of app.updateMethods) {\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = method.uniqueName.original\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n if (app.deleteMethods.length) {\n yield* jsDoc('Defines supported delete method params for this smart contract')\n yield `export type ${name}DeleteCallParams =`\n yield IncIndent\n for (const method of app.deleteMethods) {\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = method.uniqueName.original\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n yield* jsDoc('Defines arguments required for the deploy method.')\n yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`\n yield IncIndent\n if (app.createMethods.length) {\n yield* jsDoc(\n 'Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `createParams?: ${name}CreateCallParams`\n }\n if (app.updateMethods.length) {\n yield* jsDoc(\n 'Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `updateParams?: ${name}UpdateCallParams`\n }\n if (app.deleteMethods.length) {\n yield* jsDoc(\n 'Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `deleteParams?: ${name}DeleteCallParams`\n }\n yield DecIndent\n yield `}>`\n yield NewLine\n}\n"],"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AK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,IAAI;AACV,IAAA,MAAM,OAAO;AACf;;;;"}
@@ -1,4 +1,4 @@
1
1
  import { DocumentParts } from '../output/writer';
2
2
  import { GeneratorOptions } from './generator-context';
3
- import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
3
+ import { Arc56Contract } from '@algorandfoundation/algokit-utils/abi';
4
4
  export declare function generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts;
@@ -70,9 +70,9 @@ function* generate(app, options) {
70
70
  yield `/**`;
71
71
  yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`;
72
72
  yield ` * DO NOT MODIFY IT BY HAND.`;
73
- yield ` * requires: @algorandfoundation/algokit-utils: ^7`;
73
+ yield ` * requires: @algorandfoundation/algokit-utils: ^10`;
74
74
  yield ` */`;
75
- yield* imports.imports(ctx);
75
+ yield* imports.imports();
76
76
  // Change the structs definition to sanitize property names according to the defined rules
77
77
  // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp
78
78
  reduceAppSpec.structs = Object.fromEntries(Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]));
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","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":["createGeneratorContext","imports","inline","NewLine","utilityTypes","appTypes","deployTypes","paramsFactory","appFactory","appClient","callComposerType"],"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,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pB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAOC,uBAAW,CAAC,GAAG,CAAC;IACzB;AACA,IAAA,MAAMH,cAAO;;AAGb,IAAA,OAAOI,2BAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAMJ,cAAO;;AAEb,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAOK,qBAAU,CAAC,GAAG,CAAC;IACxB;;AAEA,IAAA,OAAOC,mBAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAOC,kCAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"generate.js","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/abi'\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: ^10`\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 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":["createGeneratorContext","imports","inline","NewLine","utilityTypes","appTypes","deployTypes","paramsFactory","appFactory","appClient","callComposerType"],"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,SAAS,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AACtD,SAAA,CAAC,CAAC;AACP,IAAA,CAAC;;I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` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`;
70
70
  yield ` * DO NOT MODIFY IT BY HAND.`;
71
- yield ` * requires: @algorandfoundation/algokit-utils: ^7`;
71
+ yield ` * requires: @algorandfoundation/algokit-utils: ^10`;
72
72
  yield ` */`;
73
- yield* imports(ctx);
73
+ yield* imports();
74
74
  // Change the structs definition to sanitize property names according to the defined rules
75
75
  // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp
76
76
  reduceAppSpec.structs = Object.fromEntries(Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]));
@@ -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, 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,SAAS,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AACtD,SAAA,CAAC,CAAC;AACP,IAAA,CAAC;;IAGD,IAAI,eAAe,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,IAAI,eAAe,CAAC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eAAe,CAAC;AAClE,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,CAAC,GAAG,CAAC;;;AAGnB,IAAA,aAAa,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CACxC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAClH;AACD,IAAA,OAAO,MAAM,CAAC,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,8BAA8B,CAAC;AACvH,IAAA,MAAM,OAAO;AAEb,IAAA,OAAO,YAAY,EAAE;AACrB,IAAA,MAAM,OAAO;AACb,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AAEpB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,WAAW,CAAC,GAAG,CAAC;IACzB;AACA,IAAA,MAAM,OAAO;;AAGb,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAM,OAAO;;AAEb,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,UAAU,CAAC,GAAG,CAAC;IACxB;;AAEA,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/abi'\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: ^10`\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 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,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,CAAC;AACvH,IAAA,MAAM,OAAO;AAEb,IAAA,OAAO,YAAY,EAAE;AACrB,IAAA,MAAM,OAAO;AACb,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AAEpB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,WAAW,CAAC,GAAG,CAAC;IACzB;AACA,IAAA,MAAM,OAAO;;AAGb,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAM,OAAO;;AAEb,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,UAAU,CAAC,GAAG,CAAC;IACxB;;AAEA,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
@@ -1,6 +1,6 @@
1
- import { CallConfigSummary } from './helpers/get-call-config-summary';
2
1
  import { Sanitizer } from '../util/sanitization';
3
- import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
2
+ import { Arc56Contract } from '@algorandfoundation/algokit-utils/abi';
3
+ import { AppClientContext } from './app-client-context';
4
4
  declare const GenerateMode: {
5
5
  readonly FULL: "full";
6
6
  readonly MINIMAL: "minimal";
@@ -8,10 +8,8 @@ declare const GenerateMode: {
8
8
  export type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode];
9
9
  export declare const generateModes: ("full" | "minimal")[];
10
10
  export type GeneratorContext = {
11
- app: Arc56Contract;
12
11
  name: string;
13
- callConfig: CallConfigSummary;
14
- methodSignatureToUniqueName: Record<string, string>;
12
+ app: AppClientContext;
15
13
  sanitizer: Sanitizer;
16
14
  mode: GenerateMode;
17
15
  };
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
4
3
  var sanitization = require('../util/sanitization.js');
5
- var algosdk = require('algosdk');
4
+ var appClientContext = require('./app-client-context.js');
6
5
 
7
6
  const GenerateMode = {
8
7
  FULL: 'full',
@@ -11,16 +10,11 @@ const GenerateMode = {
11
10
  const generateModes = Object.values(GenerateMode);
12
11
  const createGeneratorContext = (app, options) => {
13
12
  const sanitizer = sanitization.getSanitizer(options);
13
+ const appCtx = appClientContext.createAppClientContext(app, sanitizer);
14
14
  return {
15
15
  sanitizer,
16
- app,
17
- name: sanitizer.makeSafeTypeIdentifier(app.name),
18
- callConfig: getCallConfigSummary.getCallConfigSummary(app),
19
- methodSignatureToUniqueName: app.methods.reduce((acc, cur) => {
20
- const signature = new algosdk.ABIMethod(cur).getSignature();
21
- acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
22
- return acc;
23
- }, {}),
16
+ name: appCtx.name.makeSafeTypeIdentifier,
17
+ app: appCtx,
24
18
  mode: options.mode,
25
19
  };
26
20
  };
@@ -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\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;;;;;"}
1
+ {"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { AppClientContext, createAppClientContext } from './app-client-context'\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 name: string\n app: AppClientContext\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 const appCtx = createAppClientContext(app, sanitizer)\n return {\n sanitizer,\n name: appCtx.name.makeSafeTypeIdentifier,\n app: appCtx,\n mode: options.mode,\n }\n}\n"],"names":["getSanitizer","createAppClientContext"],"mappings":";;;;;AAIA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAc1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAGA,yBAAY,CAAC,OAAO,CAAC;IACvC,MAAM,MAAM,GAAGC,uCAAsB,CAAC,GAAG,EAAE,SAAS,CAAC;IACrD,OAAO;QACL,SAAS;AACT,QAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,sBAAsB;AACxC,QAAA,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;;"}
@@ -1,6 +1,5 @@
1
- import { getCallConfigSummary } from './helpers/get-call-config-summary.mjs';
2
1
  import { getSanitizer } from '../util/sanitization.mjs';
3
- import { ABIMethod } from 'algosdk';
2
+ import { createAppClientContext } from './app-client-context.mjs';
4
3
 
5
4
  const GenerateMode = {
6
5
  FULL: 'full',
@@ -9,16 +8,11 @@ const GenerateMode = {
9
8
  const generateModes = Object.values(GenerateMode);
10
9
  const createGeneratorContext = (app, options) => {
11
10
  const sanitizer = getSanitizer(options);
11
+ const appCtx = createAppClientContext(app, sanitizer);
12
12
  return {
13
13
  sanitizer,
14
- app,
15
- name: sanitizer.makeSafeTypeIdentifier(app.name),
16
- callConfig: getCallConfigSummary(app),
17
- methodSignatureToUniqueName: app.methods.reduce((acc, cur) => {
18
- const signature = new ABIMethod(cur).getSignature();
19
- acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
20
- return acc;
21
- }, {}),
14
+ name: appCtx.name.makeSafeTypeIdentifier,
15
+ app: appCtx,
22
16
  mode: options.mode,
23
17
  };
24
18
  };
@@ -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\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
+ {"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { AppClientContext, createAppClientContext } from './app-client-context'\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 name: string\n app: AppClientContext\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 const appCtx = createAppClientContext(app, sanitizer)\n return {\n sanitizer,\n name: appCtx.name.makeSafeTypeIdentifier,\n app: appCtx,\n mode: options.mode,\n }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAc1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;IACvC,MAAM,MAAM,GAAG,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC;IACrD,OAAO;QACL,SAAS;AACT,QAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,sBAAsB;AACxC,QAAA,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;"}
@@ -1,2 +1,2 @@
1
- import { Method } from '@algorandfoundation/algokit-utils/types/app-arc56';
2
- export declare const containsNonVoidMethod: (methods: Method[]) => boolean;
1
+ import { AppClientMethodContext } from '../app-client-context';
2
+ export declare const containsNonVoidMethod: (methods: AppClientMethodContext[]) => boolean;
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var appClientContext = require('../app-client-context.js');
4
+
3
5
  const containsNonVoidMethod = (methods) => {
4
6
  return methods.some((method) => {
5
- const returnType = method.returns.struct ?? method.returns.type ?? 'void';
6
- return returnType !== 'void';
7
+ return appClientContext.isAbiMethod(method) && method.returns.tsOutType !== 'void';
7
8
  });
8
9
  };
9
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"contains-non-void-method.js","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\n\nexport const containsNonVoidMethod = (methods: Method[]) => {\n return methods.some((method) => {\n const returnType = method.returns.struct ?? method.returns.type ?? 'void'\n return returnType !== 'void'\n })\n}\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiB,KAAI;AACzD,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM;QACzE,OAAO,UAAU,KAAK,MAAM;AAC9B,IAAA,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"contains-non-void-method.js","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { AppClientMethodContext, isAbiMethod } from '../app-client-context'\n\nexport const containsNonVoidMethod = (methods: AppClientMethodContext[]) => {\n return methods.some((method) => {\n return isAbiMethod(method) && method.returns.tsOutType !== 'void'\n })\n}\n"],"names":["isAbiMethod"],"mappings":";;;;AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiC,KAAI;AACzE,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,OAAOA,4BAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,KAAK,MAAM;AACnE,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -1,7 +1,8 @@
1
+ import { isAbiMethod } from '../app-client-context.mjs';
2
+
1
3
  const containsNonVoidMethod = (methods) => {
2
4
  return methods.some((method) => {
3
- const returnType = method.returns.struct ?? method.returns.type ?? 'void';
4
- return returnType !== 'void';
5
+ return isAbiMethod(method) && method.returns.tsOutType !== 'void';
5
6
  });
6
7
  };
7
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"contains-non-void-method.mjs","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\n\nexport const containsNonVoidMethod = (methods: Method[]) => {\n return methods.some((method) => {\n const returnType = method.returns.struct ?? method.returns.type ?? 'void'\n return returnType !== 'void'\n })\n}\n"],"names":[],"mappings":"AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiB,KAAI;AACzD,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM;QACzE,OAAO,UAAU,KAAK,MAAM;AAC9B,IAAA,CAAC,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"contains-non-void-method.mjs","sources":["../../../src/client/helpers/contains-non-void-method.ts"],"sourcesContent":["import { AppClientMethodContext, isAbiMethod } from '../app-client-context'\n\nexport const containsNonVoidMethod = (methods: AppClientMethodContext[]) => {\n return methods.some((method) => {\n return isAbiMethod(method) && method.returns.tsOutType !== 'void'\n })\n}\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB,GAAG,CAAC,OAAiC,KAAI;AACzE,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;AAC7B,QAAA,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,KAAK,MAAM;AACnE,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -1,6 +1,4 @@
1
- import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
1
+ import { ABIReferenceType, ABIType, AVMType, ABITransactionType } from '@algorandfoundation/algokit-utils/abi';
2
2
  import { Sanitizer } from '../../util/sanitization';
3
- export declare function getEquivalentType(abiTypeStr: string, ioType: 'input' | 'output', ctx: {
4
- app: Arc56Contract;
5
- sanitizer: Sanitizer;
6
- }): string;
3
+ export declare function getEquivalentType(algoType: ABIType | ABIReferenceType | ABITransactionType | AVMType | 'void', ioType: 'input' | 'output', sanitizer: Sanitizer): string;
4
+ export declare function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output', sanitizer: Sanitizer): string;
@@ -1,81 +1,80 @@
1
1
  'use strict';
2
2
 
3
- var algosdk = require('algosdk');
3
+ var abi = require('@algorandfoundation/algokit-utils/abi');
4
4
 
5
5
  const bigIntOrNumberType = 'bigint | number';
6
6
  const bytesOrStringType = 'Uint8Array | string';
7
- function getEquivalentType(abiTypeStr, ioType, ctx) {
8
- const { app, sanitizer } = ctx;
9
- if (abiTypeStr == 'void') {
7
+ function getEquivalentType(algoType, ioType, sanitizer) {
8
+ if (algoType == 'void') {
10
9
  return 'void';
11
10
  }
12
- if (abiTypeStr == 'AVMBytes') {
11
+ if (algoType == 'AVMBytes') {
13
12
  return ioType === 'input' ? bytesOrStringType : 'Uint8Array';
14
13
  }
15
- if (abiTypeStr == 'AVMString') {
14
+ if (algoType == 'AVMString') {
16
15
  return 'string';
17
16
  }
18
- if (abiTypeStr == 'AVMUint64') {
17
+ if (algoType == 'AVMUint64') {
19
18
  return 'bigint';
20
19
  }
21
- if (algosdk.abiTypeIsTransaction(abiTypeStr)) {
20
+ if (abi.argTypeIsTransaction(algoType)) {
22
21
  return 'AppMethodCallTransactionArgument';
23
22
  }
24
- if (abiTypeStr == algosdk.ABIReferenceType.account) {
23
+ if (algoType == abi.ABIReferenceType.Account) {
25
24
  return bytesOrStringType;
26
25
  }
27
- if (abiTypeStr == algosdk.ABIReferenceType.application || abiTypeStr == algosdk.ABIReferenceType.asset) {
26
+ if (algoType == abi.ABIReferenceType.Application || algoType == abi.ABIReferenceType.Asset) {
28
27
  return 'bigint';
29
28
  }
30
- if (Object.keys(app.structs).includes(abiTypeStr)) {
31
- return sanitizer.makeSafeTypeIdentifier(abiTypeStr);
29
+ return abiTypeToTs(algoType, ioType, sanitizer);
30
+ }
31
+ function abiTypeToTs(abiType, ioType, sanitizer) {
32
+ if (abiType instanceof abi.ABIStructType) {
33
+ return sanitizer.makeSafeTypeIdentifier(abiType.structName);
32
34
  }
33
- const abiType = algosdk.ABIType.from(abiTypeStr);
34
- return abiTypeToTs(abiType, ioType);
35
- function abiTypeToTs(abiType, ioType) {
36
- if (abiType instanceof algosdk.ABIUintType) {
37
- if (abiType.bitSize < 53)
38
- return ioType === 'input' ? bigIntOrNumberType : 'number';
39
- return ioType === 'input' ? bigIntOrNumberType : 'bigint';
40
- }
41
- if (abiType instanceof algosdk.ABIArrayDynamicType) {
42
- if (abiType.childType instanceof algosdk.ABIByteType)
43
- return 'Uint8Array';
44
- const childTsType = abiTypeToTs(abiType.childType, ioType);
45
- if (childTsType === bigIntOrNumberType) {
46
- return 'bigint[] | number[]';
47
- }
48
- else if (childTsType === bytesOrStringType) {
49
- return 'Uint8Array[] | string[]';
50
- }
51
- return `${childTsType}[]`;
52
- }
53
- if (abiType instanceof algosdk.ABIArrayStaticType) {
54
- if (abiType.childType instanceof algosdk.ABIByteType)
55
- return 'Uint8Array';
56
- return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`;
57
- }
58
- if (abiType instanceof algosdk.ABIAddressType) {
59
- return 'string';
60
- }
61
- if (abiType instanceof algosdk.ABIBoolType) {
62
- return 'boolean';
63
- }
64
- if (abiType instanceof algosdk.ABIUfixedType) {
65
- return 'number';
66
- }
67
- if (abiType instanceof algosdk.ABITupleType) {
68
- return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`;
69
- }
70
- if (abiType instanceof algosdk.ABIByteType) {
71
- return 'number';
35
+ if (abiType instanceof abi.ABIUintType) {
36
+ if (abiType.bitSize < 53)
37
+ return ioType === 'input' ? bigIntOrNumberType : 'number';
38
+ return ioType === 'input' ? bigIntOrNumberType : 'bigint';
39
+ }
40
+ if (abiType instanceof abi.ABIArrayDynamicType) {
41
+ if (abiType.childType instanceof abi.ABIByteType)
42
+ return 'Uint8Array';
43
+ const childTsType = abiTypeToTs(abiType.childType, ioType, sanitizer);
44
+ if (childTsType === bigIntOrNumberType) {
45
+ return 'bigint[] | number[]';
72
46
  }
73
- if (abiType instanceof algosdk.ABIStringType) {
74
- return 'string';
47
+ else if (childTsType === bytesOrStringType) {
48
+ return 'Uint8Array[] | string[]';
75
49
  }
76
- return 'unknown';
50
+ return `${childTsType}[]`;
51
+ }
52
+ if (abiType instanceof abi.ABIArrayStaticType) {
53
+ if (abiType.childType instanceof abi.ABIByteType)
54
+ return 'Uint8Array';
55
+ return `[${new Array(abiType.length).fill(abiTypeToTs(abiType.childType, ioType, sanitizer)).join(', ')}]`;
56
+ }
57
+ if (abiType instanceof abi.ABIAddressType) {
58
+ return 'string';
59
+ }
60
+ if (abiType instanceof abi.ABIBoolType) {
61
+ return 'boolean';
62
+ }
63
+ if (abiType instanceof abi.ABIUfixedType) {
64
+ return 'number';
65
+ }
66
+ if (abiType instanceof abi.ABITupleType) {
67
+ return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType, sanitizer)).join(', ')}]`;
68
+ }
69
+ if (abiType instanceof abi.ABIByteType) {
70
+ return 'number';
71
+ }
72
+ if (abiType instanceof abi.ABIStringType) {
73
+ return 'string';
77
74
  }
75
+ return 'unknown';
78
76
  }
79
77
 
78
+ exports.abiTypeToTs = abiTypeToTs;
80
79
  exports.getEquivalentType = getEquivalentType;
81
80
  //# sourceMappingURL=get-equivalent-type.js.map