@algorandfoundation/algokit-client-generator 3.0.6 → 4.0.0-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.
- package/README.md +4 -2
- package/cli.js +1 -1
- package/cli.js.map +1 -1
- package/cli.mjs +1 -1
- package/cli.mjs.map +1 -1
- package/client/{call-factory.d.ts → app-client.d.ts} +1 -1
- package/client/app-client.js +288 -0
- package/client/app-client.js.map +1 -0
- package/client/app-client.mjs +286 -0
- package/client/app-client.mjs.map +1 -0
- package/client/{call-client.d.ts → app-factory.d.ts} +1 -1
- package/client/app-factory.js +238 -0
- package/client/app-factory.js.map +1 -0
- package/client/app-factory.mjs +236 -0
- package/client/app-factory.mjs.map +1 -0
- package/client/app-types.js +196 -98
- package/client/app-types.js.map +1 -1
- package/client/app-types.mjs +196 -79
- package/client/app-types.mjs.map +1 -1
- package/client/call-composer-types.js +23 -53
- package/client/call-composer-types.js.map +1 -1
- package/client/call-composer-types.mjs +23 -34
- package/client/call-composer-types.mjs.map +1 -1
- package/client/call-composer.js +43 -57
- package/client/call-composer.js.map +1 -1
- package/client/call-composer.mjs +45 -40
- package/client/call-composer.mjs.map +1 -1
- package/client/deploy-types.d.ts +8 -4
- package/client/deploy-types.js +52 -34
- package/client/deploy-types.js.map +1 -1
- package/client/deploy-types.mjs +53 -36
- package/client/deploy-types.mjs.map +1 -1
- package/client/generate.d.ts +2 -2
- package/client/generate.js +18 -6
- package/client/generate.js.map +1 -1
- package/client/generate.mjs +18 -6
- package/client/generate.mjs.map +1 -1
- package/client/generator-context.d.ts +4 -4
- package/client/generator-context.js +5 -24
- package/client/generator-context.js.map +1 -1
- package/client/generator-context.mjs +5 -5
- package/client/generator-context.mjs.map +1 -1
- package/client/helpers/get-call-config-summary.d.ts +8 -3
- package/client/helpers/get-call-config-summary.js +22 -20
- package/client/helpers/get-call-config-summary.js.map +1 -1
- package/client/helpers/get-call-config-summary.mjs +22 -20
- package/client/helpers/get-call-config-summary.mjs.map +1 -1
- package/client/helpers/get-equivalent-type.d.ts +6 -1
- package/client/helpers/get-equivalent-type.js +10 -6
- package/client/helpers/get-equivalent-type.js.map +1 -1
- package/client/helpers/get-equivalent-type.mjs +10 -6
- package/client/helpers/get-equivalent-type.mjs.map +1 -1
- package/client/imports.js +18 -24
- package/client/imports.js.map +1 -1
- package/client/imports.mjs +18 -24
- package/client/imports.mjs.map +1 -1
- package/client/params-factory.d.ts +3 -0
- package/client/params-factory.js +126 -0
- package/client/params-factory.js.map +1 -0
- package/client/params-factory.mjs +124 -0
- package/client/params-factory.mjs.map +1 -0
- package/client/utility-types.d.ts +0 -7
- package/client/utility-types.js +37 -50
- package/client/utility-types.js.map +1 -1
- package/client/utility-types.mjs +38 -50
- package/client/utility-types.mjs.map +1 -1
- package/output/writer.js +17 -3
- package/output/writer.js.map +1 -1
- package/output/writer.mjs +17 -3
- package/output/writer.mjs.map +1 -1
- package/package.json +4 -3
- package/schema/application.schema.json.js +2 -2
- package/schema/application.schema.json.mjs +2 -2
- package/schema/arc56.schema.json.js +787 -0
- package/schema/arc56.schema.json.js.map +1 -0
- package/schema/arc56.schema.json.mjs +780 -0
- package/schema/arc56.schema.json.mjs.map +1 -0
- package/schema/load.d.ts +3 -3
- package/schema/load.js +21 -7
- package/schema/load.js.map +1 -1
- package/schema/load.mjs +22 -8
- package/schema/load.mjs.map +1 -1
- package/client/call-client.js +0 -341
- package/client/call-client.js.map +0 -1
- package/client/call-client.mjs +0 -320
- package/client/call-client.mjs.map +0 -1
- package/client/call-factory.js +0 -142
- package/client/call-factory.js.map +0 -1
- package/client/call-factory.mjs +0 -121
- package/client/call-factory.mjs.map +0 -1
|
@@ -1,97 +1,67 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var writer = require('../output/writer.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* callComposerType(ctx) {
|
|
28
9
|
const { name, callConfig, app } = ctx;
|
|
29
10
|
yield `export type ${name}Composer<TReturns extends [...any[]] = []> = {`;
|
|
30
11
|
yield writer.IncIndent;
|
|
31
12
|
yield* callComposerTypeNoops(ctx);
|
|
32
|
-
yield* callComposerOperationMethodType(ctx, `
|
|
33
|
-
yield* callComposerOperationMethodType(ctx, `
|
|
34
|
-
yield* callComposerOperationMethodType(ctx, `
|
|
35
|
-
yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.contract.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
|
|
13
|
+
yield* callComposerOperationMethodType(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
|
|
14
|
+
yield* callComposerOperationMethodType(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
|
|
15
|
+
yield* callComposerOperationMethodType(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
|
|
36
16
|
yield* callComposerTypeClearState(ctx);
|
|
37
17
|
yield* writer.jsDoc({
|
|
38
18
|
description: 'Adds a transaction to the composer',
|
|
39
19
|
params: {
|
|
40
|
-
txn: '
|
|
41
|
-
|
|
42
|
-
' include a signer.',
|
|
20
|
+
txn: 'A transaction to add to the transaction group',
|
|
21
|
+
signer: 'The optional signer to use when signing this transaction.',
|
|
43
22
|
},
|
|
44
23
|
});
|
|
45
|
-
yield `addTransaction(txn:
|
|
24
|
+
yield `addTransaction(txn: Transaction, signer?: TransactionSigner): ${name}Composer<TReturns>`;
|
|
46
25
|
yield* writer.jsDoc({
|
|
47
26
|
description: 'Returns the underlying AtomicTransactionComposer instance',
|
|
48
27
|
});
|
|
49
|
-
yield `
|
|
28
|
+
yield `composer(): AlgoKitComposer`;
|
|
50
29
|
yield* writer.jsDoc({
|
|
51
30
|
description: 'Simulates the transaction group and returns the result',
|
|
52
31
|
});
|
|
53
|
-
yield `simulate(options?: SimulateOptions): Promise<${name}
|
|
32
|
+
yield `simulate(options?: SimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
|
|
54
33
|
yield* writer.jsDoc({
|
|
55
34
|
description: 'Executes the transaction group and returns the results',
|
|
56
35
|
});
|
|
57
|
-
yield `execute(
|
|
58
|
-
yield writer.DecIndentAndCloseBlock;
|
|
59
|
-
yield `export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>`;
|
|
60
|
-
yield `export type ${name}ComposerSimulateResult<TReturns extends [...any[]]> = {`;
|
|
61
|
-
yield writer.IncIndent;
|
|
62
|
-
yield `returns: TReturns`;
|
|
63
|
-
yield `methodResults: ABIResult[]`;
|
|
64
|
-
yield `simulateResponse: modelsv2.SimulateResponse`;
|
|
65
|
-
yield writer.DecIndentAndCloseBlock;
|
|
66
|
-
yield `export type ${name}ComposerResults<TReturns extends [...any[]]> = {`;
|
|
67
|
-
yield writer.IncIndent;
|
|
68
|
-
yield `returns: TReturns`;
|
|
69
|
-
yield `groupId: string`;
|
|
70
|
-
yield `txIds: string[]`;
|
|
71
|
-
yield `transactions: Transaction[]`;
|
|
36
|
+
yield `execute(params?: ExecuteParams): Promise<${name}ComposerResults<TReturns>>`;
|
|
72
37
|
yield writer.DecIndentAndCloseBlock;
|
|
38
|
+
yield `
|
|
39
|
+
export type ${name}ComposerResults<TReturns extends [...any[]]> = Expand<SendAtomicTransactionComposerResults & {
|
|
40
|
+
returns: TReturns
|
|
41
|
+
}>
|
|
42
|
+
`;
|
|
73
43
|
}
|
|
74
44
|
function* callComposerTypeClearState({ app, name }) {
|
|
75
45
|
yield* writer.jsDoc({
|
|
76
|
-
description: `Makes a clear_state call to an existing instance of the ${app.
|
|
46
|
+
description: `Makes a clear_state call to an existing instance of the ${app.name} smart contract.`,
|
|
77
47
|
params: {
|
|
78
48
|
args: `The arguments for the bare call`,
|
|
79
49
|
},
|
|
80
50
|
returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
|
|
81
51
|
});
|
|
82
|
-
yield `clearState(
|
|
52
|
+
yield `clearState(params?: AppClientBareCallParams): ${name}Composer<[...TReturns, undefined]>`;
|
|
83
53
|
yield writer.NewLine;
|
|
84
54
|
}
|
|
85
55
|
function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }) {
|
|
86
|
-
for (const method of app.
|
|
87
|
-
const methodSignature =
|
|
56
|
+
for (const method of app.methods) {
|
|
57
|
+
const methodSignature = new algosdk.ABIMethod(method).getSignature();
|
|
88
58
|
const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
|
|
89
59
|
const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
|
|
90
60
|
// Skip methods which don't support a no_op call config
|
|
91
61
|
if (!callConfig.callMethods.includes(methodSignature))
|
|
92
62
|
continue;
|
|
93
63
|
yield* writer.jsDoc({
|
|
94
|
-
description: `Calls the ${
|
|
64
|
+
description: `Calls the ${new algosdk.ABIMethod(method).getSignature()} ABI method.`,
|
|
95
65
|
abiDescription: method.desc,
|
|
96
66
|
params: {
|
|
97
67
|
args: `The arguments for the contract call`,
|
|
@@ -99,7 +69,7 @@ function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUnique
|
|
|
99
69
|
},
|
|
100
70
|
returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
|
|
101
71
|
});
|
|
102
|
-
yield `${methodName}(
|
|
72
|
+
yield `${methodName}(params?: CallParams<'${methodSignatureSafe}'>): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'> | undefined]>`;
|
|
103
73
|
yield writer.NewLine;
|
|
104
74
|
}
|
|
105
75
|
}
|
|
@@ -118,7 +88,7 @@ function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, na
|
|
|
118
88
|
},
|
|
119
89
|
returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
|
|
120
90
|
});
|
|
121
|
-
yield `bare(
|
|
91
|
+
yield `bare(params${onComplete?.isOptional !== false ? '?' : ''}: AppClientBareCallParams ${''}): ${name}Composer<[...TReturns, undefined]>`;
|
|
122
92
|
}
|
|
123
93
|
else {
|
|
124
94
|
const uniqueName = methodSignatureToUniqueName[methodSig];
|
|
@@ -131,7 +101,7 @@ function* callComposerOperationMethodType({ app, methodSignatureToUniqueName, na
|
|
|
131
101
|
returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`,
|
|
132
102
|
});
|
|
133
103
|
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
|
|
134
|
-
yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(
|
|
104
|
+
yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<'${methodSigSafe}'>${''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, MethodReturn<'${methodSigSafe}'> | undefined]>`;
|
|
135
105
|
}
|
|
136
106
|
}
|
|
137
107
|
yield writer.DecIndentAndCloseBlock;
|
|
@@ -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,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3F,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX,CAAA;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAA;I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AA,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(): AlgoKitComposer`\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: 'Executes the transaction group and returns the results',\n })\n yield `execute(params?: ExecuteParams): 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 methodSignature = new ABIMethod(method).getSignature()\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\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<'${methodSignatureSafe}'>): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'> | 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<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, MethodReturn<'${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,GAAG,EACH,yDAAyD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAClF,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX,CAAA;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAA;IAEtC,OAAOC,YAAK,CAAC;AACX,QAAA,WAAW,EAAE,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B,cAAA,EAAA,aAAa,CAAK,EAAA,EAAuD,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,gBAAA,CAAkB,CAAA;aAClF;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, `
|
|
12
|
-
yield* callComposerOperationMethodType(ctx, `
|
|
13
|
-
yield* callComposerOperationMethodType(ctx, `
|
|
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: '
|
|
20
|
-
|
|
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:
|
|
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 `
|
|
26
|
+
yield `composer(): AlgoKitComposer`;
|
|
29
27
|
yield* jsDoc({
|
|
30
28
|
description: 'Simulates the transaction group and returns the result',
|
|
31
29
|
});
|
|
32
|
-
yield `simulate(options?: SimulateOptions): Promise<${name}
|
|
30
|
+
yield `simulate(options?: SimulateOptions): Promise<${name}ComposerResults<TReturns> & { simulateResponse: SimulateResponse }>`;
|
|
33
31
|
yield* jsDoc({
|
|
34
32
|
description: 'Executes the transaction group and returns the results',
|
|
35
33
|
});
|
|
36
|
-
yield `execute(
|
|
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 `execute(params?: ExecuteParams): 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.
|
|
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(
|
|
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.
|
|
66
|
-
const methodSignature =
|
|
54
|
+
for (const method of app.methods) {
|
|
55
|
+
const methodSignature = new ABIMethod(method).getSignature();
|
|
67
56
|
const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
|
|
68
57
|
const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
|
|
69
58
|
// Skip methods which don't support a no_op call config
|
|
70
59
|
if (!callConfig.callMethods.includes(methodSignature))
|
|
71
60
|
continue;
|
|
72
61
|
yield* jsDoc({
|
|
73
|
-
description: `Calls the ${
|
|
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}(
|
|
70
|
+
yield `${methodName}(params?: CallParams<'${methodSignatureSafe}'>): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'> | 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(
|
|
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)}(
|
|
102
|
+
yield `${sanitizer.makeSafeMethodIdentifier(uniqueName)}(params${onComplete?.isOptional !== false ? '?' : ''}: CallParams<'${methodSigSafe}'>${''}${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, MethodReturn<'${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;AACzE,IAAA,MAAM,SAAS,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,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAA,eAAA,CAAiB,EAC3F,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX,CAAA;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAA;IAEtC,OAAO,KAAK,CAAC;AACX,QAAA,WAAW,EAAE,oCAAoC;AACjD,QAAA,MAAM,EAAE;AACN,YAAA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K,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,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(): AlgoKitComposer`\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: 'Executes the transaction group and returns the results',\n })\n yield `execute(params?: ExecuteParams): 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 methodSignature = new ABIMethod(method).getSignature()\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\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<'${methodSignatureSafe}'>): ${name}Composer<[...TReturns, MethodReturn<'${methodSignatureSafe}'> | 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<'${methodSigSafe}'>${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }): ${name}Composer<[...TReturns, MethodReturn<'${methodSigSafe}'> | undefined]>`\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;AACzE,IAAA,MAAM,SAAS,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,GAAG,EACH,yDAAyD,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAClF,UAAU,CAAC,eAAe,EAC1B,UAAU,CACX,CAAA;AAED,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAA;IAEtC,OAAO,KAAK,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,CAAC,CAAA;IACF,MAAM,CAAA,8DAAA,EAAiE,IAAI,CAAA,kBAAA,CAAoB,CAAA;I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A;aAClF;SACF;AACD,QAAA,MAAM,sBAAsB,CAAA;AAC5B,QAAA,MAAM,OAAO,CAAA;KACd;AACH;;;;"}
|
package/client/call-composer.js
CHANGED
|
@@ -1,77 +1,55 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var writer = require('../output/writer.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
|
|
10
|
+
yield `public newGroup(): ${name}Composer {`;
|
|
30
11
|
yield writer.IncIndent;
|
|
31
12
|
yield `const client = this`;
|
|
32
|
-
yield `const
|
|
33
|
-
yield `
|
|
34
|
-
yield `const resultMappers: Array<undefined | ((x: any) => any)> = []`;
|
|
13
|
+
yield `const composer = client.appClient.newGroup()`;
|
|
14
|
+
yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
|
|
35
15
|
yield `return {`;
|
|
36
16
|
yield writer.IncIndent;
|
|
37
17
|
yield* callComposerNoops(ctx);
|
|
38
|
-
|
|
18
|
+
// This is async and unless we bring back promiseChain (which is possible) it's not a nice
|
|
19
|
+
// experience to expose update method(s)
|
|
20
|
+
//yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)
|
|
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:
|
|
24
|
+
yield* callComposerClearState(ctx);
|
|
25
|
+
yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
|
|
44
26
|
yield writer.IncIndent;
|
|
45
|
-
yield '
|
|
46
|
-
' client.sender)))';
|
|
27
|
+
yield 'composer.addTransaction(txn, signer)';
|
|
47
28
|
yield 'return this';
|
|
48
29
|
yield writer.DecIndent;
|
|
49
30
|
yield '},';
|
|
50
|
-
yield `
|
|
31
|
+
yield `composer() {`;
|
|
51
32
|
yield writer.IncIndent;
|
|
52
|
-
yield '
|
|
53
|
-
yield 'return atc';
|
|
33
|
+
yield 'return composer';
|
|
54
34
|
yield writer.DecIndent;
|
|
55
35
|
yield '},';
|
|
56
36
|
yield `async simulate(options?: SimulateOptions) {`;
|
|
57
37
|
yield writer.IncIndent;
|
|
58
|
-
yield `await
|
|
59
|
-
yield `const result = await atc.simulate(client.algod, new modelsv2.SimulateRequest({ txnGroups: [], ...options }))`;
|
|
38
|
+
yield `const result = await composer.simulate(options)`;
|
|
60
39
|
yield `return {`;
|
|
61
40
|
yield writer.IncIndent;
|
|
62
41
|
yield `...result,`;
|
|
63
|
-
yield `returns: result.
|
|
42
|
+
yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
|
|
64
43
|
yield writer.DecIndentAndCloseBlock;
|
|
65
44
|
yield writer.DecIndent;
|
|
66
45
|
yield '},';
|
|
67
|
-
yield `async execute(
|
|
46
|
+
yield `async execute(params?: ExecuteParams) {`;
|
|
68
47
|
yield writer.IncIndent;
|
|
69
|
-
yield `await
|
|
70
|
-
yield `const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod)`;
|
|
48
|
+
yield `const result = await composer.execute(params)`;
|
|
71
49
|
yield `return {`;
|
|
72
50
|
yield writer.IncIndent;
|
|
73
51
|
yield `...result,`;
|
|
74
|
-
yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val
|
|
52
|
+
yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`;
|
|
75
53
|
yield writer.DecIndentAndCloseBlock;
|
|
76
54
|
yield writer.DecIndentAndCloseBlock;
|
|
77
55
|
yield writer.DecIndent;
|
|
@@ -79,34 +57,44 @@ function* composeMethod(ctx) {
|
|
|
79
57
|
yield writer.DecIndentAndCloseBlock;
|
|
80
58
|
}
|
|
81
59
|
function* callComposerNoops({ app, callConfig, methodSignatureToUniqueName, sanitizer }) {
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
if (callConfig.callMethods.includes(getCallConfigSummary.BARE_CALL)) {
|
|
61
|
+
yield* writer.jsDoc(`Add a bare method call to the ${app.name} contract`);
|
|
62
|
+
yield `bare(params: AppClientBareCallParams & ${deployTypes.getCallOnCompleteOptions(getCallConfigSummary.BARE_CALL, app).type}) {`;
|
|
63
|
+
yield writer.IncIndent;
|
|
64
|
+
yield `composer.addAppCall(client.params.bare(params))`;
|
|
65
|
+
yield `return this`;
|
|
66
|
+
yield writer.DecIndent;
|
|
67
|
+
yield '},';
|
|
68
|
+
}
|
|
69
|
+
for (const methodSignature of callConfig.callMethods.filter((m) => m !== getCallConfigSummary.BARE_CALL).map((m) => m)) {
|
|
84
70
|
const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]);
|
|
85
71
|
const methodSignatureSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature);
|
|
86
72
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
87
73
|
// Skip methods which don't support a no_op call config
|
|
88
74
|
if (!callConfig.callMethods.includes(methodSignature))
|
|
89
75
|
continue;
|
|
90
|
-
yield
|
|
76
|
+
yield* writer.jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`);
|
|
77
|
+
yield `${methodName}(params: CallParams<'${methodSignatureSafe}'> & ${deployTypes.getCallOnCompleteOptions(methodSignature, app).type}) {`;
|
|
91
78
|
yield writer.IncIndent;
|
|
92
|
-
yield `
|
|
93
|
-
const outputTypeName = app.
|
|
94
|
-
yield `resultMappers.push(${outputTypeName
|
|
79
|
+
yield `composer.addAppCallMethodCall(client.params${methodNameAccessor}(params))`;
|
|
80
|
+
const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSignature)?.returns.type;
|
|
81
|
+
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSignatureSafe}', v)` : 'undefined'})`;
|
|
95
82
|
yield `return this`;
|
|
96
83
|
yield writer.DecIndent;
|
|
97
84
|
yield '},';
|
|
98
85
|
}
|
|
99
86
|
}
|
|
100
|
-
function* callComposerClearState() {
|
|
101
|
-
yield `
|
|
87
|
+
function* callComposerClearState({ app }) {
|
|
88
|
+
yield* writer.jsDoc(`Add a clear state call to the ${app.name} contract`);
|
|
89
|
+
yield `clearState(params: AppClientBareCallParams) {`;
|
|
102
90
|
yield writer.IncIndent;
|
|
103
|
-
yield `
|
|
104
|
-
yield `resultMappers.push(undefined)`;
|
|
91
|
+
yield `composer.addAppCall(client.params.clearState(params))`;
|
|
105
92
|
yield `return this`;
|
|
106
93
|
yield writer.DecIndent;
|
|
107
94
|
yield '},';
|
|
108
95
|
}
|
|
109
96
|
function* callComposerOperationMethods({ app, methodSignatureToUniqueName, sanitizer }, methods, verb, includeCompilation) {
|
|
97
|
+
const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
|
|
110
98
|
if (methods.length) {
|
|
111
99
|
yield `get ${verb}() {`;
|
|
112
100
|
yield writer.IncIndent;
|
|
@@ -114,12 +102,10 @@ function* callComposerOperationMethods({ app, methodSignatureToUniqueName, sanit
|
|
|
114
102
|
yield `return {`;
|
|
115
103
|
yield writer.IncIndent;
|
|
116
104
|
for (const methodSig of methods) {
|
|
117
|
-
const onComplete = verb === 'create' ? deployTypes.getCreateOnCompleteOptions(methodSig, app) : undefined;
|
|
118
105
|
if (methodSig === getCallConfigSummary.BARE_CALL) {
|
|
119
|
-
yield `bare(
|
|
106
|
+
yield `bare(params?: AppClientBareCallParams ${''}) {`;
|
|
120
107
|
yield writer.IncIndent;
|
|
121
|
-
yield `
|
|
122
|
-
yield `resultMappers.push(undefined)`;
|
|
108
|
+
yield `composer.addApp${callType}(client.params.${verb}.bare(params))`;
|
|
123
109
|
yield `return $this`;
|
|
124
110
|
yield writer.DecIndent;
|
|
125
111
|
yield '},';
|
|
@@ -129,11 +115,11 @@ function* callComposerOperationMethods({ app, methodSignatureToUniqueName, sanit
|
|
|
129
115
|
const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
|
|
130
116
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
131
117
|
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
|
|
132
|
-
yield `${methodName}(
|
|
118
|
+
yield `${methodName}(params: CallParams<'${methodSigSafe}'>${''}) {`;
|
|
133
119
|
yield writer.IncIndent;
|
|
134
|
-
yield `
|
|
135
|
-
const outputTypeName = app.
|
|
136
|
-
yield `resultMappers.push(${outputTypeName
|
|
120
|
+
yield `composer.addApp${callType}MethodCall(client.params.${verb}${methodNameAccessor}(params))`;
|
|
121
|
+
const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig)?.returns.type;
|
|
122
|
+
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
|
|
137
123
|
yield `return $this`;
|
|
138
124
|
yield writer.DecIndent;
|
|
139
125
|
yield '},';
|