@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/app-client-context.d.ts +122 -0
- package/client/app-client-context.js +212 -0
- package/client/app-client-context.js.map +1 -0
- package/client/app-client-context.mjs +209 -0
- package/client/app-client-context.mjs.map +1 -0
- package/client/app-client.js +29 -51
- package/client/app-client.js.map +1 -1
- package/client/app-client.mjs +29 -51
- package/client/app-client.mjs.map +1 -1
- package/client/app-factory.js +23 -27
- package/client/app-factory.js.map +1 -1
- package/client/app-factory.mjs +23 -27
- package/client/app-factory.mjs.map +1 -1
- package/client/app-types.js +31 -60
- package/client/app-types.js.map +1 -1
- package/client/app-types.mjs +32 -61
- package/client/app-types.mjs.map +1 -1
- package/client/call-composer-types.js +31 -34
- package/client/call-composer-types.js.map +1 -1
- package/client/call-composer-types.mjs +31 -34
- package/client/call-composer-types.mjs.map +1 -1
- package/client/call-composer.js +24 -31
- package/client/call-composer.js.map +1 -1
- package/client/call-composer.mjs +24 -31
- package/client/call-composer.mjs.map +1 -1
- package/client/deploy-types.d.ts +1 -11
- package/client/deploy-types.js +28 -53
- package/client/deploy-types.js.map +1 -1
- package/client/deploy-types.mjs +29 -52
- package/client/deploy-types.mjs.map +1 -1
- package/client/generate.d.ts +1 -1
- package/client/generate.js +2 -2
- package/client/generate.js.map +1 -1
- package/client/generate.mjs +2 -2
- package/client/generate.mjs.map +1 -1
- package/client/generator-context.d.ts +3 -5
- package/client/generator-context.js +4 -10
- package/client/generator-context.js.map +1 -1
- package/client/generator-context.mjs +4 -10
- package/client/generator-context.mjs.map +1 -1
- package/client/helpers/contains-non-void-method.d.ts +2 -2
- package/client/helpers/contains-non-void-method.js +3 -2
- package/client/helpers/contains-non-void-method.js.map +1 -1
- package/client/helpers/contains-non-void-method.mjs +3 -2
- package/client/helpers/contains-non-void-method.mjs.map +1 -1
- package/client/helpers/get-equivalent-type.d.ts +3 -5
- package/client/helpers/get-equivalent-type.js +53 -54
- package/client/helpers/get-equivalent-type.js.map +1 -1
- package/client/helpers/get-equivalent-type.mjs +53 -55
- package/client/helpers/get-equivalent-type.mjs.map +1 -1
- package/client/imports.d.ts +1 -2
- package/client/imports.js +10 -19
- package/client/imports.js.map +1 -1
- package/client/imports.mjs +10 -19
- package/client/imports.mjs.map +1 -1
- package/client/params-factory.js +47 -50
- package/client/params-factory.js.map +1 -1
- package/client/params-factory.mjs +47 -50
- package/client/params-factory.mjs.map +1 -1
- package/package.json +2 -3
- package/schema/load.d.ts +1 -1
- package/schema/load.js.map +1 -1
- package/schema/load.mjs.map +1 -1
- package/client/helpers/get-call-config-summary.d.ts +0 -19
- package/client/helpers/get-call-config-summary.js +0 -60
- package/client/helpers/get-call-config-summary.js.map +0 -1
- package/client/helpers/get-call-config-summary.mjs +0 -57
- package/client/helpers/get-call-config-summary.mjs.map +0 -1
package/client/call-composer.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var writer = require('../output/writer.js');
|
|
4
|
-
var
|
|
5
|
-
var deployTypes = require('./deploy-types.js');
|
|
6
|
-
var algosdk = require('algosdk');
|
|
4
|
+
var appClientContext = require('./app-client-context.js');
|
|
7
5
|
|
|
8
6
|
function* composeMethod(ctx) {
|
|
9
|
-
const { name,
|
|
7
|
+
const { name, app } = ctx;
|
|
10
8
|
// todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid
|
|
11
|
-
yield `public newGroup(): ${name}Composer {`;
|
|
9
|
+
yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`;
|
|
12
10
|
yield writer.IncIndent;
|
|
13
11
|
yield `const client = this`;
|
|
14
|
-
yield `const composer = this.algorand.newGroup()`;
|
|
12
|
+
yield `const composer = this.algorand.newGroup(composerConfig)`;
|
|
15
13
|
yield `let promiseChain:Promise<unknown> = Promise.resolve()`;
|
|
16
|
-
yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
|
|
17
14
|
yield `return {`;
|
|
18
15
|
yield writer.IncIndent;
|
|
19
16
|
yield* callComposerNoops(ctx);
|
|
20
17
|
if (ctx.mode === 'full') {
|
|
21
|
-
yield* callComposerOperationMethods(ctx,
|
|
22
|
-
yield* callComposerOperationMethods(ctx,
|
|
18
|
+
yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true);
|
|
19
|
+
yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete');
|
|
23
20
|
}
|
|
24
|
-
yield* callComposerOperationMethods(ctx,
|
|
25
|
-
yield* callComposerOperationMethods(ctx,
|
|
21
|
+
yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn');
|
|
22
|
+
yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut');
|
|
26
23
|
yield* callComposerClearState(ctx);
|
|
27
24
|
yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
|
|
28
25
|
yield writer.IncIndent;
|
|
@@ -43,7 +40,7 @@ function* composeMethod(ctx) {
|
|
|
43
40
|
yield `return {`;
|
|
44
41
|
yield writer.IncIndent;
|
|
45
42
|
yield `...result,`;
|
|
46
|
-
yield `returns: result.returns?.map(
|
|
43
|
+
yield `returns: result.returns?.map(val => val.returnValue)`;
|
|
47
44
|
yield writer.DecIndentAndCloseBlock;
|
|
48
45
|
yield writer.DecIndent;
|
|
49
46
|
yield '},';
|
|
@@ -54,36 +51,34 @@ function* composeMethod(ctx) {
|
|
|
54
51
|
yield `return {`;
|
|
55
52
|
yield writer.IncIndent;
|
|
56
53
|
yield `...result,`;
|
|
57
|
-
yield `returns: result.returns?.map(
|
|
54
|
+
yield `returns: result.returns?.map(val => val.returnValue)`;
|
|
58
55
|
yield writer.DecIndentAndCloseBlock;
|
|
59
56
|
yield writer.DecIndentAndCloseBlock;
|
|
60
57
|
yield writer.DecIndent;
|
|
61
58
|
yield `} as unknown as ${name}Composer`;
|
|
62
59
|
yield writer.DecIndentAndCloseBlock;
|
|
63
60
|
}
|
|
64
|
-
function* callComposerNoops({ app, name,
|
|
65
|
-
if (
|
|
61
|
+
function* callComposerNoops({ app, name, sanitizer }) {
|
|
62
|
+
if (app.bareMethod.callActions.noOp) {
|
|
66
63
|
yield* writer.jsDoc(`Add a bare method call to the ${app.name} contract`);
|
|
67
|
-
yield `bare(params: AppClientBareCallParams & ${
|
|
64
|
+
yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`;
|
|
68
65
|
yield writer.IncIndent;
|
|
69
66
|
yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`;
|
|
70
67
|
yield `return this`;
|
|
71
68
|
yield writer.DecIndent;
|
|
72
69
|
yield '},';
|
|
73
70
|
}
|
|
74
|
-
for (const
|
|
75
|
-
const methodName =
|
|
76
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(
|
|
71
|
+
for (const method of app.abiMethods) {
|
|
72
|
+
const methodName = method.uniqueName.makeSafeMethodIdentifier;
|
|
73
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
77
74
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
78
75
|
// Skip methods which don't support a no_op call config
|
|
79
|
-
if (!
|
|
76
|
+
if (!method.callActions.noOp)
|
|
80
77
|
continue;
|
|
81
|
-
yield* writer.jsDoc(`Add a ${
|
|
82
|
-
yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${
|
|
78
|
+
yield* writer.jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`);
|
|
79
|
+
yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`;
|
|
83
80
|
yield writer.IncIndent;
|
|
84
81
|
yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`;
|
|
85
|
-
const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSignature)?.returns.type;
|
|
86
|
-
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
|
|
87
82
|
yield `return this`;
|
|
88
83
|
yield writer.DecIndent;
|
|
89
84
|
yield '},';
|
|
@@ -98,15 +93,15 @@ function* callComposerClearState({ app }) {
|
|
|
98
93
|
yield writer.DecIndent;
|
|
99
94
|
yield '},';
|
|
100
95
|
}
|
|
101
|
-
function* callComposerOperationMethods({
|
|
96
|
+
function* callComposerOperationMethods({ name, sanitizer }, methods, verb, includeCompilation) {
|
|
102
97
|
const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
|
|
103
98
|
if (methods.length) {
|
|
104
99
|
yield `get ${verb}() {`;
|
|
105
100
|
yield writer.IncIndent;
|
|
106
101
|
yield `return {`;
|
|
107
102
|
yield writer.IncIndent;
|
|
108
|
-
for (const
|
|
109
|
-
if (
|
|
103
|
+
for (const method of methods) {
|
|
104
|
+
if (!appClientContext.isAbiMethod(method)) {
|
|
110
105
|
yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`;
|
|
111
106
|
yield writer.IncIndent;
|
|
112
107
|
yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`;
|
|
@@ -115,15 +110,13 @@ function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName,
|
|
|
115
110
|
yield '},';
|
|
116
111
|
}
|
|
117
112
|
else {
|
|
118
|
-
const uniqueName =
|
|
113
|
+
const uniqueName = method.uniqueName.original;
|
|
119
114
|
const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
|
|
120
115
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
121
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(
|
|
116
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
122
117
|
yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`;
|
|
123
118
|
yield writer.IncIndent;
|
|
124
119
|
yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`;
|
|
125
|
-
const outputTypeName = app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig)?.returns.type;
|
|
126
|
-
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
|
|
127
120
|
yield `return this`;
|
|
128
121
|
yield writer.DecIndent;
|
|
129
122
|
yield '},';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-composer.js","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = ctx\n // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid\n yield `public newGroup(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut')\n yield* callComposerClearState(ctx)\n\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async composer() {`\n yield IncIndent\n yield `await promiseChain`\n yield 'return composer'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await (!options ? composer.simulate() : composer.simulate(options))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async send(params?: SendParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await composer.send(params)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `} as unknown as ${name}Composer`\n\n yield DecIndentAndCloseBlock\n}\n\nfunction* callComposerNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n\n for (const methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc(`Add a clear state call to the ${app.name} contract`)\n yield `clearState(params: AppClientBareCallParams) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\n verb: 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call'\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) {\n yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":["IncIndent","DecIndent","DecIndentAndCloseBlock","BARE_CALL","jsDoc","getCallOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAMM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG;;IAEhC,MAAM,CAAA,mBAAA,EAAsB,IAAI,CAAA,UAAA,CAAY;AAC5C,IAAA,MAAMA,gBAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,2CAA2C;AACjD,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,kFAAkF;AACxF,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;AAC7B,IAAA,IAAI,GAAG,CAAC,IAAI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CAAC,IAAI,CAAC,CAAC,CAAkB,KAAK,IAAIM,iBAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;AAC5H,gBAAA,MAAM,sBAAsB,cAAc,IAAI,cAAc,KAAK,MAAM,GAAG,CAAA,iCAAA,EAAoC,aAAa,CAAA,KAAA,CAAO,GAAG,WAAW,GAAG;AACnJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAML,gBAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAMC,6BAAsB;AAC5B,QAAA,MAAMD,gBAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"call-composer.js","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { AppClientMethodContext, isAbiMethod } from './app-client-context'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, app } = ctx\n // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid\n yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup(composerConfig)`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut')\n yield* callComposerClearState(ctx)\n\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async composer() {`\n yield IncIndent\n yield `await promiseChain`\n yield 'return composer'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await (!options ? composer.simulate() : composer.simulate(options))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async send(params?: SendParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await composer.send(params)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `} as unknown as ${name}Composer`\n\n yield DecIndentAndCloseBlock\n}\n\nfunction* callComposerNoops({ app, name, sanitizer }: GeneratorContext): DocumentParts {\n if (app.bareMethod.callActions.noOp) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n\n for (const method of app.abiMethods) {\n const methodName = method.uniqueName.makeSafeMethodIdentifier\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!method.callActions.noOp) continue\n yield* jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc(`Add a clear state call to the ${app.name} contract`)\n yield `clearState(params: AppClientBareCallParams) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { name, sanitizer }: GeneratorContext,\n methods: AppClientMethodContext[],\n verb: 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call'\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const method of methods) {\n if (!isAbiMethod(method)) {\n yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n } else {\n const uniqueName = method.uniqueName.original\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":["IncIndent","DecIndent","DecIndentAndCloseBlock","jsDoc","isAbiMethod"],"mappings":";;;;;AAIM,UAAW,aAAa,CAAC,GAAqB,EAAA;A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AM,IAAI;IACZ;AACF;;;;"}
|
package/client/call-composer.mjs
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { IncIndent, DecIndent, DecIndentAndCloseBlock, jsDoc } from '../output/writer.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import { getCallOnCompleteOptions } from './deploy-types.mjs';
|
|
4
|
-
import { ABIMethod } from 'algosdk';
|
|
2
|
+
import { isAbiMethod } from './app-client-context.mjs';
|
|
5
3
|
|
|
6
4
|
function* composeMethod(ctx) {
|
|
7
|
-
const { name,
|
|
5
|
+
const { name, app } = ctx;
|
|
8
6
|
// todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid
|
|
9
|
-
yield `public newGroup(): ${name}Composer {`;
|
|
7
|
+
yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`;
|
|
10
8
|
yield IncIndent;
|
|
11
9
|
yield `const client = this`;
|
|
12
|
-
yield `const composer = this.algorand.newGroup()`;
|
|
10
|
+
yield `const composer = this.algorand.newGroup(composerConfig)`;
|
|
13
11
|
yield `let promiseChain:Promise<unknown> = Promise.resolve()`;
|
|
14
|
-
yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`;
|
|
15
12
|
yield `return {`;
|
|
16
13
|
yield IncIndent;
|
|
17
14
|
yield* callComposerNoops(ctx);
|
|
18
15
|
if (ctx.mode === 'full') {
|
|
19
|
-
yield* callComposerOperationMethods(ctx,
|
|
20
|
-
yield* callComposerOperationMethods(ctx,
|
|
16
|
+
yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true);
|
|
17
|
+
yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete');
|
|
21
18
|
}
|
|
22
|
-
yield* callComposerOperationMethods(ctx,
|
|
23
|
-
yield* callComposerOperationMethods(ctx,
|
|
19
|
+
yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn');
|
|
20
|
+
yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut');
|
|
24
21
|
yield* callComposerClearState(ctx);
|
|
25
22
|
yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`;
|
|
26
23
|
yield IncIndent;
|
|
@@ -41,7 +38,7 @@ function* composeMethod(ctx) {
|
|
|
41
38
|
yield `return {`;
|
|
42
39
|
yield IncIndent;
|
|
43
40
|
yield `...result,`;
|
|
44
|
-
yield `returns: result.returns?.map(
|
|
41
|
+
yield `returns: result.returns?.map(val => val.returnValue)`;
|
|
45
42
|
yield DecIndentAndCloseBlock;
|
|
46
43
|
yield DecIndent;
|
|
47
44
|
yield '},';
|
|
@@ -52,36 +49,34 @@ function* composeMethod(ctx) {
|
|
|
52
49
|
yield `return {`;
|
|
53
50
|
yield IncIndent;
|
|
54
51
|
yield `...result,`;
|
|
55
|
-
yield `returns: result.returns?.map(
|
|
52
|
+
yield `returns: result.returns?.map(val => val.returnValue)`;
|
|
56
53
|
yield DecIndentAndCloseBlock;
|
|
57
54
|
yield DecIndentAndCloseBlock;
|
|
58
55
|
yield DecIndent;
|
|
59
56
|
yield `} as unknown as ${name}Composer`;
|
|
60
57
|
yield DecIndentAndCloseBlock;
|
|
61
58
|
}
|
|
62
|
-
function* callComposerNoops({ app, name,
|
|
63
|
-
if (
|
|
59
|
+
function* callComposerNoops({ app, name, sanitizer }) {
|
|
60
|
+
if (app.bareMethod.callActions.noOp) {
|
|
64
61
|
yield* jsDoc(`Add a bare method call to the ${app.name} contract`);
|
|
65
|
-
yield `bare(params: AppClientBareCallParams & ${
|
|
62
|
+
yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`;
|
|
66
63
|
yield IncIndent;
|
|
67
64
|
yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`;
|
|
68
65
|
yield `return this`;
|
|
69
66
|
yield DecIndent;
|
|
70
67
|
yield '},';
|
|
71
68
|
}
|
|
72
|
-
for (const
|
|
73
|
-
const methodName =
|
|
74
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(
|
|
69
|
+
for (const method of app.abiMethods) {
|
|
70
|
+
const methodName = method.uniqueName.makeSafeMethodIdentifier;
|
|
71
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
75
72
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
76
73
|
// Skip methods which don't support a no_op call config
|
|
77
|
-
if (!
|
|
74
|
+
if (!method.callActions.noOp)
|
|
78
75
|
continue;
|
|
79
|
-
yield* jsDoc(`Add a ${
|
|
80
|
-
yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${
|
|
76
|
+
yield* jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`);
|
|
77
|
+
yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`;
|
|
81
78
|
yield IncIndent;
|
|
82
79
|
yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`;
|
|
83
|
-
const outputTypeName = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type;
|
|
84
|
-
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
|
|
85
80
|
yield `return this`;
|
|
86
81
|
yield DecIndent;
|
|
87
82
|
yield '},';
|
|
@@ -96,15 +91,15 @@ function* callComposerClearState({ app }) {
|
|
|
96
91
|
yield DecIndent;
|
|
97
92
|
yield '},';
|
|
98
93
|
}
|
|
99
|
-
function* callComposerOperationMethods({
|
|
94
|
+
function* callComposerOperationMethods({ name, sanitizer }, methods, verb, includeCompilation) {
|
|
100
95
|
const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call';
|
|
101
96
|
if (methods.length) {
|
|
102
97
|
yield `get ${verb}() {`;
|
|
103
98
|
yield IncIndent;
|
|
104
99
|
yield `return {`;
|
|
105
100
|
yield IncIndent;
|
|
106
|
-
for (const
|
|
107
|
-
if (
|
|
101
|
+
for (const method of methods) {
|
|
102
|
+
if (!isAbiMethod(method)) {
|
|
108
103
|
yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`;
|
|
109
104
|
yield IncIndent;
|
|
110
105
|
yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`;
|
|
@@ -113,15 +108,13 @@ function* callComposerOperationMethods({ app, name, methodSignatureToUniqueName,
|
|
|
113
108
|
yield '},';
|
|
114
109
|
}
|
|
115
110
|
else {
|
|
116
|
-
const uniqueName =
|
|
111
|
+
const uniqueName = method.uniqueName.original;
|
|
117
112
|
const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
|
|
118
113
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
119
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(
|
|
114
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
120
115
|
yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`;
|
|
121
116
|
yield IncIndent;
|
|
122
117
|
yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`;
|
|
123
|
-
const outputTypeName = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)?.returns.type;
|
|
124
|
-
yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`;
|
|
125
118
|
yield `return this`;
|
|
126
119
|
yield DecIndent;
|
|
127
120
|
yield '},';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-composer.mjs","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCallOnCompleteOptions } from './deploy-types'\nimport { ABIMethod, ABIMethodParams } from 'algosdk'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, callConfig } = ctx\n // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid\n yield `public newGroup(): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup()`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, callConfig.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, callConfig.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, callConfig.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, callConfig.closeOutMethods, 'closeOut')\n yield* callComposerClearState(ctx)\n\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async composer() {`\n yield IncIndent\n yield `await promiseChain`\n yield 'return composer'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await (!options ? composer.simulate() : composer.simulate(options))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async send(params?: SendParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await composer.send(params)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `} as unknown as ${name}Composer`\n\n yield DecIndentAndCloseBlock\n}\n\nfunction* callComposerNoops({ app, name, callConfig, methodSignatureToUniqueName, sanitizer }: GeneratorContext): DocumentParts {\n if (callConfig.callMethods.includes(BARE_CALL)) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${getCallOnCompleteOptions(BARE_CALL, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n\n for (const methodSignature of callConfig.callMethods.filter((m) => m !== BARE_CALL).map((m) => m as string)) {\n const methodName = sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature])\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSignature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n yield* jsDoc(`Add a ${methodSignature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${getCallOnCompleteOptions(methodSignature, app).type}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSignature)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc(`Add a clear state call to the ${app.name} contract`)\n yield `clearState(params: AppClientBareCallParams) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { app, name, methodSignatureToUniqueName, sanitizer }: GeneratorContext,\n methods: MethodList,\n verb: 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call'\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) {\n yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n } else {\n const uniqueName = methodSignatureToUniqueName[methodSig]\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`\n const outputTypeName = app.methods.find((m: ABIMethodParams) => new ABIMethod(m).getSignature() === methodSig)?.returns.type\n yield `resultMappers.push(${outputTypeName && outputTypeName !== 'void' ? `(v) => client.decodeReturnValue('${methodSigSafe}', v)` : 'undefined'})`\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B,GAAG,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACtE,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC;gBACpE,MAAM,CAAA,EAAG,UAAU,CAAA,sBAAA,EAAyB,IAAI,gBAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,MAAM,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,MAAA,CAAQ;AAC/L,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,+DAA+D,QAAQ,CAAA,+BAAA,EAAkC,IAAI,CAAA,EAAG,kBAAkB,YAAY;AACpJ,gBAAA,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAkB,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;AAC5H,gBAAA,MAAM,sBAAsB,cAAc,IAAI,cAAc,KAAK,MAAM,GAAG,CAAA,iCAAA,EAAoC,aAAa,CAAA,KAAA,CAAO,GAAG,WAAW,GAAG;AACnJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,SAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"call-composer.mjs","sources":["../../src/client/call-composer.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { AppClientMethodContext, isAbiMethod } from './app-client-context'\n\nexport function* composeMethod(ctx: GeneratorContext): DocumentParts {\n const { name, app } = ctx\n // todo: Patrick feedback - allow common params to be passed in here so they propagate to all params calls e.g. firstValid\n yield `public newGroup(composerConfig?: TransactionComposerConfig): ${name}Composer {`\n yield IncIndent\n\n yield `const client = this`\n yield `const composer = this.algorand.newGroup(composerConfig)`\n yield `let promiseChain:Promise<unknown> = Promise.resolve()`\n yield `return {`\n yield IncIndent\n\n yield* callComposerNoops(ctx)\n if (ctx.mode === 'full') {\n yield* callComposerOperationMethods(ctx, app.updateMethods, 'update', true)\n yield* callComposerOperationMethods(ctx, app.deleteMethods, 'delete')\n }\n yield* callComposerOperationMethods(ctx, app.optInMethods, 'optIn')\n yield* callComposerOperationMethods(ctx, app.closeOutMethods, 'closeOut')\n yield* callComposerClearState(ctx)\n\n yield `addTransaction(txn: Transaction, signer?: TransactionSigner) {`\n yield IncIndent\n yield 'promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))'\n yield 'return this'\n yield DecIndent\n yield '},'\n\n yield `async composer() {`\n yield IncIndent\n yield `await promiseChain`\n yield 'return composer'\n yield DecIndent\n yield '},'\n\n yield `async simulate(options?: SimulateOptions) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await (!options ? composer.simulate() : composer.simulate(options))`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n\n yield `async send(params?: SendParams) {`\n yield IncIndent\n yield `await promiseChain`\n yield `const result = await composer.send(params)`\n yield `return {`\n yield IncIndent\n yield `...result,`\n yield `returns: result.returns?.map(val => val.returnValue)`\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield `} as unknown as ${name}Composer`\n\n yield DecIndentAndCloseBlock\n}\n\nfunction* callComposerNoops({ app, name, sanitizer }: GeneratorContext): DocumentParts {\n if (app.bareMethod.callActions.noOp) {\n yield* jsDoc(`Add a bare method call to the ${app.name} contract`)\n yield `bare(params: AppClientBareCallParams & ${app.bareMethod.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n\n for (const method of app.abiMethods) {\n const methodName = method.uniqueName.makeSafeMethodIdentifier\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n // Skip methods which don't support a no_op call config\n if (!method.callActions.noOp) continue\n yield* jsDoc(`Add a ${method.signature} method call against the ${app.name} contract`)\n yield `${methodName}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & ${method.callActions.inputType.typeLiteral}) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n}\n\nfunction* callComposerClearState({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc(`Add a clear state call to the ${app.name} contract`)\n yield `clearState(params: AppClientBareCallParams) {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n}\n\nfunction* callComposerOperationMethods(\n { name, sanitizer }: GeneratorContext,\n methods: AppClientMethodContext[],\n verb: 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const callType = verb === 'update' ? 'Update' : verb === 'delete' ? 'Delete' : 'Call'\n if (methods.length) {\n yield `get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n for (const method of methods) {\n if (!isAbiMethod(method)) {\n yield `bare: (params?: AppClientBareCallParams ${includeCompilation ? '& AppClientCompilationParams ' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(${verb === 'update' ? 'async ' : ''}() => composer.addApp${callType}(${verb === 'update' ? 'await ' : ''}client.params.${verb}.bare(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n } else {\n const uniqueName = method.uniqueName.original\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n yield `${methodName}: (params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' & AppClientCompilationParams' : ''}) => {`\n yield IncIndent\n yield `promiseChain = promiseChain.then(async () => composer.addApp${callType}MethodCall(await client.params.${verb}${methodNameAccessor}(params)))`\n yield `return this`\n yield DecIndent\n yield '},'\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndent\n yield '},'\n }\n}\n"],"names":[],"mappings":";;;AAIM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG;;IAEzB,MAAM,CAAA,6DAAA,EAAgE,IAAI,CAAA,UAAA,CAAY;AACtF,IAAA,MAAM,SAAS;AAEf,IAAA,MAAM,qBAAqB;AAC3B,IAAA,MAAM,yDAAyD;AAC/D,IAAA,MAAM,uDAAuD;AAC7D,IAAA,MAAM,UAAU;AAChB,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC;AAC7B,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;AAC3E,QAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC;IACvE;AACA,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC;AACnE,IAAA,OAAO,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,eAAe,EAAE,UAAU,CAAC;AACzE,IAAA,OAAO,sBAAsB,CAAC,GAAG,CAAC;AAElC,IAAA,MAAM,gEAAgE;AACtE,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,8E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B,aAAa,MAAM,kBAAkB,GAAG,+BAA+B,GAAG,EAAE,CAAA,MAAA,CAAQ;AAC/L,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,+DAA+D,QAAQ,CAAA,+BAAA,EAAkC,IAAI,CAAA,EAAG,kBAAkB,YAAY;AACpJ,gBAAA,MAAM,aAAa;AACnB,gBAAA,MAAM,SAAS;AACf,gBAAA,MAAM,IAAI;YACZ;QACF;AACA,QAAA,MAAM,sBAAsB;AAC5B,QAAA,MAAM,SAAS;AACf,QAAA,MAAM,IAAI;IACZ;AACF;;;;"}
|
package/client/deploy-types.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { DocumentParts } from '../output/writer';
|
|
2
|
-
import { MethodIdentifier } from './helpers/get-call-config-summary';
|
|
3
2
|
import { GeneratorContext } from './generator-context';
|
|
4
|
-
|
|
5
|
-
export declare function getCreateOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract): {
|
|
6
|
-
type: {};
|
|
7
|
-
isOptional: boolean | undefined;
|
|
8
|
-
};
|
|
9
|
-
export declare function getCallOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract): {
|
|
10
|
-
type: {};
|
|
11
|
-
isOptional: boolean | undefined;
|
|
12
|
-
};
|
|
13
|
-
export declare function deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }: GeneratorContext): DocumentParts;
|
|
3
|
+
export declare function deployTypes({ app, sanitizer }: GeneratorContext): DocumentParts;
|
package/client/deploy-types.js
CHANGED
|
@@ -1,66 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var writer = require('../output/writer.js');
|
|
4
|
-
var
|
|
5
|
-
var algosdk = require('algosdk');
|
|
4
|
+
var appClientContext = require('./app-client-context.js');
|
|
6
5
|
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const onCompleteType = validCreateOnCompletes
|
|
11
|
-
? `{onComplete${hasNoOp ? '?' : ''}: ${validCreateOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`
|
|
12
|
-
: {};
|
|
13
|
-
return {
|
|
14
|
-
type: onCompleteType,
|
|
15
|
-
isOptional: hasNoOp,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function getCallOnCompleteOptions(method, app) {
|
|
19
|
-
const validCallOnCompletes = method === getCallConfigSummary.BARE_CALL ? app.bareActions.call : app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === method)?.actions?.call;
|
|
20
|
-
const hasNoOp = validCallOnCompletes?.includes('NoOp');
|
|
21
|
-
const onCompleteType = validCallOnCompletes
|
|
22
|
-
? `{onComplete${hasNoOp ? '?' : ''}: ${validCallOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`
|
|
23
|
-
: {};
|
|
24
|
-
return {
|
|
25
|
-
type: onCompleteType,
|
|
26
|
-
isOptional: hasNoOp,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }) {
|
|
30
|
-
const name = sanitizer.makeSafeTypeIdentifier(app.name);
|
|
31
|
-
if (callConfig.createMethods.length > 0) {
|
|
6
|
+
function* deployTypes({ app, sanitizer }) {
|
|
7
|
+
const name = app.name.makeSafeTypeIdentifier;
|
|
8
|
+
if (app.createMethods.length) {
|
|
32
9
|
yield* writer.jsDoc('Defines supported create method params for this smart contract');
|
|
33
10
|
yield `export type ${name}CreateCallParams =`;
|
|
34
11
|
yield writer.IncIndent;
|
|
35
|
-
for (const method of
|
|
36
|
-
const onComplete =
|
|
37
|
-
if (method
|
|
38
|
-
yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.
|
|
12
|
+
for (const method of app.createMethods) {
|
|
13
|
+
const onComplete = method.createActions.inputType;
|
|
14
|
+
if (!appClientContext.isAbiMethod(method)) {
|
|
15
|
+
yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.typeLiteral} & CreateSchema>`;
|
|
39
16
|
}
|
|
40
17
|
else {
|
|
41
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
|
|
42
|
-
const uniqueName =
|
|
43
|
-
if (uniqueName !== method) {
|
|
18
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
19
|
+
const uniqueName = method.uniqueName.original;
|
|
20
|
+
if (uniqueName !== method.signature) {
|
|
44
21
|
const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
|
|
45
|
-
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.
|
|
22
|
+
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.typeLiteral} & CreateSchema>`;
|
|
46
23
|
}
|
|
47
|
-
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.
|
|
24
|
+
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.typeLiteral} & CreateSchema>`;
|
|
48
25
|
}
|
|
49
26
|
}
|
|
50
27
|
yield writer.DecIndent;
|
|
51
28
|
}
|
|
52
|
-
if (
|
|
29
|
+
if (app.updateMethods.length) {
|
|
53
30
|
yield* writer.jsDoc('Defines supported update method params for this smart contract');
|
|
54
31
|
yield `export type ${name}UpdateCallParams =`;
|
|
55
32
|
yield writer.IncIndent;
|
|
56
|
-
for (const method of
|
|
57
|
-
if (method
|
|
33
|
+
for (const method of app.updateMethods) {
|
|
34
|
+
if (!appClientContext.isAbiMethod(method)) {
|
|
58
35
|
yield `| Expand<AppClientBareCallParams> & {method?: never}`;
|
|
59
36
|
}
|
|
60
37
|
else {
|
|
61
|
-
const uniqueName =
|
|
62
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
|
|
63
|
-
if (uniqueName !== method) {
|
|
38
|
+
const uniqueName = method.uniqueName.original;
|
|
39
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
40
|
+
if (uniqueName !== method.signature) {
|
|
64
41
|
const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
|
|
65
42
|
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`;
|
|
66
43
|
}
|
|
@@ -69,18 +46,18 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
|
|
|
69
46
|
}
|
|
70
47
|
yield writer.DecIndent;
|
|
71
48
|
}
|
|
72
|
-
if (
|
|
49
|
+
if (app.deleteMethods.length) {
|
|
73
50
|
yield* writer.jsDoc('Defines supported delete method params for this smart contract');
|
|
74
51
|
yield `export type ${name}DeleteCallParams =`;
|
|
75
52
|
yield writer.IncIndent;
|
|
76
|
-
for (const method of
|
|
77
|
-
if (method
|
|
53
|
+
for (const method of app.deleteMethods) {
|
|
54
|
+
if (!appClientContext.isAbiMethod(method)) {
|
|
78
55
|
yield `| Expand<AppClientBareCallParams> & {method?: never}`;
|
|
79
56
|
}
|
|
80
57
|
else {
|
|
81
|
-
const uniqueName =
|
|
82
|
-
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method);
|
|
83
|
-
if (uniqueName !== method) {
|
|
58
|
+
const uniqueName = method.uniqueName.original;
|
|
59
|
+
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature);
|
|
60
|
+
if (uniqueName !== method.signature) {
|
|
84
61
|
const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName);
|
|
85
62
|
yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`;
|
|
86
63
|
}
|
|
@@ -92,15 +69,15 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
|
|
|
92
69
|
yield* writer.jsDoc('Defines arguments required for the deploy method.');
|
|
93
70
|
yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`;
|
|
94
71
|
yield writer.IncIndent;
|
|
95
|
-
if (
|
|
72
|
+
if (app.createMethods.length) {
|
|
96
73
|
yield* writer.jsDoc('Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
|
|
97
74
|
yield `createParams?: ${name}CreateCallParams`;
|
|
98
75
|
}
|
|
99
|
-
if (
|
|
76
|
+
if (app.updateMethods.length) {
|
|
100
77
|
yield* writer.jsDoc('Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
|
|
101
78
|
yield `updateParams?: ${name}UpdateCallParams`;
|
|
102
79
|
}
|
|
103
|
-
if (
|
|
80
|
+
if (app.deleteMethods.length) {
|
|
104
81
|
yield* writer.jsDoc('Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)');
|
|
105
82
|
yield `deleteParams?: ${name}DeleteCallParams`;
|
|
106
83
|
}
|
|
@@ -110,6 +87,4 @@ function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName
|
|
|
110
87
|
}
|
|
111
88
|
|
|
112
89
|
exports.deployTypes = deployTypes;
|
|
113
|
-
exports.getCallOnCompleteOptions = getCallOnCompleteOptions;
|
|
114
|
-
exports.getCreateOnCompleteOptions = getCreateOnCompleteOptions;
|
|
115
90
|
//# sourceMappingURL=deploy-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-types.js","sources":["../../src/client/deploy-types.ts"],"sourcesContent":["import { DecIndent, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodIdentifier } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function getCreateOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCreateOnCompletes =\n method === BARE_CALL ? app.bareActions.create : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.create\n const hasNoOp = validCreateOnCompletes?.includes('NoOp')\n const onCompleteType = validCreateOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCreateOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function getCallOnCompleteOptions(method: MethodIdentifier, app: Arc56Contract) {\n const validCallOnCompletes =\n method === BARE_CALL ? app.bareActions.call : app.methods.find((m) => new ABIMethod(m).getSignature() === method)?.actions?.call\n const hasNoOp = validCallOnCompletes?.includes('NoOp')\n const onCompleteType = validCallOnCompletes\n ? `{onComplete${hasNoOp ? '?' : ''}: ${validCallOnCompletes.map((oc) => `OnApplicationComplete.${oc}OC`).join(' | ')}}`\n : {}\n return {\n type: onCompleteType,\n isOptional: hasNoOp,\n }\n}\n\nexport function* deployTypes({ app, callConfig, sanitizer, methodSignatureToUniqueName }: GeneratorContext): DocumentParts {\n const name = sanitizer.makeSafeTypeIdentifier(app.name)\n\n if (callConfig.createMethods.length > 0) {\n yield* jsDoc('Defines supported create method params for this smart contract')\n yield `export type ${name}CreateCallParams =`\n yield IncIndent\n for (const method of callConfig.createMethods) {\n const onComplete = getCreateOnCompleteOptions(method, app)\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.type} & CreateSchema>`\n } else {\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n const uniqueName = methodSignatureToUniqueName[method]\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.type} & CreateSchema>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.type} & CreateSchema>`\n }\n }\n yield DecIndent\n }\n if (callConfig.updateMethods.length > 0) {\n yield* jsDoc('Defines supported update method params for this smart contract')\n yield `export type ${name}UpdateCallParams =`\n yield IncIndent\n for (const method of callConfig.updateMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n if (callConfig.deleteMethods.length > 0) {\n yield* jsDoc('Defines supported delete method params for this smart contract')\n yield `export type ${name}DeleteCallParams =`\n yield IncIndent\n for (const method of callConfig.deleteMethods) {\n if (method === BARE_CALL) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = methodSignatureToUniqueName[method]\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method)\n if (uniqueName !== method) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n yield* jsDoc('Defines arguments required for the deploy method.')\n yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`\n yield IncIndent\n if (callConfig.createMethods.length) {\n yield* jsDoc(\n 'Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `createParams?: ${name}CreateCallParams`\n }\n if (callConfig.updateMethods.length) {\n yield* jsDoc(\n 'Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `updateParams?: ${name}UpdateCallParams`\n }\n if (callConfig.deleteMethods.length) {\n yield* jsDoc(\n 'Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `deleteParams?: ${name}DeleteCallParams`\n }\n yield DecIndent\n yield `}>`\n yield NewLine\n}\n"],"names":["BARE_CALL","ABIMethod","jsDoc","IncIndent","DecIndent","NewLine"],"mappings":";;;;;;AAMM,SAAU,0BAA0B,CAAC,MAAwB,EAAE,GAAkB,EAAA;AACrF,IAAA,MAAM,sBAAsB,GAC1B,MAAM,KAAKA,8BAAS,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAIC,iBAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;IACtI,MAAM,OAAO,GAAG,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxD,MAAM,cAAc,GAAG;AACrB,UAAE,CAAA,WAAA,EAAc,OAAO,GAAG,GAAG,GAAG,EAAE,CAAA,EAAA,EAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAA,sBAAA,EAAyB,EAAE,CAAA,EAAA,CAAI,CAAC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,EAAmB,UAAU,CAAA,GAAA,CAAK;gBAC7I;gBACA,MAAM,CAAA,oBAAA,EAAuB,IAAI,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,IAAI,CAAA,eAAA,EAAkB,aAAa,CAAA,gBAAA,EAAmB,aAAa,CAAA,GAAA,CAAK;YAChJ;QACF;AACA,QAAA,MAAMI,gBAAS;IACjB;AAEA,IAAA,OAAOF,YAAK,CAAC,mDAAmD,CAAC;IACjE,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,wGAAA,CAA0G;AACnI,IAAA,MAAMC,gBAAS;AACf,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOD,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,IAAI,UAAU,CAAC,aAAa,CAAC,MAAM,EAAE;AACnC,QAAA,OAAOA,YAAK,CACV,uLAAuL,CACxL;QACD,MAAM,CAAA,eAAA,EAAkB,IAAI,CAAA,gBAAA,CAAkB;IAChD;AACA,IAAA,MAAME,gBAAS;AACf,IAAA,MAAM,IAAI;AACV,IAAA,MAAMC,cAAO;AACf;;;;;;"}
|
|
1
|
+
{"version":3,"file":"deploy-types.js","sources":["../../src/client/deploy-types.ts"],"sourcesContent":["import { DecIndent, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { isAbiMethod } from './app-client-context'\n\nexport function* deployTypes({ app, sanitizer }: GeneratorContext): DocumentParts {\n const name = app.name.makeSafeTypeIdentifier\n\n if (app.createMethods.length) {\n yield* jsDoc('Defines supported create method params for this smart contract')\n yield `export type ${name}CreateCallParams =`\n yield IncIndent\n\n for (const method of app.createMethods) {\n const onComplete = method.createActions.inputType\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams & {method?: never} & ${onComplete.typeLiteral} & CreateSchema>`\n } else {\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n const uniqueName = method.uniqueName.original\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'} & ${onComplete.typeLiteral} & CreateSchema>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'} & ${onComplete.typeLiteral} & CreateSchema>`\n }\n }\n yield DecIndent\n }\n if (app.updateMethods.length) {\n yield* jsDoc('Defines supported update method params for this smart contract')\n yield `export type ${name}UpdateCallParams =`\n yield IncIndent\n\n for (const method of app.updateMethods) {\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = method.uniqueName.original\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n if (app.deleteMethods.length) {\n yield* jsDoc('Defines supported delete method params for this smart contract')\n yield `export type ${name}DeleteCallParams =`\n yield IncIndent\n for (const method of app.deleteMethods) {\n if (!isAbiMethod(method)) {\n yield `| Expand<AppClientBareCallParams> & {method?: never}`\n } else {\n const uniqueName = method.uniqueName.original\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(method.signature)\n if (uniqueName !== method.signature) {\n const methodName = sanitizer.makeSafeStringTypeLiteral(uniqueName)\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodName}'}>`\n }\n yield `| Expand<CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']> & {method: '${methodSigSafe}'}>`\n }\n }\n yield DecIndent\n }\n\n yield* jsDoc('Defines arguments required for the deploy method.')\n yield `export type ${name}DeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {`\n yield IncIndent\n if (app.createMethods.length) {\n yield* jsDoc(\n 'Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `createParams?: ${name}CreateCallParams`\n }\n if (app.updateMethods.length) {\n yield* jsDoc(\n 'Update transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `updateParams?: ${name}UpdateCallParams`\n }\n if (app.deleteMethods.length) {\n yield* jsDoc(\n 'Delete transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)',\n )\n yield `deleteParams?: ${name}DeleteCallParams`\n }\n yield DecIndent\n yield `}>`\n yield NewLine\n}\n"],"names":["jsDoc","IncIndent","isAbiMethod","DecIndent","NewLine"],"mappings":";;;;;AAIM,UAAW,WAAW,CAAC,EAAE,GAAG,EAAE,SAAS,EAAoB,EAAA;AAC/D,IAAA,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,sBAAsB;AAE5C,IAAA,IAAI,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE;AAC5B,QAAA,OAAOA,YAAK,CAAC,gEAAgE,CAAC;QAC9E,MAAM,CAAA,YAAA,EAAe,IAAI,CAAA,kBAAA,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