@algorandfoundation/algokit-client-generator 3.0.6 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +4 -2
  2. package/cli.d.ts +6 -0
  3. package/cli.js +47 -16
  4. package/cli.js.map +1 -1
  5. package/cli.mjs +47 -17
  6. package/cli.mjs.map +1 -1
  7. package/client/{call-factory.d.ts → app-client.d.ts} +1 -1
  8. package/client/app-client.js +345 -0
  9. package/client/app-client.js.map +1 -0
  10. package/client/app-client.mjs +343 -0
  11. package/client/app-client.mjs.map +1 -0
  12. package/client/{call-client.d.ts → app-factory.d.ts} +1 -1
  13. package/client/app-factory.js +252 -0
  14. package/client/app-factory.js.map +1 -0
  15. package/client/app-factory.mjs +250 -0
  16. package/client/app-factory.mjs.map +1 -0
  17. package/client/app-types.js +206 -112
  18. package/client/app-types.js.map +1 -1
  19. package/client/app-types.mjs +210 -97
  20. package/client/app-types.mjs.map +1 -1
  21. package/client/call-composer-types.js +27 -57
  22. package/client/call-composer-types.js.map +1 -1
  23. package/client/call-composer-types.mjs +27 -38
  24. package/client/call-composer-types.mjs.map +1 -1
  25. package/client/call-composer.js +47 -59
  26. package/client/call-composer.js.map +1 -1
  27. package/client/call-composer.mjs +49 -42
  28. package/client/call-composer.mjs.map +1 -1
  29. package/client/deploy-types.d.ts +8 -4
  30. package/client/deploy-types.js +52 -34
  31. package/client/deploy-types.js.map +1 -1
  32. package/client/deploy-types.mjs +53 -36
  33. package/client/deploy-types.mjs.map +1 -1
  34. package/client/generate.d.ts +2 -2
  35. package/client/generate.js +18 -7
  36. package/client/generate.js.map +1 -1
  37. package/client/generate.mjs +18 -7
  38. package/client/generate.mjs.map +1 -1
  39. package/client/generator-context.d.ts +4 -4
  40. package/client/generator-context.js +5 -24
  41. package/client/generator-context.js.map +1 -1
  42. package/client/generator-context.mjs +5 -5
  43. package/client/generator-context.mjs.map +1 -1
  44. package/client/helpers/get-call-config-summary.d.ts +8 -3
  45. package/client/helpers/get-call-config-summary.js +22 -20
  46. package/client/helpers/get-call-config-summary.js.map +1 -1
  47. package/client/helpers/get-call-config-summary.mjs +22 -20
  48. package/client/helpers/get-call-config-summary.mjs.map +1 -1
  49. package/client/helpers/get-equivalent-type.d.ts +6 -1
  50. package/client/helpers/get-equivalent-type.js +20 -10
  51. package/client/helpers/get-equivalent-type.js.map +1 -1
  52. package/client/helpers/get-equivalent-type.mjs +20 -10
  53. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  54. package/client/imports.js +21 -24
  55. package/client/imports.js.map +1 -1
  56. package/client/imports.mjs +21 -24
  57. package/client/imports.mjs.map +1 -1
  58. package/client/params-factory.d.ts +3 -0
  59. package/client/params-factory.js +126 -0
  60. package/client/params-factory.js.map +1 -0
  61. package/client/params-factory.mjs +124 -0
  62. package/client/params-factory.mjs.map +1 -0
  63. package/client/utility-types.d.ts +0 -7
  64. package/client/utility-types.js +37 -50
  65. package/client/utility-types.js.map +1 -1
  66. package/client/utility-types.mjs +38 -50
  67. package/client/utility-types.mjs.map +1 -1
  68. package/output/writer.d.ts +5 -5
  69. package/output/writer.js +26 -6
  70. package/output/writer.js.map +1 -1
  71. package/output/writer.mjs +26 -6
  72. package/output/writer.mjs.map +1 -1
  73. package/package.json +7 -5
  74. package/schema/application.schema.json.js +2 -2
  75. package/schema/application.schema.json.mjs +2 -2
  76. package/schema/arc56.schema.json.js +751 -0
  77. package/schema/arc56.schema.json.js.map +1 -0
  78. package/schema/arc56.schema.json.mjs +741 -0
  79. package/schema/arc56.schema.json.mjs.map +1 -0
  80. package/schema/load.d.ts +3 -3
  81. package/schema/load.js +28 -8
  82. package/schema/load.js.map +1 -1
  83. package/schema/load.mjs +29 -9
  84. package/schema/load.mjs.map +1 -1
  85. package/util/sanitization.js +13 -8
  86. package/util/sanitization.js.map +1 -1
  87. package/util/sanitization.mjs +13 -8
  88. package/util/sanitization.mjs.map +1 -1
  89. package/client/call-client.js +0 -341
  90. package/client/call-client.js.map +0 -1
  91. package/client/call-client.mjs +0 -320
  92. package/client/call-client.mjs.map +0 -1
  93. package/client/call-factory.js +0 -142
  94. package/client/call-factory.js.map +0 -1
  95. package/client/call-factory.mjs +0 -121
  96. package/client/call-factory.mjs.map +0 -1
@@ -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'\nimport * as algokit from '@algorandfoundation/algokit-utils'\n\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\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 `Updates an existing instance of the ${app.contract.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.contract.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.contract.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.contract.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: 'One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by one of algokit utils helpers (signer is obtained from the defaultSender parameter)',\n defaultSender:\n 'The default sender to be used to obtain a signer where the object provided to the transaction parameter does not' +\n ' include a signer.',\n },\n })\n yield `addTransaction(txn: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom): ${name}Composer<TReturns>`\n\n yield* jsDoc({\n description: 'Returns the underlying AtomicTransactionComposer instance',\n })\n yield `atc(): Promise<AtomicTransactionComposer>`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(options?: SimulateOptions): Promise<${name}ComposerSimulateResult<TReturns>>`\n\n yield* jsDoc({\n description: 'Executes the transaction group and returns the results',\n })\n yield `execute(sendParams?: AppClientComposeExecuteParams): Promise<${name}ComposerResults<TReturns>>`\n\n yield DecIndentAndCloseBlock\n yield `export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>`\n\n yield `export type ${name}ComposerSimulateResult<TReturns extends [...any[]]> = {`\n yield IncIndent\n yield `returns: TReturns`\n yield `methodResults: ABIResult[]`\n yield `simulateResponse: modelsv2.SimulateResponse`\n yield DecIndentAndCloseBlock\n\n yield `export type ${name}ComposerResults<TReturns extends [...any[]]> = {`\n yield IncIndent\n yield `returns: TReturns`\n yield `groupId: string`\n yield `txIds: string[]`\n yield `transactions: Transaction[]`\n yield DecIndentAndCloseBlock\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.contract.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(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, undefined]>`\n yield NewLine\n}\n\nfunction* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.contract.methods) {\n const methodSignature = algokit.getABIMethodSignature(method)\n const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc({\n description: `Calls the ${algokit.getABIMethodSignature(method)} 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}(args: MethodArgs<'${methodSignatureSafe}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'>]>`\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(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${\n includeCompilation ? '& AppClientCompilationParams ' : ''\n }& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${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)}(args: MethodArgs<'${methodSigSafe}'>, params${\n onComplete?.isOptional !== false ? '?' : ''\n }: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, MethodReturn<'${methodSigSafe}'>]>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":["IncIndent","jsDoc","DecIndentAndCloseBlock","NewLine","algokit","getCreateOnCompleteOptions","BARE_CALL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOe,UAAE,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACrC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD,CAAA;AACzE,IAAA,MAAMA,gBAAS,CAAA;AAEf,IAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACjC,OAAO,+BAA+B,CACpC,GAAG,EACH,CAAA,oCAAA,EAAuC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAiB,eAAA,CAAA,EACzE,UAAU,CAAC,aAAa,EACxB,QAAQ,EACR,IAAI,CACL,CAAA;IACD,OAAO,+BAA+B,CACpC,GAAG,EACH,CAAA,oCAAA,EAAuC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAA,eAAA,CAAiB,EACzE,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT,CAAA;IACD,OAAO,+BAA+B,CACpC,GAAG,EACH,CAAA,+CAAA,EAAkD,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAA,eAAA,CAAiB,EACpF,UAAU,CAAC,YAAY,EACvB,OAAO,CACR,CAAA;IACD,OAAO,+BAA+B,CACpC,GAAG,EACH,CAAA,sDAAA,EAAyD,GAA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C3D,kBAAkB,GAAG,+BAA+B,GAAG,EACzD,oBAAoB,UAAU,EAAE,IAAI,GAAG,CAAM,GAAA,EAAA,UAAU,CAAC,IAAI,CAAA,CAAE,GAAG,EAAE,CAAM,GAAA,EAAA,IAAI,oCAAoC,CAAA;aAClH;iBAAM;AACL,gBAAA,MAAM,UAAU,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAA;gBACzD,OAAOA,YAAK,CAAC;AACX,oBAAA,WAAW,EAAE,CAAA,EAAG,WAAW,CAAA,WAAA,EAAc,SAAS,CAAc,YAAA,CAAA;AAChE,oBAAA,MAAM,EAAE;AACN,wBAAA,IAAI,EAAE,CAA2C,yCAAA,CAAA;AACjD,wBAAA,MAAM,EAAE,CAAwC,sCAAA,CAAA;AACjD,qBAAA;AACD,oBAAA,OAAO,EAAE,CAA+H,6HAAA,CAAA;AACzI,iBAAA,CAAC,CAAA;gBACF,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAA;gBACpE,MAAM,CAAA,EAAG,SAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA,mBAAA,EAAsB,aAAa,CAAA,UAAA,EACxF,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,GAAG,GAAG,EAC3C,CAAmC,gCAAA,EAAA,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,EAC1F,UAAU,EAAE,IAAI,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,IAAI,CAAE,CAAA,GAAG,EAC/C,CAAA,GAAA,EAAM,IAAI,CAAA,qCAAA,EAAwC,aAAa,CAAA,IAAA,CAAM,CAAA;aACtE;SACF;AACD,QAAA,MAAMC,6BAAsB,CAAA;AAC5B,QAAA,MAAMC,cAAO,CAAA;KACd;AACH;;;;"}
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\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(): TransactionComposer`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(options?: SimulateOptions): 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,CAAA;IACrC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD,CAAA;AACzE,IAAA,MAAMA,gBAAS,CAAA;AAEf,IAAA,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAA;AACjC,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,uCAAuC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAChE,UAAU,CAAC,aAAa,EACxB,QAAQ,CACT,CAAA;AACD,IAAA,OAAO,+BAA+B,CACpC,GAAG,EACH,kDAAkD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3E,UAAU,CAAC,YAAY,EACvB,OAAO,CACR,CAAA;AACD,IAAA,OAAO,+BAA+B,CACpC,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A;AACD,oBAAA,OAAO,EAAE,CAA+H,6HAAA,CAAA;AACzI,iBAAA,CAAC,CAAA;gBACF,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAA;AACpE,gBAAA,MAAM,CAAG,EAAA,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,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,CAAA;aACpF;SACF;AACD,QAAA,MAAMC,6BAAsB,CAAA;AAC5B,QAAA,MAAMC,cAAO,CAAA;KACd;AACH;;;;"}
@@ -1,76 +1,65 @@
1
1
  import { IncIndent, jsDoc, DecIndentAndCloseBlock, NewLine } from '../output/writer.mjs';
2
- import * as algokit from '@algorandfoundation/algokit-utils';
3
2
  import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
4
3
  import { getCreateOnCompleteOptions } from './deploy-types.mjs';
4
+ import { ABIMethod } from 'algosdk';
5
5
 
6
6
  function* callComposerType(ctx) {
7
7
  const { name, callConfig, app } = ctx;
8
8
  yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
9
9
  yield IncIndent;
10
10
  yield* callComposerTypeNoops(ctx);
11
- yield* callComposerOperationMethodType(ctx, `Updates an existing instance of the ${app.contract.name} smart contract`, callConfig.updateMethods, 'update', true);
12
- yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.contract.name} smart contract`, callConfig.deleteMethods, 'delete');
13
- yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.contract.name} smart contract`, callConfig.optInMethods, 'optIn');
14
- yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.contract.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
11
+ yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
12
+ yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
13
+ yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
15
14
  yield* callComposerTypeClearState(ctx);
16
15
  yield* jsDoc({
17
16
  description: 'Adds a transaction to the composer',
18
17
  params: {
19
- txn: 'One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by one of algokit utils helpers (signer is obtained from the defaultSender parameter)',
20
- defaultSender: 'The default sender to be used to obtain a signer where the object provided to the transaction parameter does not' +
21
- ' include a signer.',
18
+ txn: 'A transaction to add to the transaction group',
19
+ signer: 'The optional signer to use when signing this transaction.',
22
20
  },
23
21
  });
24
- yield `addTransaction(txn: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom): ${name}Composer<TReturns>`;
22
+ yield `addTransaction(txn: Transaction, signer?: TransactionSigner): ${name}Composer<TReturns>`;
25
23
  yield* jsDoc({
26
24
  description: 'Returns the underlying AtomicTransactionComposer instance',
27
25
  });
28
- yield `atc(): Promise<AtomicTransactionComposer>`;
26
+ yield `composer(): TransactionComposer`;
29
27
  yield* jsDoc({
30
28
  description: 'Simulates the transaction group and returns the result',
31
29
  });
32
- yield `simulate(options?: SimulateOptions): Promise<${name}ComposerSimulateResult<TReturns>>`;
30
+ yield `simulate(options?: SimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
33
31
  yield* jsDoc({
34
- description: 'Executes the transaction group and returns the results',
32
+ description: 'Sends the transaction group to the network and returns the results',
35
33
  });
36
- yield `execute(sendParams?: AppClientComposeExecuteParams): Promise<${name}ComposerResults<TReturns>>`;
37
- yield DecIndentAndCloseBlock;
38
- yield `export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>`;
39
- yield `export type ${name}ComposerSimulateResult<TReturns extends [...any[]]> = {`;
40
- yield IncIndent;
41
- yield `returns: TReturns`;
42
- yield `methodResults: ABIResult[]`;
43
- yield `simulateResponse: modelsv2.SimulateResponse`;
44
- yield DecIndentAndCloseBlock;
45
- yield `export type ${name}ComposerResults<TReturns extends [...any[]]> = {`;
46
- yield IncIndent;
47
- yield `returns: TReturns`;
48
- yield `groupId: string`;
49
- yield `txIds: string[]`;
50
- yield `transactions: Transaction[]`;
34
+ yield `send(params?: SendParams): Promise<${name}ComposerResults<TReturns>>`;
51
35
  yield DecIndentAndCloseBlock;
36
+ yield `
37
+ export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendAtomicTransactionComposerResults & {
38
+ returns: TReturns
39
+ }>
40
+ `;
52
41
  }
53
42
  function* callComposerTypeClearState({ app, name }) {
54
43
  yield* jsDoc({
55
- description: `Makes a clear_state call to an existing instance of the ${app.contract.name} smart contract.`,
44
+ description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,
56
45
  params: {
57
46
  args: `The arguments for the bare call`,
58
47
  },
59
48
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
60
49
  });
61
- yield `clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, undefined]>`;
50
+ yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`;
62
51
  yield NewLine;
63
52
  }
64
53
  function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
65
- for (const method of app.contract.methods) {
66
- const methodSignature = algokit.getABIMethodSignature(method);
67
- const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
68
- const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
54
+ for (const method of app.methods) {
55
+ const methodSig = new ABIMethod(method).getSignature();
56
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
57
+ const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSig]);
69
58
  // Skip methods which don't support a no_op call config
70
- if (!callConfig.callMethods.includes(methodSignature))
59
+ if (!callConfig.callMethods.includes(methodSig))
71
60
  continue;
72
61
  yield* jsDoc({
73
- description: `Calls the ${algokit.getABIMethodSignature(method)} ABI method.`,
62
+ description: `Calls the ${new ABIMethod(method).getSignature()} ABI method.`,
74
63
  abiDescription: method.desc,
75
64
  params: {
76
65
  args: `The arguments for the contract call`,
@@ -78,7 +67,7 @@ function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUnique
78
67
  },
79
68
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
80
69
  });
81
- yield `${methodName}(args: MethodArgs<'${methodSignatureSafe}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'>]>`;
70
+ yield `${methodName}(params?: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
82
71
  yield NewLine;
83
72
  }
84
73
  }
@@ -97,7 +86,7 @@ function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, na
97
86
  },
98
87
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
99
88
  });
100
- yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, undefined]>`;
89
+ yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<[...TReturns, undefined]>`;
101
90
  }
102
91
  else {
103
92
  const uniqueName = methodSignatureToUniqueName[methodSig];
@@ -110,7 +99,7 @@ function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, na
110
99
  returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
111
100
  });
112
101
  const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
113
- yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(args: MethodArgs<'${methodSigSafe}'>, params${onComplete?.isOptional !== false ? '?' : ''}: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, MethodReturn<'${methodSigSafe}'>]>`;
102
+ yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, ${name}Returns['${methodSigSafe}'] | undefined]>`;
114
103
  }
115
104
  }
116
105
  yield DecIndentAndCloseBlock;
@@ -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'\nimport * as algokit from '@algorandfoundation/algokit-utils'\n\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\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 `Updates an existing instance of the ${app.contract.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* callComposerOperationMethodType(\n ctx,\n `Deletes an existing instance of the ${app.contract.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.contract.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.contract.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: 'One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by one of algokit utils helpers (signer is obtained from the defaultSender parameter)',\n defaultSender:\n 'The default sender to be used to obtain a signer where the object provided to the transaction parameter does not' +\n ' include a signer.',\n },\n })\n yield `addTransaction(txn: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom): ${name}Composer<TReturns>`\n\n yield* jsDoc({\n description: 'Returns the underlying AtomicTransactionComposer instance',\n })\n yield `atc(): Promise<AtomicTransactionComposer>`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(options?: SimulateOptions): Promise<${name}ComposerSimulateResult<TReturns>>`\n\n yield* jsDoc({\n description: 'Executes the transaction group and returns the results',\n })\n yield `execute(sendParams?: AppClientComposeExecuteParams): Promise<${name}ComposerResults<TReturns>>`\n\n yield DecIndentAndCloseBlock\n yield `export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>`\n\n yield `export type ${name}ComposerSimulateResult<TReturns extends [...any[]]> = {`\n yield IncIndent\n yield `returns: TReturns`\n yield `methodResults: ABIResult[]`\n yield `simulateResponse: modelsv2.SimulateResponse`\n yield DecIndentAndCloseBlock\n\n yield `export type ${name}ComposerResults<TReturns extends [...any[]]> = {`\n yield IncIndent\n yield `returns: TReturns`\n yield `groupId: string`\n yield `txIds: string[]`\n yield `transactions: Transaction[]`\n yield DecIndentAndCloseBlock\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.contract.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(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, undefined]>`\n yield NewLine\n}\n\nfunction* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.contract.methods) {\n const methodSignature = algokit.getABIMethodSignature(method)\n const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc({\n description: `Calls the ${algokit.getABIMethodSignature(method)} 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}(args: MethodArgs<'${methodSignatureSafe}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'>]>`\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(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${\n includeCompilation ? '& AppClientCompilationParams ' : ''\n }& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${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)}(args: MethodArgs<'${methodSigSafe}'>, params${\n onComplete?.isOptional !== false ? '?' : ''\n }: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, MethodReturn<'${methodSigSafe}'>]>`\n }\n }\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n"],"names":[],"mappings":";;;;;AAOe,UAAE,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACrC,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,8CAAA,CAAgD,CAAA;AAC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AG,SAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA,mBAAA,EAAsB,aAAa,CAAA,UAAA,EACxF,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,GAAG,GAAG,EAC3C,CAAmC,gCAAA,EAAA,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,EAC1F,UAAU,EAAE,IAAI,GAAG,CAAA,GAAA,EAAM,UAAU,CAAC,IAAI,CAAE,CAAA,GAAG,EAC/C,CAAA,GAAA,EAAM,IAAI,CAAA,qCAAA,EAAwC,aAAa,CAAA,IAAA,CAAM,CAAA;aACtE;SACF;AACD,QAAA,MAAM,sBAAsB,CAAA;AAC5B,QAAA,MAAM,OAAO,CAAA;KACd;AACH;;;;"}
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\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(): TransactionComposer`\n\n yield* jsDoc({\n description: 'Simulates the transaction group and returns the result',\n })\n yield `simulate(options?: SimulateOptions): 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":[],"mappings":";;;;;AAOe,UAAE,gBAAgB,CAAC,GAAqB,EAAA;IACrD,MAAM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.js');
4
- var algokit = require('@algorandfoundation/algokit-utils');
5
4
  var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
6
5
  var deployTypes = require('./deploy-types.js');
7
-
8
- function _interopNamespaceDefault(e) {
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var algokit__namespace = /*#__PURE__*/_interopNamespaceDefault(algokit);
6
+ var algosdk = require('algosdk');
26
7
 
27
8
  function* composeMethod(ctx) {
28
9
  const { name, callConfig } = ctx;
29
- yield `public compose(): ${name}Composer {`;
10
+ // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid
11
+ yield `public newGroup(): ${name}Composer {`;
30
12
  yield writer.IncIndent;
31
13
  yield `const client = this`;
32
- yield `const atc = new AtomicTransactionComposer()`;
14
+ yield `const composer = this.algorand.newGroup()`;
33
15
  yield `let promiseChain:Promise<unknown> = Promise.resolve()`;
34
- yield `const resultMappers: Array<undefined | ((x: any) => any)> = []`;
16
+ yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
35
17
  yield `return {`;
36
18
  yield writer.IncIndent;
37
19
  yield* callComposerNoops(ctx);
@@ -39,88 +21,94 @@ function* composeMethod(ctx) {
39
21
  yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete');
40
22
  yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn');
41
23
  yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut');
42
- yield* callComposerClearState();
43
- yield `addTransaction(txn: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom) {`;
24
+ yield* callComposerClearState(ctx);
25
+ yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
44
26
  yield writer.IncIndent;
45
- yield 'promiseChain = promiseChain.then(async () => atc.addTransaction(await algokit.getTransactionWithSigner(txn, defaultSender ??' +
46
- ' client.sender)))';
27
+ yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))';
47
28
  yield 'return this';
48
29
  yield writer.DecIndent;
49
30
  yield '},';
50
- yield `async atc() {`;
31
+ yield `async composer() {`;
51
32
  yield writer.IncIndent;
52
- yield 'await promiseChain';
53
- yield 'return atc';
33
+ yield `await promiseChain`;
34
+ yield 'return composer';
54
35
  yield writer.DecIndent;
55
36
  yield '},';
56
37
  yield `async simulate(options?: SimulateOptions) {`;
57
38
  yield writer.IncIndent;
58
39
  yield `await promiseChain`;
59
- yield `const result = await atc.simulate(client.algod, new modelsv2.SimulateRequest({ txnGroups: [], ...options }))`;
40
+ yield `const result = await composer.simulate(options)`;
60
41
  yield `return {`;
61
42
  yield writer.IncIndent;
62
43
  yield `...result,`;
63
- yield `returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue)`;
44
+ yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
64
45
  yield writer.DecIndentAndCloseBlock;
65
46
  yield writer.DecIndent;
66
47
  yield '},';
67
- yield `async execute(sendParams?: AppClientComposeExecuteParams) {`;
48
+ yield `async send(params?: SendParams) {`;
68
49
  yield writer.IncIndent;
69
50
  yield `await promiseChain`;
70
- yield `const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod)`;
51
+ yield `const result = await composer.send(params)`;
71
52
  yield `return {`;
72
53
  yield writer.IncIndent;
73
54
  yield `...result,`;
74
- yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue)`;
55
+ yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
75
56
  yield writer.DecIndentAndCloseBlock;
76
57
  yield writer.DecIndentAndCloseBlock;
77
58
  yield writer.DecIndent;
78
59
  yield `} as unknown as ${name}Composer`;
79
60
  yield writer.DecIndentAndCloseBlock;
80
61
  }
81
- function* callComposerNoops({ app, callConfig, methodSignatureToUniqueName, sanitizer }) {
82
- for (const method of app.contract.methods) {
83
- const methodSignature = algokit__namespace.getABIMethodSignature(method);
62
+ function* callComposerNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
63
+ if (callConfig.callMethods.includes(getCallConfigSummary.BARE_CALL)) {
64
+ yield* writer.jsDoc(`Add a bare method call to the ${app.name} contract`);
65
+ yield `bare(params: AppClientBareCallParams & ${deployTypes.getCallOnCompleteOptions(getCallConfigSummary.BARE_CALL, app).type}) {`;
66
+ yield writer.IncIndent;
67
+ yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`;
68
+ yield `return this`;
69
+ yield writer.DecIndent;
70
+ yield '},';
71
+ }
72
+ for (const methodSignature of callConfig.callMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).map((m) => m)) {
84
73
  const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
85
- const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
74
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
86
75
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
87
76
  // Skip methods which don't support a no_op call config
88
77
  if (!callConfig.callMethods.includes(methodSignature))
89
78
  continue;
90
- yield `${methodName}(args: MethodArgs<'${methodSignatureSafe}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) {`;
79
+ yield* writer.jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`);
80
+ yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${deployTypes.getCallOnCompleteOptions(methodSignature, app).type}) {`;
91
81
  yield writer.IncIndent;
92
- yield `promiseChain = promiseChain.then(() => client${methodNameAccessor}(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}}))`;
93
- const outputTypeName = app.hints?.[methodSignature]?.structs?.output?.name;
94
- yield `resultMappers.push(${outputTypeName ?? 'undefined'})`;
82
+ yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`;
83
+ const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSignature)?.returns.type;
84
+ yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
95
85
  yield `return this`;
96
86
  yield writer.DecIndent;
97
87
  yield '},';
98
88
  }
99
89
  }
100
- function* callComposerClearState() {
101
- yield `clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) {`;
90
+ function* callComposerClearState({ app }) {
91
+ yield* writer.jsDoc(`Add a clear state call to the ${app.name} contract`);
92
+ yield `clearState(params: AppClientBareCallParams) {`;
102
93
  yield writer.IncIndent;
103
- yield `promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}}))`;
104
- yield `resultMappers.push(undefined)`;
94
+ yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`;
105
95
  yield `return this`;
106
96
  yield writer.DecIndent;
107
97
  yield '},';
108
98
  }
109
- function* callComposerOperationMethods({ app, methodSignatureToUniqueName, sanitizer }, methods, verb, includeCompilation) {
99
+ function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName, sanitizer }, methods, verb, includeCompilation) {
100
+ const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
110
101
  if (methods.length) {
111
102
  yield `get ${verb}() {`;
112
103
  yield writer.IncIndent;
113
- yield `const $this = this`;
114
104
  yield `return {`;
115
105
  yield writer.IncIndent;
116
106
  for (const methodSig of methods) {
117
- const onComplete = verb === 'create' ? deployTypes.getCreateOnCompleteOptions(methodSig, app) : undefined;
118
107
  if (methodSig === getCallConfigSummary.BARE_CALL) {
119
- yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}) {`;
108
+ yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`;
120
109
  yield writer.IncIndent;
121
- yield `promiseChain = promiseChain.then(() => client.${verb}.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}}))`;
122
- yield `resultMappers.push(undefined)`;
123
- yield `return $this`;
110
+ yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`;
111
+ yield `return this`;
124
112
  yield writer.DecIndent;
125
113
  yield '},';
126
114
  }
@@ -129,12 +117,12 @@ function* callComposerOperationMethods({ app, methodSignatureToUniqueName, sanit
129
117
  const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
130
118
  const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
131
119
  const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
132
- yield `${methodName}(args: MethodArgs<'${methodSigSafe}'>, params${onComplete?.isOptional !== false ? '?' : ''}: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}) {`;
120
+ yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`;
133
121
  yield writer.IncIndent;
134
- yield `promiseChain = promiseChain.then(() => client.${verb}${methodNameAccessor}(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}}))`;
135
- const outputTypeName = app.hints?.[methodSig]?.structs?.output?.name;
136
- yield `resultMappers.push(${outputTypeName ?? 'undefined'})`;
137
- yield `return $this`;
122
+ yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`;
123
+ const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig)?.returns.type;
124
+ yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
125
+ yield `return this`;
138
126
  yield writer.DecIndent;
139
127
  yield '},';
140
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"call-composer.js","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport * as algokit from '@algorandfoundation/algokit-utils'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = ctx\n yield `public compose(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const atc = new AtomicTransactionComposer()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: any) => 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()\n\n yield `addTransaction(txn: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(async () => atc.addTransaction(await algokit.getTransactionWithSigner(txn, defaultSender ??' +\n ' client.sender)))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async atc() {`\n yield IncIndent\n yield 'await promiseChain'\n yield 'return atc'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await atc.simulate(client.algod, new modelsv2.SimulateRequest({ txnGroups: [], ...options }))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async execute(sendParams?: AppClientComposeExecuteParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : 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, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n for (const method of app.contract.methods) {\n const methodSignature = algokit.getABIMethodSignature(method)\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSignatureSafe = 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\n yield `${methodName}(args: MethodArgs<'${methodSignatureSafe}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => client${methodNameAccessor}(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}}))`\n const outputTypeName = app.hints?.[methodSignature]?.structs?.output?.name\n yield `resultMappers.push(${outputTypeName ?? 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState(): DocumentParts {\n yield `clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}}))`\n yield `resultMappers.push(undefined)`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { app, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `const $this = this`\n yield `return {`\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 `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${\n includeCompilation ? '& AppClientCompilationParams ' : ''\n }& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => client.${verb}.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}}))`\n yield `resultMappers.push(undefined)`\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}(args: MethodArgs<'${methodSigSafe}'>, params${\n onComplete?.isOptional !== false ? '?' : ''\n }: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => client.${verb}${methodNameAccessor}(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}}))`\n const outputTypeName = app.hints?.[methodSig]?.structs?.output?.name\n yield `resultMappers.push(${outputTypeName ?? '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","algokit","getCreateOnCompleteOptions","BARE_CALL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMe,UAAE,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;IAChC,MAAM,CAAA,kBAAA,EAAqB,IAAI,CAAA,UAAA,CAAY,CAAA;AAC3C,IAAA,MAAMA,gBAAS,CAAA;AAEf,IAAA,MAAM,qBAAqB,CAAA;AAC3B,IAAA,MAAM,6CAA6C,CAAA;AACnD,IAAA,MAAM,uDAAuD,CAAA;AAC7D,IAAA,MAAM,gEAAgE,CAAA;AACtE,IAAA,MAAM,UAAU,CAAA;AAChB,IAAA,MAAMA,gBAAS,CAAA;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAA;AAC7B,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAClF,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;AAC5E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;AAC1E,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;AAChF,IAAA,OAAO,sBAAsB,EAAE,CAAA;AAE/B,IAAA,MAAM,sJAAs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AM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAA;gBACpE,MAAM,CAAA,EAAG,UAAU,CAAsB,mBAAA,EAAA,aAAa,aACpD,UAAU,EAAE,UAAU,KAAK,KAAK,GAAG,GAAG,GAAG,EAC3C,CAAA,gCAAA,EAAmC,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,GAC1F,UAAU,EAAE,IAAI,GAAG,CAAM,GAAA,EAAA,UAAU,CAAC,IAAI,CAAA,CAAE,GAAG,EAC/C,CAAA,GAAA,CAAK,CAAA;AACL,gBAAA,MAAMD,gBAAS,CAAA;AACf,gBAAA,MAAM,CAAiD,8CAAA,EAAA,IAAI,CAAG,EAAA,kBAAkB,mFAAmF,CAAA;AACnK,gBAAA,MAAM,cAAc,GAAG,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAA;AACpE,gBAAA,MAAM,CAAsB,mBAAA,EAAA,cAAc,IAAI,WAAW,GAAG,CAAA;AAC5D,gBAAA,MAAM,cAAc,CAAA;AACpB,gBAAA,MAAMC,gBAAS,CAAA;AACf,gBAAA,MAAM,IAAI,CAAA;aACX;SACF;AACD,QAAA,MAAMC,6BAAsB,CAAA;AAC5B,QAAA,MAAMD,gBAAS,CAAA;AACf,QAAA,MAAM,IAAI,CAAA;KACX;AACH;;;;"}
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 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,CAAA;;IAEhC,MAAM,CAAA,mBAAA,EAAsB,IAAI,CAAA,UAAA,CAAY,CAAA;AAC5C,IAAA,MAAMA,gBAAS,CAAA;AAEf,IAAA,MAAM,qBAAqB,CAAA;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