generate client

This commit is contained in:
SaraJane
2026-01-19 23:13:13 +00:00
parent cdf35e058d
commit 4be7c60810
2 changed files with 582 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types
import { useWallet } from '@txnlab/use-wallet-react' import { useWallet } from '@txnlab/use-wallet-react'
import { useSnackbar } from 'notistack' import { useSnackbar } from 'notistack'
import { useState } from 'react' import { useState } from 'react'
import { HelloWorldFactory } from '../../TokenizeRWATemplate-contracts/smart_contracts/artifacts/hello_world/HelloWorldClient' import { HelloWorldFactory } from '../contracts/HelloWorldClient'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs' import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
interface AppCallsInterface { interface AppCallsInterface {

View File

@ -0,0 +1,581 @@
/* eslint-disable */
/**
* This file was automatically generated by @algorandfoundation/algokit-client-generator.
* DO NOT MODIFY IT BY HAND.
* requires: @algorandfoundation/algokit-utils: ^7
*/
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'
import {
AppClient as _AppClient,
AppClientMethodCallParams,
AppClientParams,
AppClientBareCallParams,
CallOnComplete,
AppClientCompilationParams,
ResolveAppClientByCreatorAndName,
ResolveAppClientByNetwork,
CloneAppClientParams,
} from '@algorandfoundation/algokit-utils/types/app-client'
import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
import SimulateResponse = modelsv2.SimulateResponse
export const APP_SPEC: Arc56Contract = {"name":"HelloWorld","structs":{},"methods":[{"name":"hello","args":[{"type":"string","name":"name"}],"returns":{"type":"string"},"actions":{"create":[],"call":["NoOp"]},"readonly":false,"events":[],"recommendations":{}}],"arcs":[22,28],"networks":{},"state":{"schema":{"global":{"ints":0,"bytes":0},"local":{"ints":0,"bytes":0}},"keys":{"global":{},"local":{},"box":{}},"maps":{"global":{},"local":{},"box":{}}},"bareActions":{"create":["NoOp"],"call":[]},"sourceInfo":{"approval":{"sourceInfo":[{"pc":[37],"errorMessage":"OnCompletion must be NoOp && can only call when creating"},{"pc":[26],"errorMessage":"OnCompletion must be NoOp && can only call when not creating"},{"pc":[47],"errorMessage":"invalid array length header"},{"pc":[55],"errorMessage":"invalid number of bytes for arc4.dynamic_array<arc4.uint8>"}],"pcOffsetMethod":"none"},"clear":{"sourceInfo":[],"pcOffsetMethod":"none"}},"source":{"approval":"I3ByYWdtYSB2ZXJzaW9uIDExCiNwcmFnbWEgdHlwZXRyYWNrIGZhbHNlCgovLyBAYWxnb3JhbmRmb3VuZGF0aW9uL2FsZ29yYW5kLXR5cGVzY3JpcHQvYXJjNC9pbmRleC5kLnRzOjpDb250cmFjdC5hcHByb3ZhbFByb2dyYW0oKSAtPiB1aW50NjQ6Cm1haW46CiAgICAvLyBzbWFydF9jb250cmFjdHMvaGVsbG9fd29ybGQvY29udHJhY3QuYWxnby50czozCiAgICAvLyBleHBvcnQgY2xhc3MgSGVsbG9Xb3JsZCBleHRlbmRzIENvbnRyYWN0IHsKICAgIHR4biBOdW1BcHBBcmdzCiAgICBieiBtYWluX19fYWxnb3RzX18uZGVmYXVsdENyZWF0ZUA1CiAgICB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6Cm1haW46CiAgICBwdXNoaW50IDEgLy8gMQogICAgcmV0dXJuCg=="},"byteCode":{"approval":"CzEbQQAYgAQCvs4RNhoAjgEAAQAxGRQxGBBEQgALMRkUMRgUEESBAUM2GgFJgQBZgQIISwEVEkRXAgCAB0hlbGxvLCBMUEkVFlcGAkxQgAQVH3x1TFCwgQFD","clear":"C4EBQw=="},"compilerInfo":{"compiler":"puya","compilerVersion":{"major":5,"minor":3,"patch":2}},"events":[],"templateVariables":{}} as unknown as Arc56Contract
/**
* A state record containing binary data
*/
export interface BinaryState {
/**
* Gets the state value as a Uint8Array
*/
asByteArray(): Uint8Array | undefined
/**
* Gets the state value as a string
*/
asString(): string | undefined
}
class BinaryStateValue implements BinaryState {
constructor(private value: Uint8Array | undefined) {}
asByteArray(): Uint8Array | undefined {
return this.value
}
asString(): string | undefined {
return this.value !== undefined ? Buffer.from(this.value).toString('utf-8') : undefined
}
}
/**
* Expands types for IntelliSense so they are more human readable
* See https://stackoverflow.com/a/69288824
*/
export type Expand<T> = T extends (...args: infer A) => infer R
? (...args: Expand<A>) => Expand<R>
: T extends infer O
? { [K in keyof O]: O[K] }
: never
/**
* The argument types for the HelloWorld contract
*/
export type HelloWorldArgs = {
/**
* The object representation of the arguments for each method
*/
obj: {
'hello(string)string': {
name: string
}
}
/**
* The tuple representation of the arguments for each method
*/
tuple: {
'hello(string)string': [name: string]
}
}
/**
* The return type for each method
*/
export type HelloWorldReturns = {
'hello(string)string': string
}
/**
* Defines the types of available calls and state of the HelloWorld smart contract.
*/
export type HelloWorldTypes = {
/**
* Maps method signatures / names to their argument and return types.
*/
methods:
& Record<'hello(string)string' | 'hello', {
argsObj: HelloWorldArgs['obj']['hello(string)string']
argsTuple: HelloWorldArgs['tuple']['hello(string)string']
returns: HelloWorldReturns['hello(string)string']
}>
}
/**
* Defines the possible abi call signatures.
*/
export type HelloWorldSignatures = keyof HelloWorldTypes['methods']
/**
* Defines the possible abi call signatures for methods that return a non-void value.
*/
export type HelloWorldNonVoidMethodSignatures = keyof HelloWorldTypes['methods'] extends infer T ? T extends keyof HelloWorldTypes['methods'] ? MethodReturn<T> extends void ? never : T : never : never
/**
* Defines an object containing all relevant parameters for a single call to the contract.
*/
export type CallParams<TArgs> = Expand<
Omit<AppClientMethodCallParams, 'method' | 'args' | 'onComplete'> &
{
/** The args for the ABI method call, either as an ordered array or an object */
args: Expand<TArgs>
}
>
/**
* Maps a method signature from the HelloWorld smart contract to the method's arguments in either tuple or struct form
*/
export type MethodArgs<TSignature extends HelloWorldSignatures> = HelloWorldTypes['methods'][TSignature]['argsObj' | 'argsTuple']
/**
* Maps a method signature from the HelloWorld smart contract to the method's return type
*/
export type MethodReturn<TSignature extends HelloWorldSignatures> = HelloWorldTypes['methods'][TSignature]['returns']
/**
* Defines supported create method params for this smart contract
*/
export type HelloWorldCreateCallParams =
| Expand<AppClientBareCallParams & {method?: never} & {onComplete?: OnApplicationComplete.NoOpOC} & CreateSchema>
/**
* Defines arguments required for the deploy method.
*/
export type HelloWorldDeployParams = Expand<Omit<AppFactoryDeployParams, 'createParams' | 'updateParams' | 'deleteParams'> & {
/**
* Create transaction parameters to use if a create needs to be issued as part of deployment; use `method` to define ABI call (if available) or leave out for a bare call (if available)
*/
createParams?: HelloWorldCreateCallParams
}>
/**
* Exposes methods for constructing `AppClient` params objects for ABI calls to the HelloWorld smart contract
*/
export abstract class HelloWorldParamsFactory {
/**
* Constructs a no op call for the hello(string)string ABI method
*
* @param params Parameters for the call
* @returns An `AppClientMethodCallParams` object for the call
*/
static hello(params: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']> & CallOnComplete): AppClientMethodCallParams & CallOnComplete {
return {
...params,
method: 'hello(string)string' as const,
args: Array.isArray(params.args) ? params.args : [params.args.name],
}
}
}
/**
* A factory to create and deploy one or more instance of the HelloWorld smart contract and to create one or more app clients to interact with those (or other) app instances
*/
export class HelloWorldFactory {
/**
* The underlying `AppFactory` for when you want to have more flexibility
*/
public readonly appFactory: _AppFactory
/**
* Creates a new instance of `HelloWorldFactory`
*
* @param params The parameters to initialise the app factory with
*/
constructor(params: Omit<AppFactoryParams, 'appSpec'>) {
this.appFactory = new _AppFactory({
...params,
appSpec: APP_SPEC,
})
}
/** The name of the app (from the ARC-32 / ARC-56 app spec or override). */
public get appName() {
return this.appFactory.appName
}
/** The ARC-56 app spec being used */
get appSpec() {
return APP_SPEC
}
/** A reference to the underlying `AlgorandClient` this app factory is using. */
public get algorand(): AlgorandClient {
return this.appFactory.algorand
}
/**
* Returns a new `AppClient` client for an app instance of the given ID.
*
* Automatically populates appName, defaultSender and source maps from the factory
* if not specified in the params.
* @param params The parameters to create the app client
* @returns The `AppClient`
*/
public getAppClientById(params: AppFactoryAppClientParams) {
return new HelloWorldClient(this.appFactory.getAppClientById(params))
}
/**
* Returns a new `AppClient` client, resolving the app by creator address and name
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
*
* Automatically populates appName, defaultSender and source maps from the factory
* if not specified in the params.
* @param params The parameters to create the app client
* @returns The `AppClient`
*/
public async getAppClientByCreatorAndName(
params: AppFactoryResolveAppClientByCreatorAndNameParams,
) {
return new HelloWorldClient(await this.appFactory.getAppClientByCreatorAndName(params))
}
/**
* Idempotently deploys the HelloWorld smart contract.
*
* @param params The arguments for the contract calls and any additional parameters for the call
* @returns The deployment result
*/
public async deploy(params: HelloWorldDeployParams = {}) {
const result = await this.appFactory.deploy({
...params,
})
return { result: result.result, appClient: new HelloWorldClient(result.appClient) }
}
/**
* Get parameters to create transactions (create and deploy related calls) for the current app. A good mental model for this is that these parameters represent a deferred transaction creation.
*/
readonly params = {
/**
* Gets available create methods
*/
create: {
/**
* Creates a new instance of the HelloWorld smart contract using a bare call.
*
* @param params The params for the bare (raw) call
* @returns The params for a create call
*/
bare: (params?: Expand<AppClientBareCallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}>) => {
return this.appFactory.params.bare.create(params)
},
},
}
/**
* Create transactions for the current app
*/
readonly createTransaction = {
/**
* Gets available create methods
*/
create: {
/**
* Creates a new instance of the HelloWorld smart contract using a bare call.
*
* @param params The params for the bare (raw) call
* @returns The transaction for a create call
*/
bare: (params?: Expand<AppClientBareCallParams & AppClientCompilationParams & CreateSchema & {onComplete?: OnApplicationComplete.NoOpOC}>) => {
return this.appFactory.createTransaction.bare.create(params)
},
},
}
/**
* Send calls to the current app
*/
readonly send = {
/**
* Gets available create methods
*/
create: {
/**
* Creates a new instance of the HelloWorld smart contract using a bare call.
*
* @param params The params for the bare (raw) call
* @returns The create result
*/
bare: async (params?: Expand<AppClientBareCallParams & AppClientCompilationParams & CreateSchema & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}>) => {
const result = await this.appFactory.send.bare.create(params)
return { result: result.result, appClient: new HelloWorldClient(result.appClient) }
},
},
}
}
/**
* A client to make calls to the HelloWorld smart contract
*/
export class HelloWorldClient {
/**
* The underlying `AppClient` for when you want to have more flexibility
*/
public readonly appClient: _AppClient
/**
* Creates a new instance of `HelloWorldClient`
*
* @param appClient An `AppClient` instance which has been created with the HelloWorld app spec
*/
constructor(appClient: _AppClient)
/**
* Creates a new instance of `HelloWorldClient`
*
* @param params The parameters to initialise the app client with
*/
constructor(params: Omit<AppClientParams, 'appSpec'>)
constructor(appClientOrParams: _AppClient | Omit<AppClientParams, 'appSpec'>) {
this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({
...appClientOrParams,
appSpec: APP_SPEC,
})
}
/**
* Checks for decode errors on the given return value and maps the return value to the return type for the given method
* @returns The typed return value or undefined if there was no value
*/
decodeReturnValue<TSignature extends HelloWorldNonVoidMethodSignatures>(method: TSignature, returnValue: ABIReturn | undefined) {
return returnValue !== undefined ? getArc56ReturnValue<MethodReturn<TSignature>>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined
}
/**
* Returns a new `HelloWorldClient` client, resolving the app by creator address and name
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
* @param params The parameters to create the app client
*/
public static async fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<HelloWorldClient> {
return new HelloWorldClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC}))
}
/**
* Returns an `HelloWorldClient` instance for the current network based on
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
*
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
* @param params The parameters to create the app client
*/
static async fromNetwork(
params: Omit<ResolveAppClientByNetwork, 'appSpec'>
): Promise<HelloWorldClient> {
return new HelloWorldClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC}))
}
/** The ID of the app instance this client is linked to. */
public get appId() {
return this.appClient.appId
}
/** The app address of the app instance this client is linked to. */
public get appAddress() {
return this.appClient.appAddress
}
/** The name of the app. */
public get appName() {
return this.appClient.appName
}
/** The ARC-56 app spec being used */
public get appSpec() {
return this.appClient.appSpec
}
/** A reference to the underlying `AlgorandClient` this app client is using. */
public get algorand(): AlgorandClient {
return this.appClient.algorand
}
/**
* Get parameters to create transactions for the current app. A good mental model for this is that these parameters represent a deferred transaction creation.
*/
readonly params = {
/**
* Makes a clear_state call to an existing instance of the HelloWorld smart contract.
*
* @param params The params for the bare (raw) call
* @returns The clearState result
*/
clearState: (params?: Expand<AppClientBareCallParams>) => {
return this.appClient.params.bare.clearState(params)
},
/**
* Makes a call to the HelloWorld smart contract using the `hello(string)string` ABI method.
*
* @param params The params for the smart contract call
* @returns The call params
*/
hello: (params: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']> & {onComplete?: OnApplicationComplete.NoOpOC}) => {
return this.appClient.params.call(HelloWorldParamsFactory.hello(params))
},
}
/**
* Create transactions for the current app
*/
readonly createTransaction = {
/**
* Makes a clear_state call to an existing instance of the HelloWorld smart contract.
*
* @param params The params for the bare (raw) call
* @returns The clearState result
*/
clearState: (params?: Expand<AppClientBareCallParams>) => {
return this.appClient.createTransaction.bare.clearState(params)
},
/**
* Makes a call to the HelloWorld smart contract using the `hello(string)string` ABI method.
*
* @param params The params for the smart contract call
* @returns The call transaction
*/
hello: (params: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']> & {onComplete?: OnApplicationComplete.NoOpOC}) => {
return this.appClient.createTransaction.call(HelloWorldParamsFactory.hello(params))
},
}
/**
* Send calls to the current app
*/
readonly send = {
/**
* Makes a clear_state call to an existing instance of the HelloWorld smart contract.
*
* @param params The params for the bare (raw) call
* @returns The clearState result
*/
clearState: (params?: Expand<AppClientBareCallParams & SendParams>) => {
return this.appClient.send.bare.clearState(params)
},
/**
* Makes a call to the HelloWorld smart contract using the `hello(string)string` ABI method.
*
* @param params The params for the smart contract call
* @returns The call result
*/
hello: async (params: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']> & SendParams & {onComplete?: OnApplicationComplete.NoOpOC}) => {
const result = await this.appClient.send.call(HelloWorldParamsFactory.hello(params))
return {...result, return: result.return as unknown as (undefined | HelloWorldReturns['hello(string)string'])}
},
}
/**
* Clone this app client with different params
*
* @param params 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.
* @returns A new app client with the altered params
*/
public clone(params: CloneAppClientParams) {
return new HelloWorldClient(this.appClient.clone(params))
}
/**
* Methods to access state for the current HelloWorld app
*/
state = {
}
public newGroup(): HelloWorldComposer {
const client = this
const composer = this.algorand.newGroup()
let promiseChain:Promise<unknown> = Promise.resolve()
const resultMappers: Array<undefined | ((x: ABIReturn | undefined) => any)> = []
return {
/**
* Add a hello(string)string method call against the HelloWorld contract
*/
hello(params: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']> & {onComplete?: OnApplicationComplete.NoOpOC}) {
promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.hello(params)))
resultMappers.push((v) => client.decodeReturnValue('hello(string)string', v))
return this
},
/**
* Add a clear state call to the HelloWorld contract
*/
clearState(params: AppClientBareCallParams) {
promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)))
return this
},
addTransaction(txn: Transaction, signer?: TransactionSigner) {
promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer))
return this
},
async composer() {
await promiseChain
return composer
},
async simulate(options?: SimulateOptions) {
await promiseChain
const result = await (!options ? composer.simulate() : composer.simulate(options))
return {
...result,
returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)
}
},
async send(params?: SendParams) {
await promiseChain
const result = await composer.send(params)
return {
...result,
returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue)
}
}
} as unknown as HelloWorldComposer
}
}
export type HelloWorldComposer<TReturns extends [...any[]] = []> = {
/**
* Calls the hello(string)string ABI method.
*
* @param args The arguments for the contract call
* @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(params?: CallParams<HelloWorldArgs['obj']['hello(string)string'] | HelloWorldArgs['tuple']['hello(string)string']>): HelloWorldComposer<[...TReturns, HelloWorldReturns['hello(string)string'] | undefined]>
/**
* Makes a clear_state call to an existing instance of the HelloWorld smart contract.
*
* @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(params?: AppClientBareCallParams): HelloWorldComposer<[...TReturns, undefined]>
/**
* Adds a transaction to the composer
*
* @param txn A transaction to add to the transaction group
* @param signer The optional signer to use when signing this transaction.
*/
addTransaction(txn: Transaction, signer?: TransactionSigner): HelloWorldComposer<TReturns>
/**
* Returns the underlying AtomicTransactionComposer instance
*/
composer(): Promise<TransactionComposer>
/**
* Simulates the transaction group and returns the result
*/
simulate(): Promise<HelloWorldComposerResults<TReturns> & { simulateResponse: SimulateResponse }>
simulate(options: SkipSignaturesSimulateOptions): Promise<HelloWorldComposerResults<TReturns> & { simulateResponse: SimulateResponse }>
simulate(options: RawSimulateOptions): Promise<HelloWorldComposerResults<TReturns> & { simulateResponse: SimulateResponse }>
/**
* Sends the transaction group to the network and returns the results
*/
send(params?: SendParams): Promise<HelloWorldComposerResults<TReturns>>
}
export type HelloWorldComposerResults<TReturns extends [...any[]]> = Expand<SendAtomicTransactionComposerResults & {
returns: TReturns
}>