@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/app-client.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var writer = require('../output/writer.js');
|
|
4
|
-
var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
|
|
5
|
-
var deployTypes = require('./deploy-types.js');
|
|
6
4
|
var callComposer = require('./call-composer.js');
|
|
7
|
-
var
|
|
8
|
-
var getEquivalentType = require('./helpers/get-equivalent-type.js');
|
|
9
|
-
var containsNonVoidMethod = require('./helpers/contains-non-void-method.js');
|
|
5
|
+
var appClientContext = require('./app-client-context.js');
|
|
10
6
|
|
|
11
7
|
function* appClient(ctx) {
|
|
12
8
|
const { app, name } = ctx;
|
|
@@ -35,16 +31,6 @@ function* appClient(ctx) {
|
|
|
35
31
|
appSpec: APP_SPEC,
|
|
36
32
|
})
|
|
37
33
|
}`;
|
|
38
|
-
if (containsNonVoidMethod.containsNonVoidMethod(app.methods)) {
|
|
39
|
-
yield `
|
|
40
|
-
/**
|
|
41
|
-
* Checks for decode errors on the given return value and maps the return value to the return type for the given method
|
|
42
|
-
* @returns The typed return value or undefined if there was no value
|
|
43
|
-
*/
|
|
44
|
-
decodeReturnValue<TSignature extends ${name}NonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {
|
|
45
|
-
return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined
|
|
46
|
-
}`;
|
|
47
|
-
}
|
|
48
34
|
yield `
|
|
49
35
|
/**
|
|
50
36
|
* Returns a new \`${name}Client\` client, resolving the app by creator address and name
|
|
@@ -137,16 +123,16 @@ function* send(ctx) {
|
|
|
137
123
|
yield writer.NewLine;
|
|
138
124
|
}
|
|
139
125
|
function* opMethods(ctx, type) {
|
|
140
|
-
const { app
|
|
126
|
+
const { app } = ctx;
|
|
141
127
|
if (ctx.mode === 'full') {
|
|
142
|
-
yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`,
|
|
143
|
-
yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`,
|
|
128
|
+
yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`, app.updateMethods, 'update', type, true);
|
|
129
|
+
yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, app.deleteMethods, 'delete', type);
|
|
144
130
|
}
|
|
145
|
-
yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`,
|
|
146
|
-
yield* operationMethods(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`,
|
|
131
|
+
yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, app.optInMethods, 'optIn', type);
|
|
132
|
+
yield* operationMethods(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, app.closeOutMethods, 'closeOut', type);
|
|
147
133
|
}
|
|
148
134
|
function* bareMethodCall({ generator: { app }, name, description, verb, type, includeCompilation, }) {
|
|
149
|
-
const onComplete = verb === 'create' ?
|
|
135
|
+
const onComplete = verb === 'create' ? app.bareMethod.createActions.inputType : verb === 'call' ? app.bareMethod.callActions.inputType : undefined;
|
|
150
136
|
yield* writer.jsDoc({
|
|
151
137
|
description: `${description}.`,
|
|
152
138
|
params: {
|
|
@@ -154,18 +140,14 @@ function* bareMethodCall({ generator: { app }, name, description, verb, type, in
|
|
|
154
140
|
},
|
|
155
141
|
returns: `The ${verb} result`,
|
|
156
142
|
});
|
|
157
|
-
yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & SendParams' : ''}${onComplete?.
|
|
143
|
+
yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & SendParams' : ''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}>) => {`;
|
|
158
144
|
yield* writer.indent(`return this.appClient.${type}.bare.${verb}(params)`);
|
|
159
145
|
yield '},';
|
|
160
146
|
}
|
|
161
|
-
function* abiMethodCall({ generator: {
|
|
162
|
-
const methodSig =
|
|
163
|
-
const uniqueName =
|
|
164
|
-
const onComplete = verb === 'create'
|
|
165
|
-
? deployTypes.getCreateOnCompleteOptions(methodSig, app)
|
|
166
|
-
: verb === 'call' && !readonly
|
|
167
|
-
? deployTypes.getCallOnCompleteOptions(methodSig, app)
|
|
168
|
-
: undefined;
|
|
147
|
+
function* abiMethodCall({ generator: { sanitizer, name }, method, description, verb, type, includeCompilation, readonly, }) {
|
|
148
|
+
const methodSig = method.signature;
|
|
149
|
+
const uniqueName = method.uniqueName.original;
|
|
150
|
+
const onComplete = verb === 'create' ? method.createActions.inputType : method.callActions.inputType;
|
|
169
151
|
yield* writer.jsDoc({
|
|
170
152
|
description: verb === 'call' && method.readonly
|
|
171
153
|
? [
|
|
@@ -183,7 +165,7 @@ function* abiMethodCall({ generator: { app, methodSignatureToUniqueName, name, s
|
|
|
183
165
|
const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
|
|
184
166
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
185
167
|
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
|
|
186
|
-
yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' &' + ' AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.
|
|
168
|
+
yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' &' + ' AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.typeLiteral && !readonly ? ` & ${onComplete.typeLiteral}` : ''}${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''})${!readonly ? ' =>' : ''} {`;
|
|
187
169
|
if (type === 'send') {
|
|
188
170
|
yield* writer.indent(`const result = await this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`, readonly
|
|
189
171
|
? `return result.return as unknown as ${name}Returns['${methodSigSafe}']`
|
|
@@ -200,8 +182,8 @@ function* operationMethods(generator, description, methods, verb, type, includeC
|
|
|
200
182
|
yield* writer.jsDoc(`Gets available ${verb} methods`);
|
|
201
183
|
yield `${verb}: {`;
|
|
202
184
|
yield writer.IncIndent;
|
|
203
|
-
for (const
|
|
204
|
-
if (
|
|
185
|
+
for (const method of methods) {
|
|
186
|
+
if (!appClientContext.isAbiMethod(method)) {
|
|
205
187
|
yield* bareMethodCall({
|
|
206
188
|
generator,
|
|
207
189
|
name: 'bare',
|
|
@@ -212,7 +194,6 @@ function* operationMethods(generator, description, methods, verb, type, includeC
|
|
|
212
194
|
});
|
|
213
195
|
}
|
|
214
196
|
else {
|
|
215
|
-
const method = generator.app.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodSig);
|
|
216
197
|
yield* abiMethodCall({
|
|
217
198
|
generator,
|
|
218
199
|
method,
|
|
@@ -239,7 +220,7 @@ function* clearState(generator, type) {
|
|
|
239
220
|
yield writer.NewLine;
|
|
240
221
|
}
|
|
241
222
|
function* call(generator, type) {
|
|
242
|
-
if (generator.
|
|
223
|
+
if (generator.app.bareMethod.callActions.noOp) {
|
|
243
224
|
yield* bareMethodCall({
|
|
244
225
|
generator,
|
|
245
226
|
name: 'bare',
|
|
@@ -251,11 +232,10 @@ function* call(generator, type) {
|
|
|
251
232
|
}
|
|
252
233
|
}
|
|
253
234
|
function* readonlyMethods(generator) {
|
|
254
|
-
const { app
|
|
255
|
-
for (const method of app.
|
|
256
|
-
const methodSignature = new algosdk.ABIMethod(method).getSignature();
|
|
235
|
+
const { app } = generator;
|
|
236
|
+
for (const method of app.abiMethods) {
|
|
257
237
|
// Skip non readonly methods
|
|
258
|
-
if (!
|
|
238
|
+
if (!method.readonly)
|
|
259
239
|
continue;
|
|
260
240
|
yield* abiMethodCall({
|
|
261
241
|
generator,
|
|
@@ -269,11 +249,9 @@ function* readonlyMethods(generator) {
|
|
|
269
249
|
}
|
|
270
250
|
}
|
|
271
251
|
function* noopMethods(generator, type) {
|
|
272
|
-
const { app
|
|
273
|
-
for (const method of app.
|
|
274
|
-
|
|
275
|
-
// Skip methods which don't support a no_op call config
|
|
276
|
-
if (!callConfig.callMethods.includes(methodSignature))
|
|
252
|
+
const { app } = generator;
|
|
253
|
+
for (const method of app.noOpMethods) {
|
|
254
|
+
if (!appClientContext.isAbiMethod(method))
|
|
277
255
|
continue;
|
|
278
256
|
yield* abiMethodCall({
|
|
279
257
|
generator,
|
|
@@ -308,14 +286,14 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
308
286
|
yield* writer.jsDoc(`Get all current keyed values from ${storageType} state`);
|
|
309
287
|
yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`;
|
|
310
288
|
yield* writer.indent(`const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getAll()`, `return {`, ...Object.keys(app.state.keys[storageType]).map((n) => {
|
|
311
|
-
return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType
|
|
289
|
+
return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType.isAvmBytes ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`;
|
|
312
290
|
}), `}`);
|
|
313
291
|
yield `},`;
|
|
314
292
|
for (const n of Object.keys(app.state.keys[storageType])) {
|
|
315
293
|
const name = sanitizer.makeSafePropertyIdentifier(n);
|
|
316
294
|
const k = app.state.keys[storageType][n];
|
|
317
295
|
yield* writer.jsDoc(`Get the current value of the ${n} key in ${storageType} state`);
|
|
318
|
-
yield `${name}: async (): Promise<${k.valueType
|
|
296
|
+
yield `${name}: async (): Promise<${k.valueType.isAvmBytes ? 'BinaryState' : `${k.valueType.tsOutType} | undefined`}> => { return ${k.valueType.isAvmBytes ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getValue("${sanitizer.makeSafeStringTypeLiteral(n)}"))${k.valueType.isAvmBytes ? ' as Uint8Array | undefined)' : ` as ${k.valueType.tsOutType} | undefined`} },`;
|
|
319
297
|
}
|
|
320
298
|
for (const n of Object.keys(app.state.maps[storageType])) {
|
|
321
299
|
const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n);
|
|
@@ -324,9 +302,9 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
324
302
|
yield `${name}: {`;
|
|
325
303
|
yield writer.IncIndent;
|
|
326
304
|
yield* writer.jsDoc(`Get all current values of the ${n} map in ${storageType} state`);
|
|
327
|
-
yield `getMap: async (): Promise<Map<${
|
|
305
|
+
yield `getMap: async (): Promise<Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMap("${sanitizer.makeSafeStringTypeLiteral(n)}")) as Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}> },`;
|
|
328
306
|
yield* writer.jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`);
|
|
329
|
-
yield `value: async (key: ${
|
|
307
|
+
yield `value: async (key: ${m.keyType.tsInType}): Promise<${m.valueType.tsOutType} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMapValue("${sanitizer.makeSafeStringTypeLiteral(n)}", key) as ${m.valueType.tsOutType} | undefined },`;
|
|
330
308
|
yield writer.DecIndent;
|
|
331
309
|
yield `},`;
|
|
332
310
|
}
|
|
@@ -340,17 +318,17 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
340
318
|
yield writer.DecIndentAndCloseBlock;
|
|
341
319
|
yield writer.NewLine;
|
|
342
320
|
}
|
|
343
|
-
function* cloneMethod({
|
|
321
|
+
function* cloneMethod({ app }) {
|
|
344
322
|
yield* writer.jsDoc({
|
|
345
323
|
description: 'Clone this app client with different params',
|
|
346
324
|
params: {
|
|
347
|
-
params: 'The params to use for the
|
|
325
|
+
params: 'The params to use for the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.',
|
|
348
326
|
},
|
|
349
327
|
returns: 'A new app client with the altered params',
|
|
350
328
|
});
|
|
351
329
|
yield `public clone(params: CloneAppClientParams) {`;
|
|
352
330
|
yield writer.IncIndent;
|
|
353
|
-
yield `return new ${name}Client(this.appClient.clone(params))`;
|
|
331
|
+
yield `return new ${app.name.makeSafeTypeIdentifier}Client(this.appClient.clone(params))`;
|
|
354
332
|
yield writer.DecIndentAndCloseBlock;
|
|
355
333
|
yield writer.NewLine;
|
|
356
334
|
}
|
package/client/app-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-client.js","sources":["../../src/client/app-client.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { GeneratorContext } from './generator-context'\nimport { getCallOnCompleteOptions, getCreateOnCompleteOptions } from './deploy-types'\nimport { composeMethod } from './call-composer'\nimport { ABIMethod } from 'algosdk'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { getEquivalentType } from './helpers/get-equivalent-type'\nimport { containsNonVoidMethod } from './helpers/contains-non-void-method'\n\nexport function* appClient(ctx: GeneratorContext): DocumentParts {\n const { app, name } = ctx\n\n yield* jsDoc(`A client to make calls to the ${app.name} smart contract`)\n yield `export class ${name}Client {`\n yield IncIndent\n yield* jsDoc(`The underlying \\`AppClient\\` for when you want to have more flexibility`)\n yield 'public readonly appClient: _AppClient'\n yield NewLine\n\n yield `\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param appClient An \\`AppClient\\` instance which has been created with the ${name} app spec\n */\n constructor(appClient: _AppClient)\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param params The parameters to initialise the app client with\n */\n constructor(params: Omit<AppClientParams, 'appSpec'>)\n constructor(appClientOrParams: _AppClient | Omit<AppClientParams, 'appSpec'>) {\n this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({\n ...appClientOrParams,\n appSpec: APP_SPEC,\n })\n }`\n\n if (containsNonVoidMethod(app.methods)) {\n yield `\n /**\n * Checks for decode errors on the given return value and maps the return value to the return type for the given method\n * @returns The typed return value or undefined if there was no value\n */\n decodeReturnValue<TSignature extends ${name}NonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {\n return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined\n }`\n }\n\n yield `\n /**\n * Returns a new \\`${name}Client\\` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n */\n public static async fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<${name}Client> {\n return new ${name}Client(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))\n }\n\n /**\n * Returns an \\`${name}Client\\` instance for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n */\n static async fromNetwork(\n params: Omit<ResolveAppClientByNetwork, 'appSpec'>\n ): Promise<${name}Client> {\n return new ${name}Client(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC}))\n }\n\n /** The ID of the app instance this client is linked to. */\n public get appId() {\n return this.appClient.appId\n }\n\n /** The app address of the app instance this client is linked to. */\n public get appAddress() {\n return this.appClient.appAddress\n }\n\n /** The name of the app. */\n public get appName() {\n return this.appClient.appName\n }\n\n /** The ARC-56 app spec being used */\n public get appSpec() {\n return this.appClient.appSpec\n }\n\n /** A reference to the underlying \\`AlgorandClient\\` this app client is using. */\n public get algorand(): AlgorandClient {\n return this.appClient.algorand\n }\n\n `\n\n yield* params(ctx)\n yield* createTransaction(ctx)\n yield* send(ctx)\n yield* cloneMethod(ctx)\n yield* readonlyMethods(ctx)\n yield* getStateMethods(ctx)\n yield* composeMethod(ctx)\n yield DecIndentAndCloseBlock\n}\n\nfunction* params(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(\n `Get parameters to create transactions for the current app. A good mental model for this is that these parameters represent a deferred transaction creation.`,\n )\n yield `readonly params = {`\n yield IncIndent\n yield* opMethods(ctx, 'params')\n yield* clearState(ctx, 'params')\n yield* call(ctx, 'params')\n yield* noopMethods(ctx, 'params')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* createTransaction(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Create transactions for the current app`)\n yield `readonly createTransaction = {`\n yield IncIndent\n yield* opMethods(ctx, 'createTransaction')\n yield* clearState(ctx, 'createTransaction')\n yield* call(ctx, 'createTransaction')\n yield* noopMethods(ctx, 'createTransaction')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* send(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Send calls to the current app`)\n yield `readonly send = {`\n yield IncIndent\n yield* opMethods(ctx, 'send')\n yield* clearState(ctx, 'send')\n yield* call(ctx, 'send')\n yield* noopMethods(ctx, 'send')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* opMethods(ctx: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n const { app, callConfig } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethods(\n ctx,\n `Updates an existing instance of the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n type,\n true,\n )\n yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'delete', type)\n }\n yield* operationMethods(\n ctx,\n `Opts the user into an existing instance of the ${app.name} smart contract`,\n callConfig.optInMethods,\n 'optIn',\n type,\n )\n yield* operationMethods(\n ctx,\n `Makes a close out call to an existing instance of the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n type,\n )\n}\n\nfunction* bareMethodCall({\n generator: { app },\n name,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n name: string\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'clearState' | 'call'\n type: 'params' | 'createTransaction' | 'send'\n includeCompilation?: boolean\n}): DocumentParts {\n const onComplete =\n verb === 'create' ? getCreateOnCompleteOptions(BARE_CALL, app) : verb === 'call' ? getCallOnCompleteOptions(BARE_CALL, app) : undefined\n yield* jsDoc({\n description: `${description}.`,\n params: {\n params: `The params for the bare (raw) call`,\n },\n returns: `The ${verb} result`,\n })\n yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & SendParams' : ''}${onComplete?.type ? ` & ${onComplete.type}` : ''}>) => {`\n yield* indent(`return this.appClient.${type}.bare.${verb}(params)`)\n yield '},'\n}\n\nfunction* abiMethodCall({\n generator: { app, methodSignatureToUniqueName, name, sanitizer },\n method,\n description,\n verb,\n type,\n includeCompilation,\n readonly,\n}: {\n generator: GeneratorContext\n method: Method\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'call'\n type: 'params' | 'createTransaction' | 'send'\n includeCompilation?: boolean\n readonly?: boolean\n}) {\n const methodSig = new ABIMethod(method).getSignature()\n const uniqueName = methodSignatureToUniqueName[methodSig]\n const onComplete =\n verb === 'create'\n ? getCreateOnCompleteOptions(methodSig, app)\n : verb === 'call' && !readonly\n ? getCallOnCompleteOptions(methodSig, app)\n : undefined\n yield* jsDoc({\n description:\n verb === 'call' && method.readonly\n ? [\n `${description} using the \\`${methodSig}\\` ABI method.`,\n '',\n 'This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.',\n ]\n : `${description} using the \\`${methodSig}\\` ABI method.`,\n abiDescription: method?.desc,\n params: {\n params: `The params for the smart contract call`,\n },\n returns: `The ${verb} ${type === 'params' ? 'params' : type === 'createTransaction' ? 'transaction' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,\n })\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${\n includeCompilation ? ' &' + ' AppClientCompilationParams' : ''\n }${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.type && !readonly ? ` & ${onComplete.type}` : ''}${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''})${!readonly ? ' =>' : ''} {`\n if (type === 'send') {\n yield* indent(\n `const result = await this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n readonly\n ? `return result.return as unknown as ${name}Returns['${methodSigSafe}']`\n : `return {...result, return: result.return as unknown as (undefined | ${name}Returns['${methodSigSafe}'])}`,\n )\n } else {\n yield* indent(\n `return this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n )\n }\n yield `}${!readonly ? ',' : ''}`\n yield NewLine\n}\n\nfunction* operationMethods(\n generator: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n type: 'params' | 'createTransaction' | 'send',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `${verb}: {`\n yield IncIndent\n for (const methodSig of methods) {\n if (methodSig === BARE_CALL) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `${description} using a bare call`,\n verb,\n type,\n includeCompilation,\n })\n } else {\n const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n yield* abiMethodCall({\n generator,\n method,\n description,\n verb,\n type,\n includeCompilation,\n })\n }\n }\n yield DecIndent\n yield '},'\n yield NewLine\n }\n}\n\nfunction* clearState(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n yield* bareMethodCall({\n generator,\n name: 'clearState',\n description: `Makes a clear_state call to an existing instance of the ${generator.app.name} smart contract`,\n verb: 'clearState',\n type,\n })\n yield NewLine\n}\n\nfunction* call(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n if (generator.callConfig.callMethods.includes(BARE_CALL)) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `Makes a call to the ${generator.app.name} smart contract using a bare call`,\n verb: 'call',\n type,\n })\n yield NewLine\n }\n}\n\nfunction* readonlyMethods(generator: GeneratorContext): DocumentParts {\n const { app, callConfig } = generator\n for (const method of app.methods) {\n const methodSignature = new ABIMethod(method).getSignature()\n // Skip non readonly methods\n if (!callConfig.callMethods.includes(methodSignature) || !method.readonly) continue\n\n yield* abiMethodCall({\n generator,\n description: `Makes a readonly (simulated) call to the ${generator.app.name} smart contract`,\n method,\n verb: 'call',\n type: 'send',\n includeCompilation: false,\n readonly: true,\n })\n }\n}\n\nfunction* noopMethods(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n const { app, callConfig } = generator\n for (const method of app.methods) {\n const methodSignature = new ABIMethod(method).getSignature()\n // Skip methods which don't support a no_op call config\n if (!callConfig.callMethods.includes(methodSignature)) continue\n\n yield* abiMethodCall({\n generator,\n description: `Makes a call to the ${generator.app.name} smart contract`,\n method,\n verb: 'call',\n type,\n includeCompilation: false,\n })\n }\n}\n\nfunction* getStateMethods({ app, sanitizer }: GeneratorContext): DocumentParts {\n if (Object.keys(app.state).length === 0) return\n\n yield* jsDoc(`Methods to access state for the current ${app.name} app`)\n yield 'state = {'\n yield IncIndent\n\n const storageTypes = ['global', 'local', 'box'] as const\n\n for (const storageType of storageTypes) {\n const hasKeys = Object.keys(app.state.keys[storageType]).length > 0\n const hasMaps = Object.keys(app.state.maps[storageType]).length > 0\n if (!hasKeys && !hasMaps) continue\n\n yield* jsDoc(`Methods to access ${storageType} state for the current ${app.name} app`)\n yield `${storageType}${storageType === 'local' ? ': (address: string | Address) => {' : ': {'}`\n yield IncIndent\n if (storageType === 'local') {\n yield \"const encodedAddress = typeof address === 'string' ? address : encodeAddress(address.publicKey)\"\n yield 'return {'\n yield IncIndent\n }\n\n yield* jsDoc(`Get all current keyed values from ${storageType} state`)\n yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`\n yield* indent(\n `const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getAll()`,\n `return {`,\n ...Object.keys(app.state.keys[storageType]).map((n) => {\n return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType === 'AVMBytes' ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`\n }),\n `}`,\n )\n yield `},`\n\n for (const n of Object.keys(app.state.keys[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(n)\n const k = app.state.keys[storageType][n]\n yield* jsDoc(`Get the current value of the ${n} key in ${storageType} state`)\n yield `${name}: async (): Promise<${k.valueType === 'AVMBytes' ? 'BinaryState' : `${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`}> => { return ${k.valueType === 'AVMBytes' ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getValue(\"${sanitizer.makeSafeStringTypeLiteral(n)}\"))${k.valueType === 'AVMBytes' ? ' as Uint8Array | undefined)' : ` as ${getEquivalentType(k.valueType, 'output', { app, sanitizer })} | undefined`} },`\n }\n\n for (const n of Object.keys(app.state.maps[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n)\n const m = app.state.maps[storageType][n]\n yield* jsDoc(`Get values from the ${n} map in ${storageType} state`)\n yield `${name}: {`\n yield IncIndent\n\n yield* jsDoc(`Get all current values of the ${n} map in ${storageType} state`)\n yield `getMap: async (): Promise<Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMap(\"${sanitizer.makeSafeStringTypeLiteral(n)}\")) as Map<${getEquivalentType(m.keyType, 'output', { app, sanitizer })}, ${getEquivalentType(m.valueType, 'output', { app, sanitizer })}> },`\n\n yield* jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`)\n yield `value: async (key: ${getEquivalentType(m.keyType, 'input', { app, sanitizer })}): Promise<${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMapValue(\"${sanitizer.makeSafeStringTypeLiteral(n)}\", key) as ${getEquivalentType(m.valueType, 'output', { app, sanitizer })} | undefined },`\n\n yield DecIndent\n yield `},`\n }\n\n yield DecIndent\n if (storageType === 'local') {\n yield '}'\n yield DecIndent\n }\n yield '},'\n }\n\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* cloneMethod({ name }: GeneratorContext): DocumentParts {\n yield* jsDoc({\n description: 'Clone this app client with different params',\n params: {\n params:\n 'The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.',\n },\n returns: 'A new app client with the altered params',\n })\n yield `public clone(params: CloneAppClientParams) {`\n yield IncIndent\n yield `return new ${name}Client(this.appClient.clone(params))`\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n"],"names":["jsDoc","IncIndent","NewLine","containsNonVoidMethod","composeMethod","DecIndentAndCloseBlock","getCreateOnCompleteOptions","BARE_CALL","getCallOnCompleteOptions","indent","ABIMethod","DecIndent","getEquivalentType"],"mappings":";;;;;;;;;;AAUM,UAAW,SAAS,CAAC,GAAqB,EAAA;AAC9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,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,iBAAiB;AAExa,YAAA,MAAMD,gBAAS;AACf,YAAA,MAAM,IAAI;QACZ;AAEA,QAAA,MAAMA,gBAAS;AACf,QAAA,IAAI,WAAW,KAAK,OAAO,EAAE;AAC3B,YAAA,MAAM,GAAG;AACT,YAAA,MAAMA,gBAAS;QACjB;AACA,QAAA,MAAM,IAAI;IACZ;AAEA,IAAA,MAAMN,6BAAsB;AAC5B,IAAA,MAAMH,cAAO;AACf;AAEA,UAAU,WAAW,CAAC,EAAE,IAAI,EAAoB,EAAA;IAC9C,OAAOF,YAAK,CAAC;AACX,QAAA,WAAW,EAAE,6CAA6C;AAC1D,QAAA,MAAM,EAAE;AACN,YAAA,MAAM,EACJ,2LAA2L;AAC9L,SAAA;AACD,QAAA,OAAO,EAAE,0CAA0C;AACpD,KAAA,CAAC;AACF,IAAA,MAAM,8CAA8C;AACpD,IAAA,MAAMC,gBAAS;IACf,MAAM,CAAA,WAAA,EAAc,IAAI,CAAA,oCAAA,CAAsC;AAC9D,IAAA,MAAMI,6BAAsB;AAC5B,IAAA,MAAMH,cAAO;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"app-client.js","sources":["../../src/client/app-client.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { composeMethod } from './call-composer'\n\nimport { AppClientMethodContext, AbiMethodClientContext, isAbiMethod } from './app-client-context'\n\nexport function* appClient(ctx: GeneratorContext): DocumentParts {\n const { app, name } = ctx\n\n yield* jsDoc(`A client to make calls to the ${app.name} smart contract`)\n yield `export class ${name}Client {`\n yield IncIndent\n yield* jsDoc(`The underlying \\`AppClient\\` for when you want to have more flexibility`)\n yield 'public readonly appClient: _AppClient'\n yield NewLine\n\n yield `\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param appClient An \\`AppClient\\` instance which has been created with the ${name} app spec\n */\n constructor(appClient: _AppClient)\n /**\n * Creates a new instance of \\`${name}Client\\`\n *\n * @param params The parameters to initialise the app client with\n */\n constructor(params: Omit<AppClientParams, 'appSpec'>)\n constructor(appClientOrParams: _AppClient | Omit<AppClientParams, 'appSpec'>) {\n this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({\n ...appClientOrParams,\n appSpec: APP_SPEC,\n })\n }`\n\n yield `\n /**\n * Returns a new \\`${name}Client\\` client, resolving the app by creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n */\n public static async fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<${name}Client> {\n return new ${name}Client(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))\n }\n\n /**\n * Returns an \\`${name}Client\\` instance for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n */\n static async fromNetwork(\n params: Omit<ResolveAppClientByNetwork, 'appSpec'>\n ): Promise<${name}Client> {\n return new ${name}Client(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC}))\n }\n\n /** The ID of the app instance this client is linked to. */\n public get appId() {\n return this.appClient.appId\n }\n\n /** The app address of the app instance this client is linked to. */\n public get appAddress() {\n return this.appClient.appAddress\n }\n\n /** The name of the app. */\n public get appName() {\n return this.appClient.appName\n }\n\n /** The ARC-56 app spec being used */\n public get appSpec() {\n return this.appClient.appSpec\n }\n\n /** A reference to the underlying \\`AlgorandClient\\` this app client is using. */\n public get algorand(): AlgorandClient {\n return this.appClient.algorand\n }\n\n `\n\n yield* params(ctx)\n yield* createTransaction(ctx)\n yield* send(ctx)\n yield* cloneMethod(ctx)\n yield* readonlyMethods(ctx)\n yield* getStateMethods(ctx)\n yield* composeMethod(ctx)\n yield DecIndentAndCloseBlock\n}\n\nfunction* params(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(\n `Get parameters to create transactions for the current app. A good mental model for this is that these parameters represent a deferred transaction creation.`,\n )\n yield `readonly params = {`\n yield IncIndent\n yield* opMethods(ctx, 'params')\n yield* clearState(ctx, 'params')\n yield* call(ctx, 'params')\n yield* noopMethods(ctx, 'params')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* createTransaction(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Create transactions for the current app`)\n yield `readonly createTransaction = {`\n yield IncIndent\n yield* opMethods(ctx, 'createTransaction')\n yield* clearState(ctx, 'createTransaction')\n yield* call(ctx, 'createTransaction')\n yield* noopMethods(ctx, 'createTransaction')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* send(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Send calls to the current app`)\n yield `readonly send = {`\n yield IncIndent\n yield* opMethods(ctx, 'send')\n yield* clearState(ctx, 'send')\n yield* call(ctx, 'send')\n yield* noopMethods(ctx, 'send')\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* opMethods(ctx: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n const { app } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`, app.updateMethods, 'update', type, true)\n yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, app.deleteMethods, 'delete', type)\n }\n yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, app.optInMethods, 'optIn', type)\n yield* operationMethods(\n ctx,\n `Makes a close out call to an existing instance of the ${app.name} smart contract`,\n app.closeOutMethods,\n 'closeOut',\n type,\n )\n}\n\nfunction* bareMethodCall({\n generator: { app },\n name,\n description,\n verb,\n type,\n includeCompilation,\n}: {\n generator: GeneratorContext\n name: string\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'clearState' | 'call'\n type: 'params' | 'createTransaction' | 'send'\n includeCompilation?: boolean\n}): DocumentParts {\n const onComplete =\n verb === 'create' ? app.bareMethod.createActions.inputType : verb === 'call' ? app.bareMethod.callActions.inputType : undefined\n yield* jsDoc({\n description: `${description}.`,\n params: {\n params: `The params for the bare (raw) call`,\n },\n returns: `The ${verb} result`,\n })\n yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' ? ' & SendParams' : ''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}>) => {`\n yield* indent(`return this.appClient.${type}.bare.${verb}(params)`)\n yield '},'\n}\n\nfunction* abiMethodCall({\n generator: { sanitizer, name },\n method,\n description,\n verb,\n type,\n includeCompilation,\n readonly,\n}: {\n generator: GeneratorContext\n method: AbiMethodClientContext\n description: string\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete' | 'call'\n type: 'params' | 'createTransaction' | 'send'\n includeCompilation?: boolean\n readonly?: boolean\n}) {\n const methodSig = method.signature\n const uniqueName = method.uniqueName.original\n const onComplete = verb === 'create' ? method.createActions.inputType : method.callActions.inputType\n yield* jsDoc({\n description:\n verb === 'call' && method.readonly\n ? [\n `${description} using the \\`${methodSig}\\` ABI method.`,\n '',\n 'This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.',\n ]\n : `${description} using the \\`${methodSig}\\` ABI method.`,\n abiDescription: method?.desc,\n params: {\n params: `The params for the smart contract call`,\n },\n returns: `The ${verb} ${type === 'params' ? 'params' : type === 'createTransaction' ? 'transaction' : 'result'}${method?.returns?.desc ? `: ${method.returns.desc}` : ''}`,\n })\n const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName)\n const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName)\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig)\n yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${\n includeCompilation ? ' &' + ' AppClientCompilationParams' : ''\n }${\n verb === 'create' ? ' & CreateSchema' : ''\n }${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.typeLiteral && !readonly ? ` & ${onComplete.typeLiteral}` : ''}${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''})${!readonly ? ' =>' : ''} {`\n if (type === 'send') {\n yield* indent(\n `const result = await this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n readonly\n ? `return result.return as unknown as ${name}Returns['${methodSigSafe}']`\n : `return {...result, return: result.return as unknown as (undefined | ${name}Returns['${methodSigSafe}'])}`,\n )\n } else {\n yield* indent(\n `return this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`,\n )\n }\n yield `}${!readonly ? ',' : ''}`\n yield NewLine\n}\n\nfunction* operationMethods(\n generator: GeneratorContext,\n description: string,\n methods: AppClientMethodContext[],\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n type: 'params' | 'createTransaction' | 'send',\n includeCompilation?: boolean,\n): DocumentParts {\n if (methods.length) {\n yield* jsDoc(`Gets available ${verb} methods`)\n yield `${verb}: {`\n yield IncIndent\n for (const method of methods) {\n if (!isAbiMethod(method)) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `${description} using a bare call`,\n verb,\n type,\n includeCompilation,\n })\n } else {\n yield* abiMethodCall({\n generator,\n method,\n description,\n verb,\n type,\n includeCompilation,\n })\n }\n }\n yield DecIndent\n yield '},'\n yield NewLine\n }\n}\n\nfunction* clearState(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n yield* bareMethodCall({\n generator,\n name: 'clearState',\n description: `Makes a clear_state call to an existing instance of the ${generator.app.name} smart contract`,\n verb: 'clearState',\n type,\n })\n yield NewLine\n}\n\nfunction* call(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n if (generator.app.bareMethod.callActions.noOp) {\n yield* bareMethodCall({\n generator,\n name: 'bare',\n description: `Makes a call to the ${generator.app.name} smart contract using a bare call`,\n verb: 'call',\n type,\n })\n yield NewLine\n }\n}\n\nfunction* readonlyMethods(generator: GeneratorContext): DocumentParts {\n const { app } = generator\n for (const method of app.abiMethods) {\n // Skip non readonly methods\n if (!method.readonly) continue\n\n yield* abiMethodCall({\n generator,\n description: `Makes a readonly (simulated) call to the ${generator.app.name} smart contract`,\n method,\n verb: 'call',\n type: 'send',\n includeCompilation: false,\n readonly: true,\n })\n }\n}\n\nfunction* noopMethods(generator: GeneratorContext, type: 'params' | 'createTransaction' | 'send'): DocumentParts {\n const { app } = generator\n for (const method of app.noOpMethods) {\n if (!isAbiMethod(method)) continue\n yield* abiMethodCall({\n generator,\n description: `Makes a call to the ${generator.app.name} smart contract`,\n method,\n verb: 'call',\n type,\n includeCompilation: false,\n })\n }\n}\n\nfunction* getStateMethods({ app, sanitizer }: GeneratorContext): DocumentParts {\n if (Object.keys(app.state).length === 0) return\n\n yield* jsDoc(`Methods to access state for the current ${app.name} app`)\n yield 'state = {'\n yield IncIndent\n\n const storageTypes = ['global', 'local', 'box'] as const\n\n for (const storageType of storageTypes) {\n const hasKeys = Object.keys(app.state.keys[storageType]).length > 0\n const hasMaps = Object.keys(app.state.maps[storageType]).length > 0\n if (!hasKeys && !hasMaps) continue\n\n yield* jsDoc(`Methods to access ${storageType} state for the current ${app.name} app`)\n yield `${storageType}${storageType === 'local' ? ': (address: string | Address) => {' : ': {'}`\n yield IncIndent\n if (storageType === 'local') {\n yield \"const encodedAddress = typeof address === 'string' ? address : encodeAddress(address.publicKey)\"\n yield 'return {'\n yield IncIndent\n }\n\n yield* jsDoc(`Get all current keyed values from ${storageType} state`)\n yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`\n yield* indent(\n `const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getAll()`,\n `return {`,\n ...Object.keys(app.state.keys[storageType]).map((n) => {\n return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType.isAvmBytes ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`\n }),\n `}`,\n )\n yield `},`\n\n for (const n of Object.keys(app.state.keys[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(n)\n const k = app.state.keys[storageType][n]\n yield* jsDoc(`Get the current value of the ${n} key in ${storageType} state`)\n yield `${name}: async (): Promise<${k.valueType.isAvmBytes ? 'BinaryState' : `${k.valueType.tsOutType} | undefined`}> => { return ${k.valueType.isAvmBytes ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getValue(\"${sanitizer.makeSafeStringTypeLiteral(n)}\"))${k.valueType.isAvmBytes ? ' as Uint8Array | undefined)' : ` as ${k.valueType.tsOutType} | undefined`} },`\n }\n\n for (const n of Object.keys(app.state.maps[storageType])) {\n const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n)\n const m = app.state.maps[storageType][n]\n yield* jsDoc(`Get values from the ${n} map in ${storageType} state`)\n yield `${name}: {`\n yield IncIndent\n\n yield* jsDoc(`Get all current values of the ${n} map in ${storageType} state`)\n yield `getMap: async (): Promise<Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMap(\"${sanitizer.makeSafeStringTypeLiteral(n)}\")) as Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}> },`\n\n yield* jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`)\n yield `value: async (key: ${m.keyType.tsInType}): Promise<${m.valueType.tsOutType} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMapValue(\"${sanitizer.makeSafeStringTypeLiteral(n)}\", key) as ${m.valueType.tsOutType} | undefined },`\n\n yield DecIndent\n yield `},`\n }\n\n yield DecIndent\n if (storageType === 'local') {\n yield '}'\n yield DecIndent\n }\n yield '},'\n }\n\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n\nfunction* cloneMethod({ app }: GeneratorContext): DocumentParts {\n yield* jsDoc({\n description: 'Clone this app client with different params',\n params: {\n params:\n 'The params to use for the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.',\n },\n returns: 'A new app client with the altered params',\n })\n yield `public clone(params: CloneAppClientParams) {`\n yield IncIndent\n yield `return new ${app.name.makeSafeTypeIdentifier}Client(this.appClient.clone(params))`\n yield DecIndentAndCloseBlock\n yield NewLine\n}\n"],"names":["jsDoc","IncIndent","NewLine","composeMethod","DecIndentAndCloseBlock","indent","isAbiMethod","DecIndent"],"mappings":";;;;;;AAMM,UAAW,SAAS,CAAC,GAAqB,EAAA;AAC9C,IAAA,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG;IAEzB,OAAOA,YAAK,CAAC,CAAA,8BAAA,EAAiC,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,CAAC;IACxE,MAAM,CAAA,aAAA,EAAgB,IAAI,CAAA,QAAA,CAAU;AACpC,IAAA,MAAMC,gBAAS;AACf,IAAA,OAAOD,YAAK,CAAC,CAAA,uEAAA,CAAyE,CAAC;AACvF,IAAA,MAAM,uCAAuC;AAC7C,IAAA,MAAME,cAAO;IAEb,MAAM;;qCAE6B,IAAI,CAAA;;oFAE2C,IAAI,CAAA;;;;qCAInD,IAAI,CAAA;;;;;;;;;;MAUnC;IAEJ,MAAM;;yBAEiB,IAAI,CAAA;;;;iHAIoF,IAAI,CAAA;mBAClG,IAAI,CAAA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;AACD,QAAA,OAAO,EAAE,0CAA0C;AACpD,KAAA,CAAC;AACF,IAAA,MAAM,8CAA8C;AACpD,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,sBAAsB,sCAAsC;AACzF,IAAA,MAAMG,6BAAsB;AAC5B,IAAA,MAAMF,cAAO;AACf;;;;"}
|
package/client/app-client.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { jsDoc, IncIndent, NewLine, DecIndentAndCloseBlock, indent, DecIndent } from '../output/writer.mjs';
|
|
2
|
-
import { BARE_CALL } from './helpers/get-call-config-summary.mjs';
|
|
3
|
-
import { getCallOnCompleteOptions, getCreateOnCompleteOptions } from './deploy-types.mjs';
|
|
4
2
|
import { composeMethod } from './call-composer.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import { getEquivalentType } from './helpers/get-equivalent-type.mjs';
|
|
7
|
-
import { containsNonVoidMethod } from './helpers/contains-non-void-method.mjs';
|
|
3
|
+
import { isAbiMethod } from './app-client-context.mjs';
|
|
8
4
|
|
|
9
5
|
function* appClient(ctx) {
|
|
10
6
|
const { app, name } = ctx;
|
|
@@ -33,16 +29,6 @@ function* appClient(ctx) {
|
|
|
33
29
|
appSpec: APP_SPEC,
|
|
34
30
|
})
|
|
35
31
|
}`;
|
|
36
|
-
if (containsNonVoidMethod(app.methods)) {
|
|
37
|
-
yield `
|
|
38
|
-
/**
|
|
39
|
-
* Checks for decode errors on the given return value and maps the return value to the return type for the given method
|
|
40
|
-
* @returns The typed return value or undefined if there was no value
|
|
41
|
-
*/
|
|
42
|
-
decodeReturnValue<TSignature extends ${name}NonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {
|
|
43
|
-
return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined
|
|
44
|
-
}`;
|
|
45
|
-
}
|
|
46
32
|
yield `
|
|
47
33
|
/**
|
|
48
34
|
* Returns a new \`${name}Client\` client, resolving the app by creator address and name
|
|
@@ -135,16 +121,16 @@ function* send(ctx) {
|
|
|
135
121
|
yield NewLine;
|
|
136
122
|
}
|
|
137
123
|
function* opMethods(ctx, type) {
|
|
138
|
-
const { app
|
|
124
|
+
const { app } = ctx;
|
|
139
125
|
if (ctx.mode === 'full') {
|
|
140
|
-
yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`,
|
|
141
|
-
yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`,
|
|
126
|
+
yield* operationMethods(ctx, `Updates an existing instance of the ${app.name} smart contract`, app.updateMethods, 'update', type, true);
|
|
127
|
+
yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, app.deleteMethods, 'delete', type);
|
|
142
128
|
}
|
|
143
|
-
yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`,
|
|
144
|
-
yield* operationMethods(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`,
|
|
129
|
+
yield* operationMethods(ctx, `Opts the user into an existing instance of the ${app.name} smart contract`, app.optInMethods, 'optIn', type);
|
|
130
|
+
yield* operationMethods(ctx, `Makes a close out call to an existing instance of the ${app.name} smart contract`, app.closeOutMethods, 'closeOut', type);
|
|
145
131
|
}
|
|
146
132
|
function* bareMethodCall({ generator: { app }, name, description, verb, type, includeCompilation, }) {
|
|
147
|
-
const onComplete = verb === 'create' ?
|
|
133
|
+
const onComplete = verb === 'create' ? app.bareMethod.createActions.inputType : verb === 'call' ? app.bareMethod.callActions.inputType : undefined;
|
|
148
134
|
yield* jsDoc({
|
|
149
135
|
description: `${description}.`,
|
|
150
136
|
params: {
|
|
@@ -152,18 +138,14 @@ function* bareMethodCall({ generator: { app }, name, description, verb, type, in
|
|
|
152
138
|
},
|
|
153
139
|
returns: `The ${verb} result`,
|
|
154
140
|
});
|
|
155
|
-
yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & SendParams' : ''}${onComplete?.
|
|
141
|
+
yield `${name}: (params?: Expand<AppClientBareCallParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' ? ' & SendParams' : ''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}>) => {`;
|
|
156
142
|
yield* indent(`return this.appClient.${type}.bare.${verb}(params)`);
|
|
157
143
|
yield '},';
|
|
158
144
|
}
|
|
159
|
-
function* abiMethodCall({ generator: {
|
|
160
|
-
const methodSig =
|
|
161
|
-
const uniqueName =
|
|
162
|
-
const onComplete = verb === 'create'
|
|
163
|
-
? getCreateOnCompleteOptions(methodSig, app)
|
|
164
|
-
: verb === 'call' && !readonly
|
|
165
|
-
? getCallOnCompleteOptions(methodSig, app)
|
|
166
|
-
: undefined;
|
|
145
|
+
function* abiMethodCall({ generator: { sanitizer, name }, method, description, verb, type, includeCompilation, readonly, }) {
|
|
146
|
+
const methodSig = method.signature;
|
|
147
|
+
const uniqueName = method.uniqueName.original;
|
|
148
|
+
const onComplete = verb === 'create' ? method.createActions.inputType : method.callActions.inputType;
|
|
167
149
|
yield* jsDoc({
|
|
168
150
|
description: verb === 'call' && method.readonly
|
|
169
151
|
? [
|
|
@@ -181,7 +163,7 @@ function* abiMethodCall({ generator: { app, methodSignatureToUniqueName, name, s
|
|
|
181
163
|
const methodName = sanitizer.makeSafeMethodIdentifier(uniqueName);
|
|
182
164
|
const methodNameAccessor = sanitizer.getSafeMemberAccessor(methodName);
|
|
183
165
|
const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(methodSig);
|
|
184
|
-
yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' &' + ' AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.
|
|
166
|
+
yield `${!readonly ? `${methodName}: ` : ''}${type === 'send' ? 'async ' : ''}${readonly ? `${methodName}` : ''}(params: CallParams<${name}Args['obj']['${methodSigSafe}'] | ${name}Args['tuple']['${methodSigSafe}']>${includeCompilation ? ' &' + ' AppClientCompilationParams' : ''}${verb === 'create' ? ' & CreateSchema' : ''}${type === 'send' && !readonly ? ' & SendParams' : ''}${onComplete?.typeLiteral && !readonly ? ` & ${onComplete.typeLiteral}` : ''}${onComplete?.isOptional !== false && (method.args.length === 0 || !method.args.some((a) => !a.defaultValue)) ? ` = {args: [${method.args.map((_) => 'undefined').join(', ')}]}` : ''})${!readonly ? ' =>' : ''} {`;
|
|
185
167
|
if (type === 'send') {
|
|
186
168
|
yield* indent(`const result = await this.appClient.${type}.${verb}(${name}ParamsFactory${verb !== 'call' ? `.${verb}` : ''}${methodNameAccessor}(params))`, readonly
|
|
187
169
|
? `return result.return as unknown as ${name}Returns['${methodSigSafe}']`
|
|
@@ -198,8 +180,8 @@ function* operationMethods(generator, description, methods, verb, type, includeC
|
|
|
198
180
|
yield* jsDoc(`Gets available ${verb} methods`);
|
|
199
181
|
yield `${verb}: {`;
|
|
200
182
|
yield IncIndent;
|
|
201
|
-
for (const
|
|
202
|
-
if (
|
|
183
|
+
for (const method of methods) {
|
|
184
|
+
if (!isAbiMethod(method)) {
|
|
203
185
|
yield* bareMethodCall({
|
|
204
186
|
generator,
|
|
205
187
|
name: 'bare',
|
|
@@ -210,7 +192,6 @@ function* operationMethods(generator, description, methods, verb, type, includeC
|
|
|
210
192
|
});
|
|
211
193
|
}
|
|
212
194
|
else {
|
|
213
|
-
const method = generator.app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig);
|
|
214
195
|
yield* abiMethodCall({
|
|
215
196
|
generator,
|
|
216
197
|
method,
|
|
@@ -237,7 +218,7 @@ function* clearState(generator, type) {
|
|
|
237
218
|
yield NewLine;
|
|
238
219
|
}
|
|
239
220
|
function* call(generator, type) {
|
|
240
|
-
if (generator.
|
|
221
|
+
if (generator.app.bareMethod.callActions.noOp) {
|
|
241
222
|
yield* bareMethodCall({
|
|
242
223
|
generator,
|
|
243
224
|
name: 'bare',
|
|
@@ -249,11 +230,10 @@ function* call(generator, type) {
|
|
|
249
230
|
}
|
|
250
231
|
}
|
|
251
232
|
function* readonlyMethods(generator) {
|
|
252
|
-
const { app
|
|
253
|
-
for (const method of app.
|
|
254
|
-
const methodSignature = new ABIMethod(method).getSignature();
|
|
233
|
+
const { app } = generator;
|
|
234
|
+
for (const method of app.abiMethods) {
|
|
255
235
|
// Skip non readonly methods
|
|
256
|
-
if (!
|
|
236
|
+
if (!method.readonly)
|
|
257
237
|
continue;
|
|
258
238
|
yield* abiMethodCall({
|
|
259
239
|
generator,
|
|
@@ -267,11 +247,9 @@ function* readonlyMethods(generator) {
|
|
|
267
247
|
}
|
|
268
248
|
}
|
|
269
249
|
function* noopMethods(generator, type) {
|
|
270
|
-
const { app
|
|
271
|
-
for (const method of app.
|
|
272
|
-
|
|
273
|
-
// Skip methods which don't support a no_op call config
|
|
274
|
-
if (!callConfig.callMethods.includes(methodSignature))
|
|
250
|
+
const { app } = generator;
|
|
251
|
+
for (const method of app.noOpMethods) {
|
|
252
|
+
if (!isAbiMethod(method))
|
|
275
253
|
continue;
|
|
276
254
|
yield* abiMethodCall({
|
|
277
255
|
generator,
|
|
@@ -306,14 +284,14 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
306
284
|
yield* jsDoc(`Get all current keyed values from ${storageType} state`);
|
|
307
285
|
yield `getAll: async (): Promise<Partial<Expand<${storageType[0].toUpperCase()}${storageType.substring(1)}KeysState>>> => {`;
|
|
308
286
|
yield* indent(`const result = await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getAll()`, `return {`, ...Object.keys(app.state.keys[storageType]).map((n) => {
|
|
309
|
-
return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType
|
|
287
|
+
return ` ${sanitizer.makeSafePropertyIdentifier(n)}: ${app.state.keys[storageType][n].valueType.isAvmBytes ? `new BinaryStateValue(result${sanitizer.getSafeMemberAccessor(n)})` : `result${sanitizer.getSafeMemberAccessor(n)}`},`;
|
|
310
288
|
}), `}`);
|
|
311
289
|
yield `},`;
|
|
312
290
|
for (const n of Object.keys(app.state.keys[storageType])) {
|
|
313
291
|
const name = sanitizer.makeSafePropertyIdentifier(n);
|
|
314
292
|
const k = app.state.keys[storageType][n];
|
|
315
293
|
yield* jsDoc(`Get the current value of the ${n} key in ${storageType} state`);
|
|
316
|
-
yield `${name}: async (): Promise<${k.valueType
|
|
294
|
+
yield `${name}: async (): Promise<${k.valueType.isAvmBytes ? 'BinaryState' : `${k.valueType.tsOutType} | undefined`}> => { return ${k.valueType.isAvmBytes ? 'new BinaryStateValue(' : ''}(await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getValue("${sanitizer.makeSafeStringTypeLiteral(n)}"))${k.valueType.isAvmBytes ? ' as Uint8Array | undefined)' : ` as ${k.valueType.tsOutType} | undefined`} },`;
|
|
317
295
|
}
|
|
318
296
|
for (const n of Object.keys(app.state.maps[storageType])) {
|
|
319
297
|
const name = sanitizer.makeSafePropertyIdentifier(app.state.keys[storageType][n] ? `${n}Map` : n);
|
|
@@ -322,9 +300,9 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
322
300
|
yield `${name}: {`;
|
|
323
301
|
yield IncIndent;
|
|
324
302
|
yield* jsDoc(`Get all current values of the ${n} map in ${storageType} state`);
|
|
325
|
-
yield `getMap: async (): Promise<Map<${
|
|
303
|
+
yield `getMap: async (): Promise<Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}>> => { return (await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMap("${sanitizer.makeSafeStringTypeLiteral(n)}")) as Map<${m.keyType.tsOutType}, ${m.valueType.tsOutType}> },`;
|
|
326
304
|
yield* jsDoc(`Get a current value of the ${n} map by key from ${storageType} state`);
|
|
327
|
-
yield `value: async (key: ${
|
|
305
|
+
yield `value: async (key: ${m.keyType.tsInType}): Promise<${m.valueType.tsOutType} | undefined> => { return await this.appClient.state.${storageType}${storageType === 'local' ? '(encodedAddress)' : ''}.getMapValue("${sanitizer.makeSafeStringTypeLiteral(n)}", key) as ${m.valueType.tsOutType} | undefined },`;
|
|
328
306
|
yield DecIndent;
|
|
329
307
|
yield `},`;
|
|
330
308
|
}
|
|
@@ -338,17 +316,17 @@ function* getStateMethods({ app, sanitizer }) {
|
|
|
338
316
|
yield DecIndentAndCloseBlock;
|
|
339
317
|
yield NewLine;
|
|
340
318
|
}
|
|
341
|
-
function* cloneMethod({
|
|
319
|
+
function* cloneMethod({ app }) {
|
|
342
320
|
yield* jsDoc({
|
|
343
321
|
description: 'Clone this app client with different params',
|
|
344
322
|
params: {
|
|
345
|
-
params: 'The params to use for the
|
|
323
|
+
params: 'The params to use for the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.',
|
|
346
324
|
},
|
|
347
325
|
returns: 'A new app client with the altered params',
|
|
348
326
|
});
|
|
349
327
|
yield `public clone(params: CloneAppClientParams) {`;
|
|
350
328
|
yield IncIndent;
|
|
351
|
-
yield `return new ${name}Client(this.appClient.clone(params))`;
|
|
329
|
+
yield `return new ${app.name.makeSafeTypeIdentifier}Client(this.appClient.clone(params))`;
|
|
352
330
|
yield DecIndentAndCloseBlock;
|
|
353
331
|
yield NewLine;
|
|
354
332
|
}
|