@algorandfoundation/algokit-client-generator 6.0.0-beta.2 → 6.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +54 -4
  2. package/cli.d.ts +3 -3
  3. package/cli.js +12 -4
  4. package/cli.js.map +1 -1
  5. package/cli.mjs +13 -5
  6. package/cli.mjs.map +1 -1
  7. package/client/app-client.js +4 -2
  8. package/client/app-client.js.map +1 -1
  9. package/client/app-client.mjs +4 -2
  10. package/client/app-client.mjs.map +1 -1
  11. package/client/app-factory.js.map +1 -1
  12. package/client/app-factory.mjs.map +1 -1
  13. package/client/app-types.js.map +1 -1
  14. package/client/app-types.mjs.map +1 -1
  15. package/client/call-composer-types.js +7 -5
  16. package/client/call-composer-types.js.map +1 -1
  17. package/client/call-composer-types.mjs +7 -5
  18. package/client/call-composer-types.mjs.map +1 -1
  19. package/client/call-composer.js +4 -2
  20. package/client/call-composer.js.map +1 -1
  21. package/client/call-composer.mjs +4 -2
  22. package/client/call-composer.mjs.map +1 -1
  23. package/client/deploy-types.js.map +1 -1
  24. package/client/deploy-types.mjs.map +1 -1
  25. package/client/generate.d.ts +1 -1
  26. package/client/generate.js +59 -8
  27. package/client/generate.js.map +1 -1
  28. package/client/generate.mjs +59 -8
  29. package/client/generate.mjs.map +1 -1
  30. package/client/generator-context.d.ts +10 -7
  31. package/client/generator-context.js +7 -0
  32. package/client/generator-context.js.map +1 -1
  33. package/client/generator-context.mjs +7 -1
  34. package/client/generator-context.mjs.map +1 -1
  35. package/client/helpers/get-call-config-summary.js.map +1 -1
  36. package/client/helpers/get-call-config-summary.mjs.map +1 -1
  37. package/client/helpers/get-equivalent-type.js.map +1 -1
  38. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  39. package/client/imports.d.ts +2 -1
  40. package/client/imports.js +2 -3
  41. package/client/imports.js.map +1 -1
  42. package/client/imports.mjs +2 -3
  43. package/client/imports.mjs.map +1 -1
  44. package/client/params-factory.js +5 -3
  45. package/client/params-factory.js.map +1 -1
  46. package/client/params-factory.mjs +5 -3
  47. package/client/params-factory.mjs.map +1 -1
  48. package/output/writer.js.map +1 -1
  49. package/output/writer.mjs.map +1 -1
  50. package/package.json +1 -7
  51. package/schema/load.js.map +1 -1
  52. package/schema/load.mjs.map +1 -1
  53. package/util/boom.js.map +1 -1
  54. package/util/boom.mjs.map +1 -1
  55. package/util/color-console.js.map +1 -1
  56. package/util/color-console.mjs.map +1 -1
  57. package/util/sanitization.d.ts +2 -3
  58. package/util/sanitization.js +1 -1
  59. package/util/sanitization.js.map +1 -1
  60. package/util/sanitization.mjs +1 -1
  61. package/util/sanitization.mjs.map +1 -1
  62. package/tests/approval-tests.spec.d.ts +0 -1
@@ -10,10 +10,12 @@ function* callComposerType(ctx) {
10
10
  yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
11
11
  yield writer.IncIndent;
12
12
  yield* callComposerTypeNoops(ctx);
13
- yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
13
+ 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');
16
+ }
14
17
  yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
15
18
  yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
16
- yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'update');
17
19
  yield* callComposerTypeClearState(ctx);
18
20
  yield* writer.jsDoc({
19
21
  description: 'Adds a transaction to the composer',
@@ -30,9 +32,9 @@ function* callComposerType(ctx) {
30
32
  yield* writer.jsDoc({
31
33
  description: 'Simulates the transaction group and returns the result',
32
34
  });
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 }>`;
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 }>`;
36
38
  yield* writer.jsDoc({
37
39
  description: 'Sends the transaction group to the network and returns the results',
38
40
  });
@@ -1 +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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { ABIMethod } from 'algosdk'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig, app } = ctx\n yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`\n yield IncIndent\n\n yield* callComposerTypeNoops(ctx)\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n callConfig.deleteMethods,\n 'delete',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n callConfig.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 callConfig.closeOutMethods,\n 'closeOut',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\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<SendAtomicTransactionComposerResults & {\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 args: `The arguments 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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.methods) {\n const methodSig = new ABIMethod(method).getSignature()\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSig)) continue\n\n yield* jsDoc({\n description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,\n abiDescription: method.desc,\n params: {\n args: `The arguments for the contract call`,\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 `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { app, methodSignatureToUniqueName, name, sanitizer }: GeneratorContext,\n description: string,\n methods: MethodList,\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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig === BARE_CALL) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n args: `The arguments 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 `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<[...TReturns, undefined]>`\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n params: {\n args: `The arguments for the smart contract call`,\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(methodSig)\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":["IncIndent","jsDoc","DecIndentAndCloseBlock","NewLine","ABIMethod","getCreateOnCompleteOptions","BARE_CALL"],"mappings":";;;;;;;AAOe,UAAE,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG;IACrC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD;AACzE,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC;AACjC,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,kDAAkD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3E,UAAU,CAAC,YAAY,EACvB,OAAO,CACR;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,yDAAyD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAClF,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC;IAEtC,OAAOC,YAAK,CAAC;AACX,QAAA,WAAW,EAAE,oCAAoC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,EAAgB,IAAI,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAM,GAAA,EAAuD,EAAE,CACzJ,EAAA,UAAU,EAAE,IAAI,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,IAAI,CAAA,CAAE,GAAG,EAC/C,CAAM,GAAA,EAAA,IAAI,CAA0B,uBAAA,EAAA,IAAI,CAAY,SAAA,EAAA,aAAa,kBAAkB;;;AAGvF,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMC,cAAO;;AAEjB;;;;"}
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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { ABIMethod } from 'algosdk'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig, 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 callConfig.updateMethods,\n 'update',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n callConfig.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 callConfig.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 callConfig.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: modelsv2.SimulateResponse }>`\n yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`\n yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.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<SendAtomicTransactionComposerResults & {\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 args: `The arguments 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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.methods) {\n const methodSig = new ABIMethod(method).getSignature()\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSig)) continue\n\n yield* jsDoc({\n description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,\n abiDescription: method.desc,\n params: {\n args: `The arguments for the contract call`,\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 `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { app, methodSignatureToUniqueName, name, sanitizer }: GeneratorContext,\n description: string,\n methods: MethodList,\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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig === BARE_CALL) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n args: `The arguments 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 `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<[...TReturns, undefined]>`\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n params: {\n args: `The arguments for the smart contract call`,\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(methodSig)\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":["IncIndent","jsDoc","DecIndentAndCloseBlock","NewLine","ABIMethod","getCreateOnCompleteOptions","BARE_CALL"],"mappings":";;;;;;;AAOM,UAAW,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG;IACrC,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,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT;AACD,QAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT;IACH;AACA,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,kDAAkD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3E,UAAU,CAAC,YAAY,EACvB,OAAO,CACR;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,yDAAyD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAClF,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC;IAEtC,OAAOC,YAAK,CAAC;AACX,QAAA,WAAW,EAAE,oCAAoC;AACjD,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,EAAE,+CAA+C;AACpD,YAAA,MAAM,EAAE,2DAA2D;AACpE,SAAA;AACF,KAAA,CAA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,EAAE,CAAA,EACzJ,UAAU,EAAE,IAAI,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,IAAI,CAAA,CAAE,GAAG,EAC/C,CAAA,GAAA,EAAM,IAAI,CAAA,uBAAA,EAA0B,IAAI,CAAA,SAAA,EAAY,aAAa,kBAAkB;YACrF;QACF;AACA,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMC,cAAO;IACf;AACF;;;;"}
@@ -8,10 +8,12 @@ function* callComposerType(ctx) {
8
8
  yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
9
9
  yield IncIndent;
10
10
  yield* callComposerTypeNoops(ctx);
11
- yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
11
+ 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');
14
+ }
12
15
  yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
13
16
  yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
14
- yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'update');
15
17
  yield* callComposerTypeClearState(ctx);
16
18
  yield* jsDoc({
17
19
  description: 'Adds a transaction to the composer',
@@ -28,9 +30,9 @@ function* callComposerType(ctx) {
28
30
  yield* jsDoc({
29
31
  description: 'Simulates the transaction group and returns the result',
30
32
  });
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 }>`;
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 }>`;
34
36
  yield* jsDoc({
35
37
  description: 'Sends the transaction group to the network and returns the results',
36
38
  });
@@ -1 +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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { ABIMethod } from 'algosdk'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig, app } = ctx\n yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`\n yield IncIndent\n\n yield* callComposerTypeNoops(ctx)\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n callConfig.deleteMethods,\n 'delete',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n callConfig.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 callConfig.closeOutMethods,\n 'closeOut',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\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<SendAtomicTransactionComposerResults & {\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 args: `The arguments 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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.methods) {\n const methodSig = new ABIMethod(method).getSignature()\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSig)) continue\n\n yield* jsDoc({\n description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,\n abiDescription: method.desc,\n params: {\n args: `The arguments for the contract call`,\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 `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { app, methodSignatureToUniqueName, name, sanitizer }: GeneratorContext,\n description: string,\n methods: MethodList,\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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig === BARE_CALL) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n args: `The arguments 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 `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<[...TReturns, undefined]>`\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n params: {\n args: `The arguments for the smart contract call`,\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(methodSig)\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, ${name}Returns['${methodSig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AAsB;AAC5B,QAAA,MAAM,OAAO;;AAEjB;;;;"}
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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { ABIMethod } from 'algosdk'\n\nexport function* callComposerType(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig, 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 callConfig.updateMethods,\n 'update',\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.name} smart contract`,\n callConfig.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 callConfig.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 callConfig.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: modelsv2.SimulateResponse }>`\n yield `simulate(options: SkipSignaturesSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.SimulateResponse }>`\n yield `simulate(options: RawSimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: modelsv2.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<SendAtomicTransactionComposerResults & {\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 args: `The arguments 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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.methods) {\n const methodSig = new ABIMethod(method).getSignature()\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSig)) continue\n\n yield* jsDoc({\n description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,\n abiDescription: method.desc,\n params: {\n args: `The arguments for the contract call`,\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 `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n yield NewLine\n }\n}\n\nfunction* callComposerOperationMethodType(\n { app, methodSignatureToUniqueName, name, sanitizer }: GeneratorContext,\n description: string,\n methods: MethodList,\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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig === BARE_CALL) {\n yield* jsDoc({\n description: `${description} using a bare call.`,\n params: {\n args: `The arguments 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 `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${\n includeCompilation ? '& AppClientCompilationParams' : ''\n }): ${name}Composer<[...TReturns, undefined]>`\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} ABI method.`,\n params: {\n args: `The arguments for the smart contract call`,\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(methodSig)\n yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${\n onComplete?.isOptional !== false ? '?' : ''\n }: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":[],"mappings":";;;;;AAOM,UAAW,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG;IACrC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD;AACzE,IAAA,MAAM,SAAS;AAEf,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E,UAAU,KAAK,KAAK,GAAG,GAAG,GAAG,EAAE,CAAA,0BAAA,EACP,EACxD,CAAA,GAAA,EAAM,IAAI,CAAA,kCAAA,CAAoC;YAChD;iBAAO;AACL,gBAAA,MAAM,UAAU,GAAG,2BAA2B,CAAC,SAAS,CAAC;gBACzD,OAAO,KAAK,CAAC;AACX,oBAAA,WAAW,EAAE,CAAA,EAAG,WAAW,CAAA,WAAA,EAAc,SAAS,CAAA,YAAA,CAAc;AAChE,oBAAA,MAAM,EAAE;AACN,wBAAA,IAAI,EAAE,CAAA,yCAAA,CAA2C;AACjD,wBAAA,MAAM,EAAE,CAAA,sCAAA,CAAwC;AACjD,qBAAA;AACD,oBAAA,OAAO,EAAE,CAAA,6HAAA,CAA+H;AACzI,iBAAA,CAAC;gBACF,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC;AACpE,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,IAAI,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,IAAI,CAAA,CAAE,GAAG,EAC/C,CAAA,GAAA,EAAM,IAAI,CAAA,uBAAA,EAA0B,IAAI,CAAA,SAAA,EAAY,aAAa,kBAAkB;YACrF;QACF;AACA,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,OAAO;IACf;AACF;;;;"}
@@ -17,8 +17,10 @@ function* composeMethod(ctx) {
17
17
  yield `return {`;
18
18
  yield writer.IncIndent;
19
19
  yield* callComposerNoops(ctx);
20
- yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
21
- yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
20
+ if (ctx.mode === 'full') {
21
+ yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
22
+ yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
23
+ }
22
24
  yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn');
23
25
  yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut');
24
26
  yield* callComposerClearState(ctx);
@@ -1 +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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = 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(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\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 methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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 { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\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 methodSig of methods) {\n if (methodSig === BARE_CALL) {\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 = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\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 const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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","BARE_CALL","jsDoc","getCallOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAMe,UAAE,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG;;IAEhC,MAAM,CAAA,mBAAA,EAAsB,IAAI,CAAA,UAAA,CAAY;AAC5C,IAAA,MAAMA,gBAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,2CAA2C;AACjD,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,kFAAkF;AACxF,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;AAC7B,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;AAClF,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC;AAC5E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC;AAChF,IAAA,OAAO,sBAAsB,CAAC,GAAG,CAAC;AAEl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;"}
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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = 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(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\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 methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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 { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\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 methodSig of methods) {\n if (methodSig === BARE_CALL) {\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 = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\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 const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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","BARE_CALL","jsDoc","getCallOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAMM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG;;IAEhC,MAAM,CAAA,mBAAA,EAAsB,IAAI,CAAA,UAAA,CAAY;AAC5C,IAAA,MAAMA,gBAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,2CAA2C;AACjD,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,kFAAkF;AACxF,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;AAC7B,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;AAClF,QAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC;IAC9E;AACA,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC;AAChF,IAAA,OAAO,sBAAsB,CAAC,GAAG,CAAC;AAElC,IAAA,MAAM,gEAAgE;AACtE,IAAA,MAAMA,gBAAS;AACf,IAAA,MAAM,8EAA8E;AACpF,IAAA,MAAM,aAAa;AACnB,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,IAAI;AAEV,IAAA,MAAM,oBAAoB;AAC1B,IAAA,MAAMD,gBAAS;AACf,IAAA,MAA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AAO;AACL,gBAAA,MAAM,UAAU,GAAG,2BAA2B,CAAC,SAAS,CAAC;gBACzD,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,SAAS,CAAC;gBACpE,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,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAkB,KAAK,IAAIM,iBAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;AAC5H,gBAAA,MAAM,sBAAsB,cAAc,IAAI,cAAc,KAAK,MAAM,GAAG,CAAA,iCAAA,EAAoC,aAAa,CAAA,KAAA,CAAO,GAAG,WAAW,GAAG;AACnJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAML,gBAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMD,gBAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
@@ -15,8 +15,10 @@ function* composeMethod(ctx) {
15
15
  yield `return {`;
16
16
  yield IncIndent;
17
17
  yield* callComposerNoops(ctx);
18
- yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
19
- yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
18
+ if (ctx.mode === 'full') {
19
+ yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true);
20
+ yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
21
+ }
20
22
  yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn');
21
23
  yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut');
22
24
  yield* callComposerClearState(ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"call-composer.mjs","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = 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(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\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 methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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 { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\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 methodSig of methods) {\n if (methodSig === BARE_CALL) {\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 = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\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 const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":[],"mappings":";;;;;AAMe,UAAE,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG;;IAEhC,MAAM,CAAA,mBAAA,EAAsB,IAAI,CAAA,UAAA,CAAY;AAC5C,IAAA,MAAM,SAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,2CAA2C;AACjD,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,kFAAkF;AACxF,IAAA,MAAM,UAAU;AAChB,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;AAC7B,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;AAClF,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC;AAC5E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC;AAC1E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC;AAChF,IAAA,OAAO,sBAAsB,CAAC,GAAG,CAAC;AAElC,IAAA,MAAM,gEAAgE;AACtE,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,8EAA8E;AACpF,IAAA,MAAM,aAAa;AACnB,IAAA,MAAM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AACf,gBAAA,MAAM,IAAI;;iBACL;AACL,gBAAA,MAAM,UAAU,GAAG,2BAA2B,CAAC,SAAS,CAAC;gBACzD,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,SAAS,CAAC;gBACpE,MAAM,CAAA,EAAG,UAAU,CAAyB,sBAAA,EAAA,IAAI,gBAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAkB,eAAA,EAAA,aAAa,MAAM,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,MAAA,CAAQ;AAC/L,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,+DAA+D,QAAQ,CAAA,+BAAA,EAAkC,IAAI,CAAG,EAAA,kBAAkB,YAAY;AACpJ,gBAAA,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAkB,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;AAC5H,gBAAA,MAAM,sBAAsB,cAAc,IAAI,cAAc,KAAK,MAAM,GAAG,CAAA,iCAAA,EAAoC,aAAa,CAAO,KAAA,CAAA,GAAG,WAAW,GAAG;AACnJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,IAAI;;;AAGd,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,SAAS;AACf,QAAA,MAAM,IAAI;;AAEd;;;;"}
1
+ {"version":3,"file":"call-composer.mjs","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = 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(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, i) => resultMappers[i] !== undefined ? resultMappers[i]!(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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\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 methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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 { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\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 methodSig of methods) {\n if (methodSig === BARE_CALL) {\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 = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\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 const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":[],"mappings":";;;;;AAMM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU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CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,MAAM,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,MAAA,CAAQ;AAC/L,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,+DAA+D,QAAQ,CAAA,+BAAA,EAAkC,IAAI,CAAA,EAAG,kBAAkB,YAAY;AACpJ,gBAAA,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAkB,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;AAC5H,gBAAA,MAAM,sBAAsB,cAAc,IAAI,cAAc,KAAK,MAAM,GAAG,CAAA,iCAAA,EAAoC,aAAa,CAAA,KAAA,CAAO,GAAG,WAAW,GAAG;AACnJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,SAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"deploy-types.js","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":["BARE_CALL","ABIMethod","jsDoc","IncIndent","DecIndent","NewLine"],"mappings":";;;;;;AAMgB,SAAA,0BAA0B,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACrF,IAAA,MAAM,sBAAsB,GAC1B,MAAM,KAAKA,8BAAS,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAIC,iBAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;IACtI,MAAM,OAAO,GAAG,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxD,MAAM,cAAc,GAAG;AACrB,UAAE,CAAA,WAAA,EAAc,OAAO,GAAG,GAAG,GAAG,EAAE,CAAA,EAAA,EAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAyB,sBAAA,EAAA,EAAE,CAAI,EAAA,CAAA,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAG,CAAA;UACvH,EAAE;IACN,OAAO;AACL,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,UAAU,EAAE,OAAO;KACpB;AACH;AAEgB,SAAA,wBAAwB,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACnF,IAAA,MAAM,oBAAoB,GACxB,MAAM,KAAKD,8BAAS,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAIC,iBAAS,CAAC,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AM,EAAE;AACnC,QAAA,OAAOD,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;;AAEhD,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;;AAEhD,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;;AAEhD,IAAA,MAAME,gBAAS;AACf,IAAA,MAAM,IAAI;AACV,IAAA,MAAMC,cAAO;AACf;;;;;;"}
1
+ {"version":3,"file":"deploy-types.js","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}DeleteCallPar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CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,MAAME,gBAAS;AACf,IAAA,MAAM,IAAI;AACV,IAAA,MAAMC,cAAO;AACf;;;;;;"}
@@ -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":";;;;AAMgB,SAAA,0BAA0B,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACrF,IAAA,M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;;AAEhD,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,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 { 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,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;IACtI,MAAM,OAAO,GAAG,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxD,MAAM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AC,yBAAyB,CAAC,UAAU,CAAC;oBAClE,MAAM,CAAA,oBAAA,EAAuB,IAAI,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAA,gBAAA,EAAmB,UAAU,CAAA,GAAA,CAAK;gBAC7I;gBACA,MAAM,CAAA,oBAAA,EAAuB,IAAI,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAA,gBAAA,EAAmB,aAAa,CAAA,GAAA,CAAK;YAChJ;QACF;AACA,QAAA,MAAM,SAAS;IACjB;AAEA,IAAA,OAAO,KAAK,CAAC,mDAAmD,CAAC;IACjE,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,wGAAA,CAA0G;AACnI,IAAA,MAAM,SAAS;AACf,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAO,KAAK,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
3
  import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
4
- export declare function generate(app: Arc56Contract, options?: GeneratorOptions): DocumentParts;
4
+ export declare function generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts;
@@ -17,30 +17,81 @@ function convertStructs(s, sanitizer) {
17
17
  type: typeof type === 'string' ? type : convertStructs(type, sanitizer),
18
18
  }));
19
19
  }
20
- function* generate(app, options = { preserveNames: false }) {
21
- const ctx = generatorContext.createGeneratorContext(app, options);
20
+ function shrinkAppSpec(app, options) {
21
+ const strippedAppSpec = structuredClone(app);
22
+ // Only keep the source info if it is needed for error mapping
23
+ const shrinkSourceInfo = (sourceInfo) => {
24
+ return sourceInfo
25
+ .filter((entry) => entry.errorMessage)
26
+ .map((entry) => ({
27
+ pc: entry.pc,
28
+ errorMessage: entry.errorMessage,
29
+ // Keep minimal context for error mapping if available
30
+ ...(entry.teal !== undefined && { teal: entry.teal }),
31
+ }));
32
+ };
33
+ // Keep only source info entries that can be used for approval and clear program error mapping
34
+ if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {
35
+ strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo);
36
+ }
37
+ if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {
38
+ strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo);
39
+ }
40
+ if (strippedAppSpec.compilerInfo) {
41
+ delete strippedAppSpec.compilerInfo;
42
+ }
43
+ // These are used for deploying but not for calling deployed apps
44
+ if (options.mode === 'minimal') {
45
+ if (strippedAppSpec.source) {
46
+ delete strippedAppSpec.source;
47
+ }
48
+ if (strippedAppSpec.byteCode) {
49
+ delete strippedAppSpec.byteCode;
50
+ }
51
+ if (strippedAppSpec.templateVariables) {
52
+ delete strippedAppSpec.templateVariables;
53
+ }
54
+ if (strippedAppSpec.scratchVariables) {
55
+ delete strippedAppSpec.scratchVariables;
56
+ }
57
+ }
58
+ return strippedAppSpec;
59
+ }
60
+ function* generate(app, options) {
61
+ const resolvedOptions = {
62
+ // Set defaults
63
+ preserveNames: false,
64
+ mode: 'full',
65
+ ...options,
66
+ };
67
+ const reduceAppSpec = shrinkAppSpec(app, resolvedOptions);
68
+ const ctx = generatorContext.createGeneratorContext(reduceAppSpec, resolvedOptions);
22
69
  yield `/* eslint-disable */`;
23
70
  yield `/**`;
24
71
  yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`;
25
72
  yield ` * DO NOT MODIFY IT BY HAND.`;
26
73
  yield ` * requires: @algorandfoundation/algokit-utils: ^7`;
27
74
  yield ` */`;
28
- yield* imports.imports();
75
+ yield* imports.imports(ctx);
29
76
  // Change the structs definition to sanitize property names according to the defined rules
30
77
  // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp
31
- app.structs = Object.fromEntries(Object.keys(app.structs).map((key) => [key, convertStructs(app.structs[key], ctx.sanitizer)]));
32
- yield* writer.inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(app), ' as unknown as Arc56Contract');
78
+ reduceAppSpec.structs = Object.fromEntries(Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]));
79
+ yield* writer.inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract');
33
80
  yield writer.NewLine;
34
81
  yield* utilityTypes.utilityTypes();
35
82
  yield writer.NewLine;
36
83
  yield* appTypes.appTypes(ctx);
37
- yield* deployTypes.deployTypes(ctx);
84
+ if (ctx.mode === 'full') {
85
+ yield* deployTypes.deployTypes(ctx);
86
+ }
38
87
  yield writer.NewLine;
39
88
  // Write a call factory
40
89
  yield* paramsFactory.paramsFactory(ctx);
41
90
  yield writer.NewLine;
42
- // Write a factory
43
- yield* appFactory.appFactory(ctx);
91
+ // Write a factory in full mode
92
+ if (ctx.mode === 'full') {
93
+ yield* appFactory.appFactory(ctx);
94
+ }
44
95
  // Write a client
45
96
  yield* appClient.appClient(ctx);
46
97
  yield* callComposerTypes.callComposerType(ctx);
@@ -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, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nexport function* generate(app: Arc56Contract, options: GeneratorOptions = { preserveNames: false }): DocumentParts {\n const ctx = createGeneratorContext(app, options)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports()\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n app.structs = Object.fromEntries(Object.keys(app.structs).map((key) => [key, convertStructs(app.structs[key], ctx.sanitizer)]))\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(app), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n yield* deployTypes(ctx)\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory\n yield* appFactory(ctx)\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":["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;AAEe,UAAE,QAAQ,CAAC,GAAkB,EAAE,OAAA,GAA4B,EAAE,aAAa,EAAE,KAAK,EAAE,EAAA;IAChG,MAAM,GAAG,GAAGA,uCAAsB,CAAC,GAAG,EAAE,OAAO,CAAC;AAChD,IAAA,MAAM,sBAAsB;AAC5B,IAAA,MAAM,KAAK;AACX,IAAA,MAAM,2FAA2F;AACjG,IAAA,MAAM,8BAA8B;AACpC,IAAA,MAAM,oDAAoD;AAC1D,IAAA,MAAM,KAAK;AAEX,IAAA,OAAOC,eAAO,EAAE;;;AAGhB,IAAA,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC/H,IAAA,OAAOC,aAAM,CAAC,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,8BAA8B,CAAC;AAC7G,IAAA,MAAMC,cAAO;AAEb,IAAA,OAAOC,yBAAY,EAAE;AACrB,IAAA,MAAMD,cAAO;AACb,IAAA,OAAOE,iBAAQ,CAAC,GAAG,CAAC;AACpB,IAAA,OAAOC,uBAAW,CAAC,GAAG,CAAC;AACvB,IAAA,MAAMH,cAAO;;AAGb,IAAA,OAAOI,2BAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAMJ,cAAO;;AAEb,IAAA,OAAOK,qBAAU,CAAC,GAAG,CAAC;;AAEtB,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/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,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,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