diff --git a/examples/helloworld/client.ts b/examples/helloworld/client.ts index 5535168..afe4e02 100644 --- a/examples/helloworld/client.ts +++ b/examples/helloworld/client.ts @@ -24,7 +24,7 @@ import type { ApplicationClient, } from '@algorandfoundation/algokit-utils/types/app-client' import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec' -import type { SendTransactionResult, TransactionToSign, SendTransactionFrom } from '@algorandfoundation/algokit-utils/types/transaction' +import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction' import type { ABIResult, TransactionWithSigner } from 'algosdk' import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk' export const APP_SPEC: AppSpec = { @@ -128,7 +128,7 @@ export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApp */ export type IntegerState = { /** - * Gets the state value as a BigInt + * Gets the state value as a BigInt. */ asBigInt(): bigint /** @@ -153,6 +153,11 @@ export type BinaryState = { export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial & AppReference export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial +export type AppClientComposeCallCoreParams = Omit & { + sendParams?: Omit +} +export type AppClientComposeExecuteParams = Pick + /** * Defines the types of available calls and state of the HelloWorldApp smart contract. */ @@ -516,12 +521,12 @@ export class HelloWorldAppClient { let promiseChain:Promise = Promise.resolve() const resultMappers: Array any)> = [] return { - hello(args: MethodArgs<'hello(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + hello(args: MethodArgs<'hello(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.hello(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - helloWorldCheck(args: MethodArgs<'hello_world_check(string)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + helloWorldCheck(args: MethodArgs<'hello_world_check(string)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.helloWorldCheck(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -529,7 +534,7 @@ export class HelloWorldAppClient { get update() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.update.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this @@ -539,14 +544,14 @@ export class HelloWorldAppClient { get delete() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.delete.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, } }, - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -567,9 +572,9 @@ export class HelloWorldAppClient { returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) } }, - async execute() { + async execute(sendParams?: AppClientComposeExecuteParams) { await promiseChain - const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams: {} }, client.algod) + const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod) return { ...result, returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) @@ -588,7 +593,7 @@ export type HelloWorldAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - hello(args: MethodArgs<'hello(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, MethodReturn<'hello(string)string'>]> + hello(args: MethodArgs<'hello(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, MethodReturn<'hello(string)string'>]> /** * Calls the hello_world_check(string)void ABI method. @@ -599,7 +604,7 @@ export type HelloWorldAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - helloWorldCheck(args: MethodArgs<'hello_world_check(string)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, MethodReturn<'hello_world_check(string)void'>]> + helloWorldCheck(args: MethodArgs<'hello_world_check(string)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, MethodReturn<'hello_world_check(string)void'>]> /** * Gets available update methods @@ -611,7 +616,7 @@ export type HelloWorldAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> } /** @@ -624,7 +629,7 @@ export type HelloWorldAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> } /** @@ -633,7 +638,7 @@ export type HelloWorldAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): HelloWorldAppComposer<[...TReturns, undefined]> /** * Adds a transaction to the composer @@ -653,7 +658,7 @@ export type HelloWorldAppComposer = { /** * Executes the transaction group and returns the results */ - execute(): Promise> + execute(sendParams?: AppClientComposeExecuteParams): Promise> } export type SimulateOptions = Omit[0], 'txnGroups'> export type HelloWorldAppComposerSimulateResult = { diff --git a/examples/lifecycle/client.ts b/examples/lifecycle/client.ts index ba47134..aed122b 100644 --- a/examples/lifecycle/client.ts +++ b/examples/lifecycle/client.ts @@ -24,7 +24,7 @@ import type { ApplicationClient, } from '@algorandfoundation/algokit-utils/types/app-client' import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec' -import type { SendTransactionResult, TransactionToSign, SendTransactionFrom } from '@algorandfoundation/algokit-utils/types/transaction' +import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction' import type { ABIResult, TransactionWithSigner } from 'algosdk' import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk' export const APP_SPEC: AppSpec = { @@ -174,7 +174,7 @@ export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApp */ export type IntegerState = { /** - * Gets the state value as a BigInt + * Gets the state value as a BigInt. */ asBigInt(): bigint /** @@ -199,6 +199,11 @@ export type BinaryState = { export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial & AppReference export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial +export type AppClientComposeCallCoreParams = Omit & { + sendParams?: Omit +} +export type AppClientComposeExecuteParams = Pick + /** * Defines the types of available calls and state of the LifeCycleApp smart contract. */ @@ -638,12 +643,12 @@ export class LifeCycleAppClient { let promiseChain:Promise = Promise.resolve() const resultMappers: Array any)> = [] return { - helloStringString(args: MethodArgs<'hello(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + helloStringString(args: MethodArgs<'hello(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.helloStringString(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - helloString(args: MethodArgs<'hello()string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + helloString(args: MethodArgs<'hello()string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.helloString(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -651,14 +656,14 @@ export class LifeCycleAppClient { get update() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.update.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, } }, - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -679,9 +684,9 @@ export class LifeCycleAppClient { returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) } }, - async execute() { + async execute(sendParams?: AppClientComposeExecuteParams) { await promiseChain - const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams: {} }, client.algod) + const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod) return { ...result, returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) @@ -698,7 +703,7 @@ export type LifeCycleAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - helloStringString(args: MethodArgs<'hello(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, MethodReturn<'hello(string)string'>]> + helloStringString(args: MethodArgs<'hello(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, MethodReturn<'hello(string)string'>]> /** * Calls the hello()string ABI method. @@ -707,7 +712,7 @@ export type LifeCycleAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - helloString(args: MethodArgs<'hello()string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, MethodReturn<'hello()string'>]> + helloString(args: MethodArgs<'hello()string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, MethodReturn<'hello()string'>]> /** * Gets available update methods @@ -719,7 +724,7 @@ export type LifeCycleAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, undefined]> } /** @@ -728,7 +733,7 @@ export type LifeCycleAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, undefined]> + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): LifeCycleAppComposer<[...TReturns, undefined]> /** * Adds a transaction to the composer @@ -748,7 +753,7 @@ export type LifeCycleAppComposer = { /** * Executes the transaction group and returns the results */ - execute(): Promise> + execute(sendParams?: AppClientComposeExecuteParams): Promise> } export type SimulateOptions = Omit[0], 'txnGroups'> export type LifeCycleAppComposerSimulateResult = { diff --git a/examples/state/client.ts b/examples/state/client.ts index 0aa5214..2201de7 100644 --- a/examples/state/client.ts +++ b/examples/state/client.ts @@ -24,7 +24,7 @@ import type { ApplicationClient, } from '@algorandfoundation/algokit-utils/types/app-client' import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec' -import type { SendTransactionResult, TransactionToSign, SendTransactionFrom } from '@algorandfoundation/algokit-utils/types/transaction' +import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction' import type { ABIResult, TransactionWithSigner } from 'algosdk' import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk' export const APP_SPEC: AppSpec = { @@ -503,7 +503,7 @@ export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApp */ export type IntegerState = { /** - * Gets the state value as a BigInt + * Gets the state value as a BigInt. */ asBigInt(): bigint /** @@ -528,6 +528,11 @@ export type BinaryState = { export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial & AppReference export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial +export type AppClientComposeCallCoreParams = Omit & { + sendParams?: Omit +} +export type AppClientComposeExecuteParams = Pick + /** * Defines the types of available calls and state of the StateApp smart contract. */ @@ -1464,62 +1469,62 @@ export class StateAppClient { let promiseChain:Promise = Promise.resolve() const resultMappers: Array any)> = [] return { - callAbi(args: MethodArgs<'call_abi(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + callAbi(args: MethodArgs<'call_abi(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.callAbi(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - callAbiTxn(args: MethodArgs<'call_abi_txn(pay,string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + callAbiTxn(args: MethodArgs<'call_abi_txn(pay,string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.callAbiTxn(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - callWithReferences(args: MethodArgs<'call_with_references(asset,account,application)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + callWithReferences(args: MethodArgs<'call_with_references(asset,account,application)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.callWithReferences(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - setGlobal(args: MethodArgs<'set_global(uint64,uint64,string,byte[4])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + setGlobal(args: MethodArgs<'set_global(uint64,uint64,string,byte[4])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.setGlobal(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - setLocal(args: MethodArgs<'set_local(uint64,uint64,string,byte[4])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + setLocal(args: MethodArgs<'set_local(uint64,uint64,string,byte[4])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.setLocal(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - setBox(args: MethodArgs<'set_box(byte[4],string)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + setBox(args: MethodArgs<'set_box(byte[4],string)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.setBox(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - error(args: MethodArgs<'error()void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + error(args: MethodArgs<'error()void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.error(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - defaultValue(args: MethodArgs<'default_value(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + defaultValue(args: MethodArgs<'default_value(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.defaultValue(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - defaultValueInt(args: MethodArgs<'default_value_int(uint64)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + defaultValueInt(args: MethodArgs<'default_value_int(uint64)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.defaultValueInt(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - defaultValueFromAbi(args: MethodArgs<'default_value_from_abi(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + defaultValueFromAbi(args: MethodArgs<'default_value_from_abi(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.defaultValueFromAbi(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - defaultValueFromGlobalState(args: MethodArgs<'default_value_from_global_state(uint64)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + defaultValueFromGlobalState(args: MethodArgs<'default_value_from_global_state(uint64)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.defaultValueFromGlobalState(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - defaultValueFromLocalState(args: MethodArgs<'default_value_from_local_state(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + defaultValueFromLocalState(args: MethodArgs<'default_value_from_local_state(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.defaultValueFromLocalState(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -1527,12 +1532,12 @@ export class StateAppClient { get update() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.update.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, - updateAbi(args: MethodArgs<'update_abi(string)string'>, params?: AppClientCallCoreParams & AppClientCompilationParams) { + updateAbi(args: MethodArgs<'update_abi(string)string'>, params?: AppClientComposeCallCoreParams & AppClientCompilationParams) { promiseChain = promiseChain.then(() => client.update.updateAbi(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this @@ -1542,12 +1547,12 @@ export class StateAppClient { get delete() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.delete.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, - deleteAbi(args: MethodArgs<'delete_abi(string)string'>, params?: AppClientCallCoreParams) { + deleteAbi(args: MethodArgs<'delete_abi(string)string'>, params?: AppClientComposeCallCoreParams) { promiseChain = promiseChain.then(() => client.delete.deleteAbi(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this @@ -1557,14 +1562,14 @@ export class StateAppClient { get optIn() { const $this = this return { - optIn(args: MethodArgs<'opt_in()void'>, params?: AppClientCallCoreParams) { + optIn(args: MethodArgs<'opt_in()void'>, params?: AppClientComposeCallCoreParams) { promiseChain = promiseChain.then(() => client.optIn.optIn(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, } }, - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -1585,9 +1590,9 @@ export class StateAppClient { returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) } }, - async execute() { + async execute(sendParams?: AppClientComposeExecuteParams) { await promiseChain - const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams: {} }, client.algod) + const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod) return { ...result, returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) @@ -1604,7 +1609,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - callAbi(args: MethodArgs<'call_abi(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_abi(string)string'>]> + callAbi(args: MethodArgs<'call_abi(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_abi(string)string'>]> /** * Calls the call_abi_txn(pay,string)string ABI method. @@ -1613,7 +1618,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - callAbiTxn(args: MethodArgs<'call_abi_txn(pay,string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_abi_txn(pay,string)string'>]> + callAbiTxn(args: MethodArgs<'call_abi_txn(pay,string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_abi_txn(pay,string)string'>]> /** * Calls the call_with_references(asset,account,application)uint64 ABI method. @@ -1622,7 +1627,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - callWithReferences(args: MethodArgs<'call_with_references(asset,account,application)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_with_references(asset,account,application)uint64'>]> + callWithReferences(args: MethodArgs<'call_with_references(asset,account,application)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'call_with_references(asset,account,application)uint64'>]> /** * Calls the set_global(uint64,uint64,string,byte[4])void ABI method. @@ -1631,7 +1636,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - setGlobal(args: MethodArgs<'set_global(uint64,uint64,string,byte[4])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_global(uint64,uint64,string,byte[4])void'>]> + setGlobal(args: MethodArgs<'set_global(uint64,uint64,string,byte[4])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_global(uint64,uint64,string,byte[4])void'>]> /** * Calls the set_local(uint64,uint64,string,byte[4])void ABI method. @@ -1640,7 +1645,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - setLocal(args: MethodArgs<'set_local(uint64,uint64,string,byte[4])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_local(uint64,uint64,string,byte[4])void'>]> + setLocal(args: MethodArgs<'set_local(uint64,uint64,string,byte[4])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_local(uint64,uint64,string,byte[4])void'>]> /** * Calls the set_box(byte[4],string)void ABI method. @@ -1649,7 +1654,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - setBox(args: MethodArgs<'set_box(byte[4],string)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_box(byte[4],string)void'>]> + setBox(args: MethodArgs<'set_box(byte[4],string)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'set_box(byte[4],string)void'>]> /** * Calls the error()void ABI method. @@ -1658,7 +1663,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - error(args: MethodArgs<'error()void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'error()void'>]> + error(args: MethodArgs<'error()void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'error()void'>]> /** * Calls the default_value(string)string ABI method. @@ -1667,7 +1672,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - defaultValue(args: MethodArgs<'default_value(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value(string)string'>]> + defaultValue(args: MethodArgs<'default_value(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value(string)string'>]> /** * Calls the default_value_int(uint64)uint64 ABI method. @@ -1676,7 +1681,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - defaultValueInt(args: MethodArgs<'default_value_int(uint64)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_int(uint64)uint64'>]> + defaultValueInt(args: MethodArgs<'default_value_int(uint64)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_int(uint64)uint64'>]> /** * Calls the default_value_from_abi(string)string ABI method. @@ -1685,7 +1690,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - defaultValueFromAbi(args: MethodArgs<'default_value_from_abi(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_abi(string)string'>]> + defaultValueFromAbi(args: MethodArgs<'default_value_from_abi(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_abi(string)string'>]> /** * Calls the default_value_from_global_state(uint64)uint64 ABI method. @@ -1694,7 +1699,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - defaultValueFromGlobalState(args: MethodArgs<'default_value_from_global_state(uint64)uint64'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_global_state(uint64)uint64'>]> + defaultValueFromGlobalState(args: MethodArgs<'default_value_from_global_state(uint64)uint64'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_global_state(uint64)uint64'>]> /** * Calls the default_value_from_local_state(string)string ABI method. @@ -1703,7 +1708,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - defaultValueFromLocalState(args: MethodArgs<'default_value_from_local_state(string)string'>, params?: AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_local_state(string)string'>]> + defaultValueFromLocalState(args: MethodArgs<'default_value_from_local_state(string)string'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, MethodReturn<'default_value_from_local_state(string)string'>]> /** * Gets available update methods @@ -1715,7 +1720,7 @@ export type StateAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & AppClientCompilationParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> /** * Updates an existing instance of the StateApp smart contract using the update_abi(string)string ABI method. * @@ -1723,7 +1728,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - updateAbi(args: MethodArgs<'update_abi(string)string'>, params?: AppClientCallCoreParams & AppClientCompilationParams): StateAppComposer<[...TReturns, MethodReturn<'update_abi(string)string'>]> + updateAbi(args: MethodArgs<'update_abi(string)string'>, params?: AppClientComposeCallCoreParams & AppClientCompilationParams): StateAppComposer<[...TReturns, MethodReturn<'update_abi(string)string'>]> } /** @@ -1736,7 +1741,7 @@ export type StateAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> /** * Deletes an existing instance of the StateApp smart contract using the delete_abi(string)string ABI method. * @@ -1744,7 +1749,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - deleteAbi(args: MethodArgs<'delete_abi(string)string'>, params?: AppClientCallCoreParams): StateAppComposer<[...TReturns, MethodReturn<'delete_abi(string)string'>]> + deleteAbi(args: MethodArgs<'delete_abi(string)string'>, params?: AppClientComposeCallCoreParams): StateAppComposer<[...TReturns, MethodReturn<'delete_abi(string)string'>]> } /** @@ -1758,7 +1763,7 @@ export type StateAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - optIn(args: MethodArgs<'opt_in()void'>, params?: AppClientCallCoreParams): StateAppComposer<[...TReturns, MethodReturn<'opt_in()void'>]> + optIn(args: MethodArgs<'opt_in()void'>, params?: AppClientComposeCallCoreParams): StateAppComposer<[...TReturns, MethodReturn<'opt_in()void'>]> } /** @@ -1767,7 +1772,7 @@ export type StateAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): StateAppComposer<[...TReturns, undefined]> /** * Adds a transaction to the composer @@ -1787,7 +1792,7 @@ export type StateAppComposer = { /** * Executes the transaction group and returns the results */ - execute(): Promise> + execute(sendParams?: AppClientComposeExecuteParams): Promise> } export type SimulateOptions = Omit[0], 'txnGroups'> export type StateAppComposerSimulateResult = { diff --git a/examples/voting/client.ts b/examples/voting/client.ts index 08d2a81..619e276 100644 --- a/examples/voting/client.ts +++ b/examples/voting/client.ts @@ -24,7 +24,7 @@ import type { ApplicationClient, } from '@algorandfoundation/algokit-utils/types/app-client' import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec' -import type { SendTransactionResult, TransactionToSign, SendTransactionFrom } from '@algorandfoundation/algokit-utils/types/transaction' +import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction' import type { ABIResult, TransactionWithSigner } from 'algosdk' import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk' export const APP_SPEC: AppSpec = { @@ -299,7 +299,7 @@ export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApp */ export type IntegerState = { /** - * Gets the state value as a BigInt + * Gets the state value as a BigInt. */ asBigInt(): bigint /** @@ -324,6 +324,11 @@ export type BinaryState = { export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial & AppReference export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial +export type AppClientComposeCallCoreParams = Omit & { + sendParams?: Omit +} +export type AppClientComposeExecuteParams = Pick + /** * Defines the types of available calls and state of the VotingRoundApp smart contract. */ @@ -887,22 +892,22 @@ export class VotingRoundAppClient { let promiseChain:Promise = Promise.resolve() const resultMappers: Array any)> = [] return { - bootstrap(args: MethodArgs<'bootstrap(pay)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + bootstrap(args: MethodArgs<'bootstrap(pay)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.bootstrap(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - close(args: MethodArgs<'close()void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + close(args: MethodArgs<'close()void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.close(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this }, - getPreconditions(args: MethodArgs<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + getPreconditions(args: MethodArgs<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.getPreconditions(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(VotingPreconditions) return this }, - vote(args: MethodArgs<'vote(pay,byte[],uint8[])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs) { + vote(args: MethodArgs<'vote(pay,byte[],uint8[])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.vote(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -910,14 +915,14 @@ export class VotingRoundAppClient { get delete() { const $this = this return { - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.delete.bare({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return $this }, } }, - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) { + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) { promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}})) resultMappers.push(undefined) return this @@ -938,9 +943,9 @@ export class VotingRoundAppClient { returns: result.methodResults?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) } }, - async execute() { + async execute(sendParams?: AppClientComposeExecuteParams) { await promiseChain - const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams: {} }, client.algod) + const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod) return { ...result, returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val.returnValue) : val.returnValue) @@ -957,7 +962,7 @@ export type VotingRoundAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bootstrap(args: MethodArgs<'bootstrap(pay)void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'bootstrap(pay)void'>]> + bootstrap(args: MethodArgs<'bootstrap(pay)void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'bootstrap(pay)void'>]> /** * Calls the close()void ABI method. @@ -966,7 +971,7 @@ export type VotingRoundAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - close(args: MethodArgs<'close()void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'close()void'>]> + close(args: MethodArgs<'close()void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'close()void'>]> /** * Calls the get_preconditions(byte[])(uint64,uint64,uint64,uint64) ABI method. @@ -977,7 +982,7 @@ export type VotingRoundAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - getPreconditions(args: MethodArgs<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>, params?: AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>]> + getPreconditions(args: MethodArgs<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'get_preconditions(byte[])(uint64,uint64,uint64,uint64)'>]> /** * Calls the vote(pay,byte[],uint8[])void ABI method. @@ -986,7 +991,7 @@ export type VotingRoundAppComposer = { * @param params Any additional parameters for the call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - vote(args: MethodArgs<'vote(pay,byte[],uint8[])void'>, params?: AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'vote(pay,byte[],uint8[])void'>]> + vote(args: MethodArgs<'vote(pay,byte[],uint8[])void'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, MethodReturn<'vote(pay,byte[],uint8[])void'>]> /** * Gets available delete methods @@ -998,7 +1003,7 @@ export type VotingRoundAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - bare(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, undefined]> + bare(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, undefined]> } /** @@ -1007,7 +1012,7 @@ export type VotingRoundAppComposer = { * @param args The arguments for the bare call * @returns The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions */ - clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, undefined]> + clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): VotingRoundAppComposer<[...TReturns, undefined]> /** * Adds a transaction to the composer @@ -1027,7 +1032,7 @@ export type VotingRoundAppComposer = { /** * Executes the transaction group and returns the results */ - execute(): Promise> + execute(sendParams?: AppClientComposeExecuteParams): Promise> } export type SimulateOptions = Omit[0], 'txnGroups'> export type VotingRoundAppComposerSimulateResult = { diff --git a/package-lock.json b/package-lock.json index b1b9423..30ce70f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { - "@algorandfoundation/algokit-utils": "^5.0.0", - "algosdk": "^2.5.0", + "@algorandfoundation/algokit-utils": "^5.3.2", + "algosdk": "^2.7.0", "chalk": "^4.1.2", "change-case": "^4.1.2", "commander": "^11.0.0", @@ -57,9 +57,9 @@ } }, "node_modules/@algorandfoundation/algokit-utils": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@algorandfoundation/algokit-utils/-/algokit-utils-5.0.1.tgz", - "integrity": "sha512-+mUqrRwPvvrZjBYetH4zvEa0BPh0ph3BFP2N7RDGU2zOU2MdhKuAtNYwHVZGUzcK6bySijzww8ggwzOg4ufrVA==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/@algorandfoundation/algokit-utils/-/algokit-utils-5.3.2.tgz", + "integrity": "sha512-HBaXttZrjgHRgh4vGeD3m5l9G4jkq07A8pFVKBTf5yQqckZ7aSGSIWHGpNw6x5FDZwq3s9i9Pw4LXoen4l8Yug==", "dependencies": { "buffer": "^6.0.3" }, diff --git a/package.json b/package.json index 518f48c..b9d75eb 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "semver": "7.5.2" }, "dependencies": { - "@algorandfoundation/algokit-utils": "^5.0.0", - "algosdk": "^2.5.0", + "@algorandfoundation/algokit-utils": "^5.3.2", + "algosdk": "^2.7.0", "chalk": "^4.1.2", "change-case": "^4.1.2", "commander": "^11.0.0", @@ -134,4 +134,4 @@ "@semantic-release/github" ] } -} \ No newline at end of file +} diff --git a/src/client/call-composer-types.ts b/src/client/call-composer-types.ts index 8071e47..efb286e 100644 --- a/src/client/call-composer-types.ts +++ b/src/client/call-composer-types.ts @@ -63,7 +63,7 @@ export function* callComposerType(ctx: GeneratorContext): DocumentParts { yield* jsDoc({ description: 'Executes the transaction group and returns the results', }) - yield `execute(): Promise<${name}ComposerResults>` + yield `execute(sendParams?: AppClientComposeExecuteParams): Promise<${name}ComposerResults>` yield DecIndentAndCloseBlock yield `export type SimulateOptions = Omit[0], 'txnGroups'>` @@ -92,7 +92,7 @@ function* callComposerTypeClearState({ app, name }: GeneratorContext): DocumentP }, returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`, }) - yield `clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, undefined]>` + yield `clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, undefined]>` yield NewLine } @@ -111,7 +111,7 @@ function* callComposerTypeNoops({ app, name, callConfig, methodSignatureToUnique }, returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`, }) - yield `${methodName}(args: MethodArgs<'${methodSignature}'>, params?: AppClientCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, MethodReturn<'${methodSignature}'>]>` + yield `${methodName}(args: MethodArgs<'${methodSignature}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs): ${name}Composer<[...TReturns, MethodReturn<'${methodSignature}'>]>` yield NewLine } } @@ -137,7 +137,7 @@ function* callComposerOperationMethodType( }, returns: `The typed transaction composer so you can fluently chain multiple calls or call execute to execute all queued up transactions`, }) - yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientCallCoreParams ${ + yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${ includeCompilation ? '& AppClientCompilationParams ' : '' }& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}): ${name}Composer<[...TReturns, undefined]>` } else { @@ -152,7 +152,7 @@ function* callComposerOperationMethodType( }) yield `${makeSafeMethodIdentifier(uniqueName)}(args: MethodArgs<'${methodSig}'>, params${ onComplete?.isOptional !== false ? '?' : '' - }: AppClientCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${ + }: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${ onComplete?.type ? ` & ${onComplete.type}` : '' }): ${name}Composer<[...TReturns, MethodReturn<'${methodSig}'>]>` } diff --git a/src/client/call-composer.ts b/src/client/call-composer.ts index 1c96003..b1875fa 100644 --- a/src/client/call-composer.ts +++ b/src/client/call-composer.ts @@ -51,10 +51,10 @@ export function* composeMethod(ctx: GeneratorContext): DocumentParts { yield DecIndent yield '},' - yield `async execute() {` + yield `async execute(sendParams?: AppClientComposeExecuteParams) {` yield IncIndent yield `await promiseChain` - yield `const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams: {} }, client.algod)` + yield `const result = await algokit.sendAtomicTransactionComposer({ atc, sendParams }, client.algod)` yield `return {` yield IncIndent yield `...result,` @@ -74,7 +74,7 @@ function* callComposerNoops({ app, callConfig, methodSignatureToUniqueName }: Ge // Skip methods which don't support a no_op call config if (!callConfig.callMethods.includes(methodSignature)) continue - yield `${methodName}(args: MethodArgs<'${methodSignature}'>, params?: AppClientCallCoreParams & CoreAppCallArgs) {` + yield `${methodName}(args: MethodArgs<'${methodSignature}'>, params?: AppClientComposeCallCoreParams & CoreAppCallArgs) {` yield IncIndent yield `promiseChain = promiseChain.then(() => client.${methodName}(args, {...params, sendParams: {...params?.sendParams, skipSending: true, atc}}))` const outputTypeName = app.hints?.[methodSignature]?.structs?.output?.name @@ -86,7 +86,7 @@ function* callComposerNoops({ app, callConfig, methodSignatureToUniqueName }: Ge } function* callComposerClearState(): DocumentParts { - yield `clearState(args?: BareCallArgs & AppClientCallCoreParams & CoreAppCallArgs) {` + yield `clearState(args?: BareCallArgs & AppClientComposeCallCoreParams & CoreAppCallArgs) {` yield IncIndent yield `promiseChain = promiseChain.then(() => client.clearState({...args, sendParams: {...args?.sendParams, skipSending: true, atc}}))` yield `resultMappers.push(undefined)` @@ -110,7 +110,7 @@ function* callComposerOperationMethods( for (const methodSig of methods) { const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined if (methodSig === BARE_CALL) { - yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientCallCoreParams ${ + yield `bare(args${onComplete?.isOptional !== false ? '?' : ''}: BareCallArgs & AppClientComposeCallCoreParams ${ includeCompilation ? '& AppClientCompilationParams ' : '' }& CoreAppCallArgs${onComplete?.type ? ` & ${onComplete.type}` : ''}) {` yield IncIndent @@ -124,7 +124,7 @@ function* callComposerOperationMethods( const methodName = makeSafeMethodIdentifier(uniqueName) yield `${methodName}(args: MethodArgs<'${methodSig}'>, params${ onComplete?.isOptional !== false ? '?' : '' - }: AppClientCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${ + }: AppClientComposeCallCoreParams${includeCompilation ? ' & AppClientCompilationParams' : ''}${ onComplete?.type ? ` & ${onComplete.type}` : '' }) {` yield IncIndent diff --git a/src/client/imports.ts b/src/client/imports.ts index 209300c..f858da9 100644 --- a/src/client/imports.ts +++ b/src/client/imports.ts @@ -21,7 +21,7 @@ import type { ApplicationClient, } from '@algorandfoundation/algokit-utils/types/app-client' import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec' -import type { SendTransactionResult, TransactionToSign, SendTransactionFrom } from '@algorandfoundation/algokit-utils/types/transaction' +import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction' import type { ABIResult, TransactionWithSigner } from 'algosdk' import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk'` } diff --git a/src/client/utility-types.ts b/src/client/utility-types.ts index 41b7dbf..af6b5e2 100644 --- a/src/client/utility-types.ts +++ b/src/client/utility-types.ts @@ -1,4 +1,4 @@ -import { DecIndentAndCloseBlock, DocumentParts, IncIndent, jsDoc, NewLine } from '../output/writer' +import { DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer' export function* utilityTypes(): DocumentParts { yield* jsDoc(`Defines an onCompletionAction of 'no_op'`) @@ -15,7 +15,7 @@ export function* utilityTypes(): DocumentParts { yield* jsDoc('A state record containing a single unsigned integer') yield `export type IntegerState = {` yield IncIndent - yield* jsDoc('Gets the state value as a BigInt ') + yield* jsDoc('Gets the state value as a BigInt.') yield `asBigInt(): bigint` yield* jsDoc('Gets the state value as a number.') yield `asNumber(): number` @@ -32,6 +32,14 @@ export function* utilityTypes(): DocumentParts { yield NewLine yield `export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial & AppReference` yield `export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial` + + yield NewLine + yield `export type AppClientComposeCallCoreParams = Omit & {` + yield* indent( + `sendParams?: Omit`, + ) + yield `}` + yield `export type AppClientComposeExecuteParams = Pick` } export const OnCompleteCodeMap = {