@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.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 (156) hide show
  1. package/client/app-client-context.d.ts +122 -0
  2. package/client/deploy-types.d.ts +1 -11
  3. package/client/generate.d.ts +1 -1
  4. package/client/generator-context.d.ts +3 -5
  5. package/client/helpers/contains-non-void-method.d.ts +2 -2
  6. package/client/helpers/get-equivalent-type.d.ts +3 -5
  7. package/client/imports.d.ts +1 -2
  8. package/package.json +2 -3
  9. package/schema/load.d.ts +1 -1
  10. package/src/cli.js.map +1 -0
  11. package/src/cli.mjs.map +1 -0
  12. package/src/client/app-client-context.js +211 -0
  13. package/src/client/app-client-context.js.map +1 -0
  14. package/src/client/app-client-context.mjs +208 -0
  15. package/src/client/app-client-context.mjs.map +1 -0
  16. package/{client → src/client}/app-client.js +29 -51
  17. package/src/client/app-client.js.map +1 -0
  18. package/{client → src/client}/app-client.mjs +29 -51
  19. package/src/client/app-client.mjs.map +1 -0
  20. package/{client → src/client}/app-factory.js +23 -27
  21. package/src/client/app-factory.js.map +1 -0
  22. package/{client → src/client}/app-factory.mjs +23 -27
  23. package/src/client/app-factory.mjs.map +1 -0
  24. package/{client → src/client}/app-types.js +31 -60
  25. package/src/client/app-types.js.map +1 -0
  26. package/{client → src/client}/app-types.mjs +32 -61
  27. package/src/client/app-types.mjs.map +1 -0
  28. package/{client → src/client}/call-composer-types.js +31 -34
  29. package/src/client/call-composer-types.js.map +1 -0
  30. package/{client → src/client}/call-composer-types.mjs +31 -34
  31. package/src/client/call-composer-types.mjs.map +1 -0
  32. package/{client → src/client}/call-composer.js +24 -31
  33. package/src/client/call-composer.js.map +1 -0
  34. package/{client → src/client}/call-composer.mjs +24 -31
  35. package/src/client/call-composer.mjs.map +1 -0
  36. package/{client → src/client}/deploy-types.js +28 -53
  37. package/src/client/deploy-types.js.map +1 -0
  38. package/{client → src/client}/deploy-types.mjs +29 -52
  39. package/src/client/deploy-types.mjs.map +1 -0
  40. package/{client → src/client}/generate.js +2 -2
  41. package/src/client/generate.js.map +1 -0
  42. package/{client → src/client}/generate.mjs +2 -2
  43. package/src/client/generate.mjs.map +1 -0
  44. package/src/client/generator-context.js +24 -0
  45. package/src/client/generator-context.js.map +1 -0
  46. package/src/client/generator-context.mjs +21 -0
  47. package/src/client/generator-context.mjs.map +1 -0
  48. package/{client → src/client}/helpers/contains-non-void-method.js +3 -2
  49. package/src/client/helpers/contains-non-void-method.js.map +1 -0
  50. package/{client → src/client}/helpers/contains-non-void-method.mjs +3 -2
  51. package/src/client/helpers/contains-non-void-method.mjs.map +1 -0
  52. package/src/client/helpers/get-equivalent-type.js +80 -0
  53. package/src/client/helpers/get-equivalent-type.js.map +1 -0
  54. package/src/client/helpers/get-equivalent-type.mjs +77 -0
  55. package/src/client/helpers/get-equivalent-type.mjs.map +1 -0
  56. package/src/client/imports.js +18 -0
  57. package/src/client/imports.js.map +1 -0
  58. package/src/client/imports.mjs +16 -0
  59. package/src/client/imports.mjs.map +1 -0
  60. package/src/client/params-factory.js +125 -0
  61. package/src/client/params-factory.js.map +1 -0
  62. package/src/client/params-factory.mjs +123 -0
  63. package/src/client/params-factory.mjs.map +1 -0
  64. package/src/client/utility-types.js.map +1 -0
  65. package/src/client/utility-types.mjs.map +1 -0
  66. package/src/output/writer.js.map +1 -0
  67. package/src/output/writer.mjs.map +1 -0
  68. package/src/schema/load.js.map +1 -0
  69. package/src/schema/load.mjs.map +1 -0
  70. package/src/util/boom.js.map +1 -0
  71. package/src/util/boom.mjs.map +1 -0
  72. package/src/util/color-console.js.map +1 -0
  73. package/src/util/color-console.mjs.map +1 -0
  74. package/src/util/sanitization.js.map +1 -0
  75. package/src/util/sanitization.mjs.map +1 -0
  76. package/cli.js.map +0 -1
  77. package/cli.mjs.map +0 -1
  78. package/client/app-client.js.map +0 -1
  79. package/client/app-client.mjs.map +0 -1
  80. package/client/app-factory.js.map +0 -1
  81. package/client/app-factory.mjs.map +0 -1
  82. package/client/app-types.js.map +0 -1
  83. package/client/app-types.mjs.map +0 -1
  84. package/client/call-composer-types.js.map +0 -1
  85. package/client/call-composer-types.mjs.map +0 -1
  86. package/client/call-composer.js.map +0 -1
  87. package/client/call-composer.mjs.map +0 -1
  88. package/client/deploy-types.js.map +0 -1
  89. package/client/deploy-types.mjs.map +0 -1
  90. package/client/generate.js.map +0 -1
  91. package/client/generate.mjs.map +0 -1
  92. package/client/generator-context.js +0 -30
  93. package/client/generator-context.js.map +0 -1
  94. package/client/generator-context.mjs +0 -27
  95. package/client/generator-context.mjs.map +0 -1
  96. package/client/helpers/contains-non-void-method.js.map +0 -1
  97. package/client/helpers/contains-non-void-method.mjs.map +0 -1
  98. package/client/helpers/get-call-config-summary.d.ts +0 -19
  99. package/client/helpers/get-call-config-summary.js +0 -60
  100. package/client/helpers/get-call-config-summary.js.map +0 -1
  101. package/client/helpers/get-call-config-summary.mjs +0 -57
  102. package/client/helpers/get-call-config-summary.mjs.map +0 -1
  103. package/client/helpers/get-equivalent-type.js +0 -81
  104. package/client/helpers/get-equivalent-type.js.map +0 -1
  105. package/client/helpers/get-equivalent-type.mjs +0 -79
  106. package/client/helpers/get-equivalent-type.mjs.map +0 -1
  107. package/client/imports.js +0 -27
  108. package/client/imports.js.map +0 -1
  109. package/client/imports.mjs +0 -25
  110. package/client/imports.mjs.map +0 -1
  111. package/client/params-factory.js +0 -128
  112. package/client/params-factory.js.map +0 -1
  113. package/client/params-factory.mjs +0 -126
  114. package/client/params-factory.mjs.map +0 -1
  115. package/client/utility-types.js.map +0 -1
  116. package/client/utility-types.mjs.map +0 -1
  117. package/output/writer.js.map +0 -1
  118. package/output/writer.mjs.map +0 -1
  119. package/schema/load.js.map +0 -1
  120. package/schema/load.mjs.map +0 -1
  121. package/util/boom.js.map +0 -1
  122. package/util/boom.mjs.map +0 -1
  123. package/util/color-console.js.map +0 -1
  124. package/util/color-console.mjs.map +0 -1
  125. package/util/sanitization.js.map +0 -1
  126. package/util/sanitization.mjs.map +0 -1
  127. /package/{cli.js → src/cli.js} +0 -0
  128. /package/{cli.mjs → src/cli.mjs} +0 -0
  129. /package/{client → src/client}/utility-types.js +0 -0
  130. /package/{client → src/client}/utility-types.mjs +0 -0
  131. /package/{index.js → src/index.js} +0 -0
  132. /package/{index.js.map → src/index.js.map} +0 -0
  133. /package/{index.mjs → src/index.mjs} +0 -0
  134. /package/{index.mjs.map → src/index.mjs.map} +0 -0
  135. /package/{output → src/output}/writer.js +0 -0
  136. /package/{output → src/output}/writer.mjs +0 -0
  137. /package/{schema → src/schema}/application.schema.json.js +0 -0
  138. /package/{schema → src/schema}/application.schema.json.js.map +0 -0
  139. /package/{schema → src/schema}/application.schema.json.mjs +0 -0
  140. /package/{schema → src/schema}/application.schema.json.mjs.map +0 -0
  141. /package/{schema → src/schema}/arc56.schema.json.js +0 -0
  142. /package/{schema → src/schema}/arc56.schema.json.js.map +0 -0
  143. /package/{schema → src/schema}/arc56.schema.json.mjs +0 -0
  144. /package/{schema → src/schema}/arc56.schema.json.mjs.map +0 -0
  145. /package/{schema → src/schema}/contract.schema.json.js +0 -0
  146. /package/{schema → src/schema}/contract.schema.json.js.map +0 -0
  147. /package/{schema → src/schema}/contract.schema.json.mjs +0 -0
  148. /package/{schema → src/schema}/contract.schema.json.mjs.map +0 -0
  149. /package/{schema → src/schema}/load.js +0 -0
  150. /package/{schema → src/schema}/load.mjs +0 -0
  151. /package/{util → src/util}/boom.js +0 -0
  152. /package/{util → src/util}/boom.mjs +0 -0
  153. /package/{util → src/util}/color-console.js +0 -0
  154. /package/{util → src/util}/color-console.mjs +0 -0
  155. /package/{util → src/util}/sanitization.js +0 -0
  156. /package/{util → src/util}/sanitization.mjs +0 -0
@@ -1,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
3
  var writer = require('../output/writer.js');
4
- var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
5
- var deployTypes = require('./deploy-types.js');
6
- var algosdk = require('algosdk');
4
+ var appClientContext = require('./app-client-context.js');
7
5
 
8
6
  function* callComposerType(ctx) {
9
- const { name, callConfig, app } = ctx;
7
+ const { name, app } = ctx;
10
8
  yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
11
9
  yield writer.IncIndent;
12
10
  yield* callComposerTypeNoops(ctx);
13
11
  if (ctx.mode === 'full') {
14
- yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'update');
15
- yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
12
+ yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, app.updateMethods, 'update');
13
+ yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, app.deleteMethods, 'delete');
16
14
  }
17
- yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
18
- yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
15
+ yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, app.optInMethods, 'optIn');
16
+ yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, app.closeOutMethods, 'closeOut');
19
17
  yield* callComposerTypeClearState(ctx);
20
18
  yield* writer.jsDoc({
21
19
  description: 'Adds a transaction to the composer',
@@ -32,16 +30,16 @@ function* callComposerType(ctx) {
32
30
  yield* writer.jsDoc({
33
31
  description: 'Simulates the transaction group and returns the result',
34
32
  });
35
- yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
36
- yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
37
- yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
33
+ yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
34
+ yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
35
+ yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
38
36
  yield* writer.jsDoc({
39
37
  description: 'Sends the transaction group to the network and returns the results',
40
38
  });
41
39
  yield `send(params?: SendParams): Promise<${name}ComposerResults<TReturns>>`;
42
40
  yield writer.DecIndentAndCloseBlock;
43
41
  yield `
44
- export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendAtomicTransactionComposerResults & {
42
+ export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendTransactionComposerResults & {
45
43
  returns: TReturns
46
44
  }>
47
45
  `;
@@ -50,63 +48,62 @@ function* callComposerTypeClearState({ app, name }) {
50
48
  yield* writer.jsDoc({
51
49
  description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,
52
50
  params: {
53
- args: `The arguments for the bare call`,
51
+ params: `Any additional parameters for the bare call`,
54
52
  },
55
53
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
56
54
  });
57
55
  yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`;
58
56
  yield writer.NewLine;
59
57
  }
60
- function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
61
- for (const method of app.methods) {
62
- const methodSig = new algosdk.ABIMethod(method).getSignature();
63
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
64
- const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig]);
65
- // Skip methods which don't support a no_op call config
66
- if (!callConfig.callMethods.includes(methodSig))
58
+ function* callComposerTypeNoops({ app, name, sanitizer }) {
59
+ for (const method of app.noOpMethods) {
60
+ if (!appClientContext.isAbiMethod(method))
67
61
  continue;
62
+ const methodSig = method.signature;
63
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
64
+ const methodName = method.uniqueName.makeSafeMethodIdentifier;
68
65
  yield* writer.jsDoc({
69
- description: `Calls the ${new algosdk.ABIMethod(method).getSignature()} ABI method.`,
66
+ description: `Calls the ${methodSig} ABI method.`,
70
67
  abiDescription: method.desc,
71
68
  params: {
72
- args: `The arguments for the contract call`,
73
69
  params: `Any additional parameters for the call`,
74
70
  },
75
71
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
76
72
  });
77
- yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
73
+ const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`;
74
+ yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<${updatedReturnType}>`;
78
75
  yield writer.NewLine;
79
76
  }
80
77
  }
81
- function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, name, sanitizer }, description, methods, verb, includeCompilation) {
78
+ function* callComposerOperationMethodType({ name, sanitizer }, description, methods, verb, includeCompilation) {
82
79
  if (methods.length) {
83
80
  yield* writer.jsDoc(`Gets available ${verb} methods`);
84
81
  yield `readonly ${verb}: {`;
85
82
  yield writer.IncIndent;
86
- for (const methodSig of methods) {
87
- const onComplete = verb === 'create' ? deployTypes.getCreateOnCompleteOptions(methodSig, app) : undefined;
88
- if (methodSig === getCallConfigSummary.BARE_CALL) {
83
+ for (const method of methods) {
84
+ const onComplete = verb === 'create' ? method.createActions.inputType : undefined;
85
+ if (!appClientContext.isAbiMethod(method)) {
89
86
  yield* writer.jsDoc({
90
87
  description: `${description} using a bare call.`,
91
88
  params: {
92
- args: `The arguments for the bare call`,
89
+ params: `Any additional parameters for the call`,
93
90
  },
94
91
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
95
92
  });
96
- yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<[...TReturns, undefined]>`;
93
+ yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<TReturns>`;
97
94
  }
98
95
  else {
99
- const uniqueName = methodSignatureToUniqueName[methodSig];
96
+ const uniqueName = method.uniqueName.original;
100
97
  yield* writer.jsDoc({
101
- description: `${description} using the ${methodSig} ABI method.`,
98
+ description: `${description} using the ${method.signature} ABI method.`,
102
99
  params: {
103
- args: `The arguments for the smart contract call`,
104
100
  params: `Any additional parameters for the call`,
105
101
  },
106
102
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
107
103
  });
108
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
109
- yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
104
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
105
+ const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`;
106
+ yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}): ${name}Composer<${updatedReturnType}>`;
110
107
  }
111
108
  }
112
109
  yield writer.DecIndentAndCloseBlock;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-composer-types.js","sources":["../../../src/client/call-composer-types.ts"],"sourcesContent":["import { DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nimport { AppClientMethodContext, isAbiMethod } from './app-client-context'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, app } = ctx\n yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`\n yield IncIndent\n\n yield* callComposerTypeNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethodType(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n app.updateMethods,\n 'update',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n app.deleteMethods,\n 'delete',\n )\n }\n yield* callComposerOperationMethodType(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n app.optInMethods,\n 'optIn',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Makes a close out call to an existing instance of the ${app.name} smart contract`,\n app.closeOutMethods,\n 'closeOut',\n )\n\n yield* callComposerTypeClearState(ctx)\n\n yield* jsDoc({\n description: 'Adds a transaction to the composer',\n params: {\n txn: 'A transaction to add to the transaction group',\n signer: 'The optional signer to use when signing this transaction.',\n },\n })\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner): ${name}Composer<TReturns>`\n\n yield* jsDoc({\n description: 'Returns the underlying AtomicTransactionComposer instance',\n })\n yield `composer(): Promise<TransactionComposer>`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n\n yield* jsDoc({\n description: 'Sends the transaction group to the network and returns the results',\n })\n yield `send(params?: SendParams): Promise<${name}ComposerResults<TReturns>>`\n\n yield DecIndentAndCloseBlock\n\n yield `\n export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendTransactionComposerResults & {\n returns: TReturns\n }>\n `\n}\n\nfunction* callComposerTypeClearState({ app, name }: GeneratorContext): DocumentParts {\n yield* jsDoc({\n description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,\n params: {\n params: `Any additional parameters for the bare call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`\n yield NewLine\n}\n\nfunction* callComposerTypeNoops({ app, name, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.noOpMethods) {\n if (!isAbiMethod(method)) continue\n const methodSig = method.signature\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = method.uniqueName.makeSafeMethodIdentifier\n\n yield* jsDoc({\n description: `Calls the ${methodSig} ABI method.`,\n abiDescription: method.desc,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`\n yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<${updatedReturnType}>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { name, sanitizer }: GeneratorContext,\n description: string,\n methods: AppClientMethodContext[],\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `readonly ${verb}: {`\n yield IncIndent\n for (const method of methods) {\n const onComplete = verb === 'create' ? method.createActions.inputType : undefined\n if (!isAbiMethod(method)) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<TReturns>`\n } else {\n const uniqueName = method.uniqueName.original\n yield* jsDoc({\n description: `${description} using the ${method.signature} ABI method.`,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n\n const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''\n }): ${name}Composer<${updatedReturnType}>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":["IncIndent","jsDoc","DecIndentAndCloseBlock","NewLine","isAbiMethod"],"mappings":";;;;;AAKM,UAAW,gBAAgB,CAAC,GAAqB,EAAA;AACrD,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG;IACzB,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD;AACzE,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC;AACjC,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,GAAG,CAAC,aAAa,EACjB,QAAQ,CACT;AACD,QAA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CAAA,CAAwC;AACjD,qBAAA;AACD,oBAAA,OAAO,EAAE,CAAA,6HAAA,CAA+H;AACzI,iBAAA,CAAC;gBACF,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,SAAS,CAAC;AAE3E,gBAAA,MAAM,iBAAiB,GAAG,CAAA,cAAA,EAAiB,IAAI,CAAA,SAAA,EAAY,aAAa,iBAAiB;AACzF,gBAAA,MAAM,CAAA,EAAG,SAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA,OAAA,EACrD,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,GAAG,GAAG,EAC3C,CAAA,aAAA,EAAgB,IAAI,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAA,GAAA,EAA6D,EAAE,CAAA,EACzJ,UAAU,EAAE,WAAW,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,WAAW,CAAA,CAAE,GAAG,EAC7D,CAAA,GAAA,EAAM,IAAI,CAAA,SAAA,EAAY,iBAAiB,CAAA,CAAA,CAAG;YAC5C;QACF;AACA,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMC,cAAO;IACf;AACF;;;;"}
@@ -1,19 +1,17 @@
1
1
  import { IncIndent, jsDoc, DecIndentAndCloseBlock, NewLine } from '../output/writer.mjs';
2
- import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
3
- import { getCreateOnCompleteOptions } from './deploy-types.mjs';
4
- import { ABIMethod } from 'algosdk';
2
+ import { isAbiMethod } from './app-client-context.mjs';
5
3
 
6
4
  function* callComposerType(ctx) {
7
- const { name, callConfig, app } = ctx;
5
+ const { name, app } = ctx;
8
6
  yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
9
7
  yield IncIndent;
10
8
  yield* callComposerTypeNoops(ctx);
11
9
  if (ctx.mode === 'full') {
12
- yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'update');
13
- yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
10
+ yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, app.updateMethods, 'update');
11
+ yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, app.deleteMethods, 'delete');
14
12
  }
15
- yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
16
- yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
13
+ yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, app.optInMethods, 'optIn');
14
+ yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, app.closeOutMethods, 'closeOut');
17
15
  yield* callComposerTypeClearState(ctx);
18
16
  yield* jsDoc({
19
17
  description: 'Adds a transaction to the composer',
@@ -30,16 +28,16 @@ function* callComposerType(ctx) {
30
28
  yield* jsDoc({
31
29
  description: 'Simulates the transaction group and returns the result',
32
30
  });
33
- yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
34
- yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
35
- yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`;
31
+ yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
32
+ yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
33
+ yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
36
34
  yield* jsDoc({
37
35
  description: 'Sends the transaction group to the network and returns the results',
38
36
  });
39
37
  yield `send(params?: SendParams): Promise<${name}ComposerResults<TReturns>>`;
40
38
  yield DecIndentAndCloseBlock;
41
39
  yield `
42
- export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendAtomicTransactionComposerResults & {
40
+ export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendTransactionComposerResults & {
43
41
  returns: TReturns
44
42
  }>
45
43
  `;
@@ -48,63 +46,62 @@ function* callComposerTypeClearState({ app, name }) {
48
46
  yield* jsDoc({
49
47
  description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,
50
48
  params: {
51
- args: `The arguments for the bare call`,
49
+ params: `Any additional parameters for the bare call`,
52
50
  },
53
51
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
54
52
  });
55
53
  yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`;
56
54
  yield NewLine;
57
55
  }
58
- function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
59
- for (const method of app.methods) {
60
- const methodSig = new ABIMethod(method).getSignature();
61
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
62
- const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig]);
63
- // Skip methods which don't support a no_op call config
64
- if (!callConfig.callMethods.includes(methodSig))
56
+ function* callComposerTypeNoops({ app, name, sanitizer }) {
57
+ for (const method of app.noOpMethods) {
58
+ if (!isAbiMethod(method))
65
59
  continue;
60
+ const methodSig = method.signature;
61
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
62
+ const methodName = method.uniqueName.makeSafeMethodIdentifier;
66
63
  yield* jsDoc({
67
- description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,
64
+ description: `Calls the ${methodSig} ABI method.`,
68
65
  abiDescription: method.desc,
69
66
  params: {
70
- args: `The arguments for the contract call`,
71
67
  params: `Any additional parameters for the call`,
72
68
  },
73
69
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
74
70
  });
75
- yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
71
+ const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`;
72
+ yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<${updatedReturnType}>`;
76
73
  yield NewLine;
77
74
  }
78
75
  }
79
- function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, name, sanitizer }, description, methods, verb, includeCompilation) {
76
+ function* callComposerOperationMethodType({ name, sanitizer }, description, methods, verb, includeCompilation) {
80
77
  if (methods.length) {
81
78
  yield* jsDoc(`Gets available ${verb} methods`);
82
79
  yield `readonly ${verb}: {`;
83
80
  yield IncIndent;
84
- for (const methodSig of methods) {
85
- const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined;
86
- if (methodSig === BARE_CALL) {
81
+ for (const method of methods) {
82
+ const onComplete = verb === 'create' ? method.createActions.inputType : undefined;
83
+ if (!isAbiMethod(method)) {
87
84
  yield* jsDoc({
88
85
  description: `${description} using a bare call.`,
89
86
  params: {
90
- args: `The arguments for the bare call`,
87
+ params: `Any additional parameters for the call`,
91
88
  },
92
89
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
93
90
  });
94
- yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<[...TReturns, undefined]>`;
91
+ yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<TReturns>`;
95
92
  }
96
93
  else {
97
- const uniqueName = methodSignatureToUniqueName[methodSig];
94
+ const uniqueName = method.uniqueName.original;
98
95
  yield* jsDoc({
99
- description: `${description} using the ${methodSig} ABI method.`,
96
+ description: `${description} using the ${method.signature} ABI method.`,
100
97
  params: {
101
- args: `The arguments for the smart contract call`,
102
98
  params: `Any additional parameters for the call`,
103
99
  },
104
100
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
105
101
  });
106
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
107
- yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
102
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
103
+ const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`;
104
+ yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}): ${name}Composer<${updatedReturnType}>`;
108
105
  }
109
106
  }
110
107
  yield DecIndentAndCloseBlock;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-composer-types.mjs","sources":["../../../src/client/call-composer-types.ts"],"sourcesContent":["import { DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nimport { AppClientMethodContext, isAbiMethod } from './app-client-context'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, app } = ctx\n yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`\n yield IncIndent\n\n yield* callComposerTypeNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethodType(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n app.updateMethods,\n 'update',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n app.deleteMethods,\n 'delete',\n )\n }\n yield* callComposerOperationMethodType(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n app.optInMethods,\n 'optIn',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Makes a close out call to an existing instance of the ${app.name} smart contract`,\n app.closeOutMethods,\n 'closeOut',\n )\n\n yield* callComposerTypeClearState(ctx)\n\n yield* jsDoc({\n description: 'Adds a transaction to the composer',\n params: {\n txn: 'A transaction to add to the transaction group',\n signer: 'The optional signer to use when signing this transaction.',\n },\n })\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner): ${name}Composer<TReturns>`\n\n yield* jsDoc({\n description: 'Returns the underlying AtomicTransactionComposer instance',\n })\n yield `composer(): Promise<TransactionComposer>`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`\n\n yield* jsDoc({\n description: 'Sends the transaction group to the network and returns the results',\n })\n yield `send(params?: SendParams): Promise<${name}ComposerResults<TReturns>>`\n\n yield DecIndentAndCloseBlock\n\n yield `\n export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendTransactionComposerResults & {\n returns: TReturns\n }>\n `\n}\n\nfunction* callComposerTypeClearState({ app, name }: GeneratorContext): DocumentParts {\n yield* jsDoc({\n description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,\n params: {\n params: `Any additional parameters for the bare call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`\n yield NewLine\n}\n\nfunction* callComposerTypeNoops({ app, name, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.noOpMethods) {\n if (!isAbiMethod(method)) continue\n const methodSig = method.signature\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = method.uniqueName.makeSafeMethodIdentifier\n\n yield* jsDoc({\n description: `Calls the ${methodSig} ABI method.`,\n abiDescription: method.desc,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`\n yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<${updatedReturnType}>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { name, sanitizer }: GeneratorContext,\n description: string,\n methods: AppClientMethodContext[],\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `readonly ${verb}: {`\n yield IncIndent\n for (const method of methods) {\n const onComplete = verb === 'create' ? method.createActions.inputType : undefined\n if (!isAbiMethod(method)) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<TReturns>`\n } else {\n const uniqueName = method.uniqueName.original\n yield* jsDoc({\n description: `${description} using the ${method.signature} ABI method.`,\n params: {\n params: `Any additional parameters for the call`,\n },\n returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,\n })\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n\n const updatedReturnType = `[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]`\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''\n }): ${name}Composer<${updatedReturnType}>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":[],"mappings":";;;AAKM,UAAW,gBAAgB,CAAC,GAAqB,EAAA;AACrD,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG;IACzB,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD;AACzE,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC;AACjC,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,GAAG,CAAC,aAAa,EACjB,QAAQ,CACT;AACD,QAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,GAAG,CAAC,aAAa,EACjB,QAAQ,CACT;IACH;AACA,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,kDAAkD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3E,GAAG,CAAC,YAAY,EAChB,OAAO,CACR;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,yDAAyD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAClF,GAAG,CAAC,eAAe,EACnB,UAAU,CACX;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC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,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAA,GAAA,EAA6D,EAAE,CAAA,EACzJ,UAAU,EAAE,WAAW,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,WAAW,CAAA,CAAE,GAAG,EAC7D,CAAA,GAAA,EAAM,IAAI,CAAA,SAAA,EAAY,iBAAiB,CAAA,CAAA,CAAG;YAC5C;QACF;AACA,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,OAAO;IACf;AACF;;;;"}
@@ -1,28 +1,25 @@
1
1
  'use strict';
2
2
 
3
3
  var writer = require('../output/writer.js');
4
- var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
5
- var deployTypes = require('./deploy-types.js');
6
- var algosdk = require('algosdk');
4
+ var appClientContext = require('./app-client-context.js');
7
5
 
8
6
  function* composeMethod(ctx) {
9
- const { name, callConfig } = ctx;
7
+ const { name, app } = ctx;
10
8
  // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid
11
- yield `public newGroup(): ${name}Composer {`;
9
+ yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`;
12
10
  yield writer.IncIndent;
13
11
  yield `const client = this`;
14
- yield `const composer = this.algorand.newGroup()`;
12
+ yield `const composer = this.algorand.newGroup(composerConfig)`;
15
13
  yield `let promiseChain:Promise<unknown> = Promise.resolve()`;
16
- yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
17
14
  yield `return {`;
18
15
  yield writer.IncIndent;
19
16
  yield* callComposerNoops(ctx);
20
17
  if (ctx.mode === 'full') {
21
- yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
22
- yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
18
+ yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true);
19
+ yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete');
23
20
  }
24
- yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn');
25
- yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut');
21
+ yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn');
22
+ yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut');
26
23
  yield* callComposerClearState(ctx);
27
24
  yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
28
25
  yield writer.IncIndent;
@@ -43,7 +40,7 @@ function* composeMethod(ctx) {
43
40
  yield `return {`;
44
41
  yield writer.IncIndent;
45
42
  yield `...result,`;
46
- yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
43
+ yield `returns: result.returns?.map(val => val.returnValue)`;
47
44
  yield writer.DecIndentAndCloseBlock;
48
45
  yield writer.DecIndent;
49
46
  yield '},';
@@ -54,36 +51,34 @@ function* composeMethod(ctx) {
54
51
  yield `return {`;
55
52
  yield writer.IncIndent;
56
53
  yield `...result,`;
57
- yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
54
+ yield `returns: result.returns?.map(val => val.returnValue)`;
58
55
  yield writer.DecIndentAndCloseBlock;
59
56
  yield writer.DecIndentAndCloseBlock;
60
57
  yield writer.DecIndent;
61
58
  yield `} as unknown as ${name}Composer`;
62
59
  yield writer.DecIndentAndCloseBlock;
63
60
  }
64
- function* callComposerNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
65
- if (callConfig.callMethods.includes(getCallConfigSummary.BARE_CALL)) {
61
+ function* callComposerNoops({ app, name, sanitizer }) {
62
+ if (app.bareMethod.callActions.noOp) {
66
63
  yield* writer.jsDoc(`Add a bare method call to the ${app.name} contract`);
67
- yield `bare(params: AppClientBareCallParams & ${deployTypes.getCallOnCompleteOptions(getCallConfigSummary.BARE_CALL, app).type}) {`;
64
+ yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`;
68
65
  yield writer.IncIndent;
69
66
  yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`;
70
67
  yield `return this`;
71
68
  yield writer.DecIndent;
72
69
  yield '},';
73
70
  }
74
- for (const methodSignature of callConfig.callMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).map((m) => m)) {
75
- const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
76
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
71
+ for (const method of app.abiMethods) {
72
+ const methodName = method.uniqueName.makeSafeMethodIdentifier;
73
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
77
74
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
78
75
  // Skip methods which don't support a no_op call config
79
- if (!callConfig.callMethods.includes(methodSignature))
76
+ if (!method.callActions.noOp)
80
77
  continue;
81
- yield* writer.jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`);
82
- yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${deployTypes.getCallOnCompleteOptions(methodSignature, app).type}) {`;
78
+ yield* writer.jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`);
79
+ yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`;
83
80
  yield writer.IncIndent;
84
81
  yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`;
85
- const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSignature)?.returns.type;
86
- yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
87
82
  yield `return this`;
88
83
  yield writer.DecIndent;
89
84
  yield '},';
@@ -98,15 +93,15 @@ function* callComposerClearState({ app }) {
98
93
  yield writer.DecIndent;
99
94
  yield '},';
100
95
  }
101
- function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName, sanitizer }, methods, verb, includeCompilation) {
96
+ function* callComposerOperationMethods({ name, sanitizer }, methods, verb, includeCompilation) {
102
97
  const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
103
98
  if (methods.length) {
104
99
  yield `get ${verb}() {`;
105
100
  yield writer.IncIndent;
106
101
  yield `return {`;
107
102
  yield writer.IncIndent;
108
- for (const methodSig of methods) {
109
- if (methodSig === getCallConfigSummary.BARE_CALL) {
103
+ for (const method of methods) {
104
+ if (!appClientContext.isAbiMethod(method)) {
110
105
  yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`;
111
106
  yield writer.IncIndent;
112
107
  yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`;
@@ -115,15 +110,13 @@ function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName,
115
110
  yield '},';
116
111
  }
117
112
  else {
118
- const uniqueName = methodSignatureToUniqueName[methodSig];
113
+ const uniqueName = method.uniqueName.original;
119
114
  const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
120
115
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
121
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
116
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
122
117
  yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`;
123
118
  yield writer.IncIndent;
124
119
  yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`;
125
- const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig)?.returns.type;
126
- yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
127
120
  yield `return this`;
128
121
  yield writer.DecIndent;
129
122
  yield '},';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-composer.js","sources":["../../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { AppClientMethodContext, isAbiMethod } from './app-client-context'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, app } = ctx\n // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid\n yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup(composerConfig)`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut')\n yield* callComposerClearState(ctx)\n\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async composer() {`\n yield IncIndent\n yield `await promiseChain`\n yield 'return composer'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await (!options ? composer.simulate() : composer.simulate(options))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async send(params?: SendParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await composer.send(params)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `} as unknown as ${name}Composer`\n\n yield DecIndentAndCloseBlock\n}\n\nfunction* callComposerNoops({ app, name, sanitizer }: GeneratorContext): DocumentParts {\n if (app.bareMethod.callActions.noOp) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n\n for (const method of app.abiMethods) {\n const methodName = method.uniqueName.makeSafeMethodIdentifier\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!method.callActions.noOp) continue\n yield* jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc(`Add a clear state call to the ${app.name} contract`)\n yield `clearState(params: AppClientBareCallParams) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { name, sanitizer }: GeneratorContext,\n methods: AppClientMethodContext[],\n verb: 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call'\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const method of methods) {\n if (!isAbiMethod(method)) {\n yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n } else {\n const uniqueName = method.uniqueName.original\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":["IncIndent","DecIndent","DecIndentAndCloseBlock","jsDoc","isAbiMethod"],"mappings":";;;;;AAIM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG;;IAEzB,MAAM,CAAA,6DAAA,EAAgE,IAAI,CAAA,UAAA,CAAY;AACtF,IAAA,MAAMA,gBAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,yDAAyD;AAC/D,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAA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QAAQ,CAAA,CAAA,EAAI,IAAI,KAAK,QAAQ,GAAG,QAAQ,GAAG,EAAE,CAAA,cAAA,EAAiB,IAAI,iBAAiB;AACtL,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAMC,gBAAS;AACf,gBAAA,MAAM,IAAI;YACZ;iBAAO;AACL,gBAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ;gBAC7C,MAAM,UAAU,GAAG,SAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBACjE,MAAM,kBAAkB,GAAG,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACtE,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,SAAS,CAAC;gBAC3E,MAAM,CAAA,EAAG,UAAU,CAAA,sBAAA,EAAyB,IAAI,gBAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,MAAM,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,MAAA,CAAQ;AAC/L,gBAAA,MAAMD,gBAAS;AACf,gBAAA,MAAM,+DAA+D,QAAQ,CAAA,+BAAA,EAAkC,IAAI,CAAA,EAAG,kBAAkB,YAAY;AACpJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAMC,gBAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMD,gBAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
@@ -1,26 +1,23 @@
1
1
  import { IncIndent, DecIndent, DecIndentAndCloseBlock, jsDoc } from '../output/writer.mjs';
2
- import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
3
- import { getCallOnCompleteOptions } from './deploy-types.mjs';
4
- import { ABIMethod } from 'algosdk';
2
+ import { isAbiMethod } from './app-client-context.mjs';
5
3
 
6
4
  function* composeMethod(ctx) {
7
- const { name, callConfig } = ctx;
5
+ const { name, app } = ctx;
8
6
  // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid
9
- yield `public newGroup(): ${name}Composer {`;
7
+ yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`;
10
8
  yield IncIndent;
11
9
  yield `const client = this`;
12
- yield `const composer = this.algorand.newGroup()`;
10
+ yield `const composer = this.algorand.newGroup(composerConfig)`;
13
11
  yield `let promiseChain:Promise<unknown> = Promise.resolve()`;
14
- yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
15
12
  yield `return {`;
16
13
  yield IncIndent;
17
14
  yield* callComposerNoops(ctx);
18
15
  if (ctx.mode === 'full') {
19
- yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
20
- yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
16
+ yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true);
17
+ yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete');
21
18
  }
22
- yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn');
23
- yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut');
19
+ yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn');
20
+ yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut');
24
21
  yield* callComposerClearState(ctx);
25
22
  yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
26
23
  yield IncIndent;
@@ -41,7 +38,7 @@ function* composeMethod(ctx) {
41
38
  yield `return {`;
42
39
  yield IncIndent;
43
40
  yield `...result,`;
44
- yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
41
+ yield `returns: result.returns?.map(val => val.returnValue)`;
45
42
  yield DecIndentAndCloseBlock;
46
43
  yield DecIndent;
47
44
  yield '},';
@@ -52,36 +49,34 @@ function* composeMethod(ctx) {
52
49
  yield `return {`;
53
50
  yield IncIndent;
54
51
  yield `...result,`;
55
- yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
52
+ yield `returns: result.returns?.map(val => val.returnValue)`;
56
53
  yield DecIndentAndCloseBlock;
57
54
  yield DecIndentAndCloseBlock;
58
55
  yield DecIndent;
59
56
  yield `} as unknown as ${name}Composer`;
60
57
  yield DecIndentAndCloseBlock;
61
58
  }
62
- function* callComposerNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
63
- if (callConfig.callMethods.includes(BARE_CALL)) {
59
+ function* callComposerNoops({ app, name, sanitizer }) {
60
+ if (app.bareMethod.callActions.noOp) {
64
61
  yield* jsDoc(`Add a bare method call to the ${app.name} contract`);
65
- yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`;
62
+ yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`;
66
63
  yield IncIndent;
67
64
  yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`;
68
65
  yield `return this`;
69
66
  yield DecIndent;
70
67
  yield '},';
71
68
  }
72
- for (const methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m)) {
73
- const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
74
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
69
+ for (const method of app.abiMethods) {
70
+ const methodName = method.uniqueName.makeSafeMethodIdentifier;
71
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
75
72
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
76
73
  // Skip methods which don't support a no_op call config
77
- if (!callConfig.callMethods.includes(methodSignature))
74
+ if (!method.callActions.noOp)
78
75
  continue;
79
- yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`);
80
- yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`;
76
+ yield* jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`);
77
+ yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`;
81
78
  yield IncIndent;
82
79
  yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`;
83
- const outputTypeName = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type;
84
- yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
85
80
  yield `return this`;
86
81
  yield DecIndent;
87
82
  yield '},';
@@ -96,15 +91,15 @@ function* callComposerClearState({ app }) {
96
91
  yield DecIndent;
97
92
  yield '},';
98
93
  }
99
- function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName, sanitizer }, methods, verb, includeCompilation) {
94
+ function* callComposerOperationMethods({ name, sanitizer }, methods, verb, includeCompilation) {
100
95
  const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
101
96
  if (methods.length) {
102
97
  yield `get ${verb}() {`;
103
98
  yield IncIndent;
104
99
  yield `return {`;
105
100
  yield IncIndent;
106
- for (const methodSig of methods) {
107
- if (methodSig === BARE_CALL) {
101
+ for (const method of methods) {
102
+ if (!isAbiMethod(method)) {
108
103
  yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`;
109
104
  yield IncIndent;
110
105
  yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`;
@@ -113,15 +108,13 @@ function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName,
113
108
  yield '},';
114
109
  }
115
110
  else {
116
- const uniqueName = methodSignatureToUniqueName[methodSig];
111
+ const uniqueName = method.uniqueName.original;
117
112
  const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
118
113
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
119
- const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
114
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
120
115
  yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`;
121
116
  yield IncIndent;
122
117
  yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`;
123
- const outputTypeName = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)?.returns.type;
124
- yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
125
118
  yield `return this`;
126
119
  yield DecIndent;
127
120
  yield '},';