From 18ab4e9756177ce4823a94a9ac212a243d995360 Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Thu, 28 Nov 2024 16:09:23 +0800 Subject: [PATCH] fix: correctly call createTransaction (#135) --- examples/arc56_test/client.ts | 4 +-- examples/duplicate_structs/client.ts | 4 +-- examples/helloworld/client.ts | 4 +-- examples/lifecycle/client.ts | 12 ++++----- examples/minimal/client.ts | 4 +-- examples/nested/client.ts | 4 +-- examples/reti/client.ts | 4 +-- examples/state/client.ts | 8 +++--- examples/voting/client.ts | 4 +-- src/client/app-factory.ts | 37 +++++++++++++++++++++++----- 10 files changed, 55 insertions(+), 30 deletions(-) diff --git a/examples/arc56_test/client.ts b/examples/arc56_test/client.ts index 6ad32f7..4b1f5c1 100644 --- a/examples/arc56_test/client.ts +++ b/examples/arc56_test/client.ts @@ -444,10 +444,10 @@ export class Arc56TestFactory { * Creates a new instance of the ARC56Test smart contract using the createApplication()void ABI method. * * @param params The params for the smart contract call - * @returns The create params + * @returns The create transaction */ createApplication: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => { - return this.appFactory.params.create(Arc56TestParamsFactory.create.createApplication(params)) + return this.appFactory.createTransaction.create(Arc56TestParamsFactory.create.createApplication(params)) }, }, diff --git a/examples/duplicate_structs/client.ts b/examples/duplicate_structs/client.ts index f3fb594..8bb7cf4 100644 --- a/examples/duplicate_structs/client.ts +++ b/examples/duplicate_structs/client.ts @@ -311,10 +311,10 @@ export class DuplicateStructsContractFactory { * Creates a new instance of the DuplicateStructsContract smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, }, diff --git a/examples/helloworld/client.ts b/examples/helloworld/client.ts index bd87419..d0722e0 100644 --- a/examples/helloworld/client.ts +++ b/examples/helloworld/client.ts @@ -352,10 +352,10 @@ export class HelloWorldAppFactory { * Creates a new instance of the HelloWorldApp smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, }, diff --git a/examples/lifecycle/client.ts b/examples/lifecycle/client.ts index bd9e4e4..5aee028 100644 --- a/examples/lifecycle/client.ts +++ b/examples/lifecycle/client.ts @@ -434,10 +434,10 @@ export class LifeCycleAppFactory { * Creates a new instance of the LifeCycleApp smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, /** * Creates a new instance of the LifeCycleApp smart contract using the create(string)string ABI method. @@ -445,10 +445,10 @@ export class LifeCycleAppFactory { * ABI create method with 1 argument * * @param params The params for the smart contract call - * @returns The create params: The formatted greeting + * @returns The create transaction: The formatted greeting */ createStringString: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}) => { - return this.appFactory.params.create(LifeCycleAppParamsFactory.create.createStringString(params)) + return this.appFactory.createTransaction.create(LifeCycleAppParamsFactory.create.createStringString(params)) }, /** * Creates a new instance of the LifeCycleApp smart contract using the create(string,uint32)void ABI method. @@ -456,10 +456,10 @@ export class LifeCycleAppFactory { * ABI create method with 2 arguments * * @param params The params for the smart contract call - * @returns The create params + * @returns The create transaction */ createStringUint32Void: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}) => { - return this.appFactory.params.create(LifeCycleAppParamsFactory.create.createStringUint32Void(params)) + return this.appFactory.createTransaction.create(LifeCycleAppParamsFactory.create.createStringUint32Void(params)) }, }, diff --git a/examples/minimal/client.ts b/examples/minimal/client.ts index ef0be9a..32388c5 100644 --- a/examples/minimal/client.ts +++ b/examples/minimal/client.ts @@ -302,10 +302,10 @@ export class AppFactory { * Creates a new instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, }, diff --git a/examples/nested/client.ts b/examples/nested/client.ts index d1191d9..dfcedf2 100644 --- a/examples/nested/client.ts +++ b/examples/nested/client.ts @@ -326,10 +326,10 @@ export class NestedContractFactory { * Creates a new instance of the NestedContract smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, }, diff --git a/examples/reti/client.ts b/examples/reti/client.ts index 9519c53..3bb5156 100644 --- a/examples/reti/client.ts +++ b/examples/reti/client.ts @@ -1543,10 +1543,10 @@ export class ValidatorRegistryFactory { * Creates a new instance of the ValidatorRegistry smart contract using the createApplication()void ABI method. * * @param params The params for the smart contract call - * @returns The create params + * @returns The create transaction */ createApplication: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC} = {args: []}) => { - return this.appFactory.params.create(ValidatorRegistryParamsFactory.create.createApplication(params)) + return this.appFactory.createTransaction.create(ValidatorRegistryParamsFactory.create.createApplication(params)) }, }, diff --git a/examples/state/client.ts b/examples/state/client.ts index 0314469..5460ef9 100644 --- a/examples/state/client.ts +++ b/examples/state/client.ts @@ -895,19 +895,19 @@ export class StateAppFactory { * Creates a new instance of the StateApp smart contract using a bare call. * * @param params The params for the bare (raw) call - * @returns The params for a create call + * @returns The transaction for a create call */ bare: (params?: Expand) => { - return this.appFactory.params.bare.create(params) + return this.appFactory.createTransaction.bare.create(params) }, /** * Creates a new instance of the StateApp smart contract using the create_abi(string)string ABI method. * * @param params The params for the smart contract call - * @returns The create params + * @returns The create transaction */ createAbi: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}) => { - return this.appFactory.params.create(StateAppParamsFactory.create.createAbi(params)) + return this.appFactory.createTransaction.create(StateAppParamsFactory.create.createAbi(params)) }, }, diff --git a/examples/voting/client.ts b/examples/voting/client.ts index 9b2645d..9499e40 100644 --- a/examples/voting/client.ts +++ b/examples/voting/client.ts @@ -510,10 +510,10 @@ export class VotingRoundAppFactory { * Creates a new instance of the VotingRoundApp smart contract using the create(string,byte[],string,uint64,uint64,uint8[],uint64,string)void ABI method. * * @param params The params for the smart contract call - * @returns The create params + * @returns The create transaction */ create: (params: CallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}) => { - return this.appFactory.params.create(VotingRoundAppParamsFactory.create.create(params)) + return this.appFactory.createTransaction.create(VotingRoundAppParamsFactory.create.create(params)) }, }, diff --git a/src/client/app-factory.ts b/src/client/app-factory.ts index a84344e..1a147fe 100644 --- a/src/client/app-factory.ts +++ b/src/client/app-factory.ts @@ -148,22 +148,43 @@ function* createMethods(generator: GeneratorContext): DocumentParts { function* paramMethods(ctx: GeneratorContext): DocumentParts { const { app, callConfig } = ctx - yield* operationMethods(ctx, `Creates a new instance of the ${app.name} smart contract`, callConfig.createMethods, 'create', true) + yield* operationMethods( + ctx, + `Creates a new instance of the ${app.name} smart contract`, + callConfig.createMethods, + 'create', + 'params', + true, + ) yield* operationMethods( ctx, `Updates an existing instance of the ${app.name} smart contract`, callConfig.updateMethods, 'deployUpdate', + 'params', true, ) - yield* operationMethods(ctx, `Deletes an existing instance of the ${app.name} smart contract`, callConfig.deleteMethods, 'deployDelete') + yield* operationMethods( + ctx, + `Deletes an existing instance of the ${app.name} smart contract`, + callConfig.deleteMethods, + 'deployDelete', + 'params', + ) } function* createTransactionMethods(ctx: GeneratorContext): DocumentParts { const { app, callConfig } = ctx - yield* operationMethods(ctx, `Creates a new instance of the ${app.name} smart contract`, callConfig.createMethods, 'create', true) + yield* operationMethods( + ctx, + `Creates a new instance of the ${app.name} smart contract`, + callConfig.createMethods, + 'create', + 'createTransaction', + true, + ) } function* bareMethodCallParams({ @@ -187,7 +208,10 @@ function* bareMethodCallParams({ params: { params: `The params for the bare (raw) call`, }, - returns: type === 'params' ? `The params for a ${verb} call` : `The ${verb} result`, + returns: + type === 'params' || type === 'createTransaction' + ? `The ${type === 'createTransaction' ? 'transaction' : type} for a ${verb} call` + : `The ${verb} result`, }) yield `${name}: ${type === 'send' ? 'async ' : ''}(params?: Expand