Skip to content

Commit

Permalink
Merge main into release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Feb 1, 2024
2 parents 0845677 + 5103332 commit 665e09f
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 108 deletions.
35 changes: 20 additions & 15 deletions examples/helloworld/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
/**
Expand All @@ -153,6 +153,11 @@ export type BinaryState = {
export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult> & AppReference
export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult>

export type AppClientComposeCallCoreParams = Omit<AppClientCallCoreParams, 'sendParams'> & {
sendParams?: Omit<SendTransactionParams, 'skipSending' | 'atc' | 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources'>
}
export type AppClientComposeExecuteParams = Pick<SendTransactionParams, 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources' | 'suppressLog'>

/**
* Defines the types of available calls and state of the HelloWorldApp smart contract.
*/
Expand Down Expand Up @@ -516,20 +521,20 @@ export class HelloWorldAppClient {
let promiseChain:Promise<unknown> = Promise.resolve()
const resultMappers: Array<undefined | ((x: any) => 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
},
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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -588,7 +593,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
* @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.
Expand All @@ -599,7 +604,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
* @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
Expand All @@ -611,7 +616,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
* @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]>
}

/**
Expand All @@ -624,7 +629,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
* @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]>
}

/**
Expand All @@ -633,7 +638,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
* @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
Expand All @@ -653,7 +658,7 @@ export type HelloWorldAppComposer<TReturns extends [...any[]] = []> = {
/**
* Executes the transaction group and returns the results
*/
execute(): Promise<HelloWorldAppComposerResults<TReturns>>
execute(sendParams?: AppClientComposeExecuteParams): Promise<HelloWorldAppComposerResults<TReturns>>
}
export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>
export type HelloWorldAppComposerSimulateResult<TReturns extends [...any[]]> = {
Expand Down
31 changes: 18 additions & 13 deletions examples/lifecycle/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
/**
Expand All @@ -199,6 +199,11 @@ export type BinaryState = {
export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult> & AppReference
export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult>

export type AppClientComposeCallCoreParams = Omit<AppClientCallCoreParams, 'sendParams'> & {
sendParams?: Omit<SendTransactionParams, 'skipSending' | 'atc' | 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources'>
}
export type AppClientComposeExecuteParams = Pick<SendTransactionParams, 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources' | 'suppressLog'>

/**
* Defines the types of available calls and state of the LifeCycleApp smart contract.
*/
Expand Down Expand Up @@ -638,27 +643,27 @@ export class LifeCycleAppClient {
let promiseChain:Promise<unknown> = Promise.resolve()
const resultMappers: Array<undefined | ((x: any) => 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
},
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
Expand All @@ -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)
Expand All @@ -698,7 +703,7 @@ export type LifeCycleAppComposer<TReturns extends [...any[]] = []> = {
* @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.
Expand All @@ -707,7 +712,7 @@ export type LifeCycleAppComposer<TReturns extends [...any[]] = []> = {
* @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
Expand All @@ -719,7 +724,7 @@ export type LifeCycleAppComposer<TReturns extends [...any[]] = []> = {
* @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]>
}

/**
Expand All @@ -728,7 +733,7 @@ export type LifeCycleAppComposer<TReturns extends [...any[]] = []> = {
* @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
Expand All @@ -748,7 +753,7 @@ export type LifeCycleAppComposer<TReturns extends [...any[]] = []> = {
/**
* Executes the transaction group and returns the results
*/
execute(): Promise<LifeCycleAppComposerResults<TReturns>>
execute(sendParams?: AppClientComposeExecuteParams): Promise<LifeCycleAppComposerResults<TReturns>>
}
export type SimulateOptions = Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>
export type LifeCycleAppComposerSimulateResult<TReturns extends [...any[]]> = {
Expand Down
Loading

0 comments on commit 665e09f

Please sign in to comment.