From 3d26945a58ebfecbf6b3046dbfa7a03d1a6ca7ea Mon Sep 17 00:00:00 2001 From: Neil Campbell Date: Wed, 27 Nov 2024 14:50:25 +0800 Subject: [PATCH] fix: handle an app called App (#134) --- examples/arc56_test/client.ts | 20 ++-- examples/duplicate_structs/client.ts | 20 ++-- examples/helloworld/client.ts | 20 ++-- examples/lifecycle/client.ts | 20 ++-- examples/minimal/application.json | 68 ++++++------ examples/minimal/client.spec.ts | 4 +- examples/minimal/client.ts | 156 +++++++++++++-------------- examples/minimal/minimal.py | 2 +- examples/nested/client.ts | 20 ++-- examples/reti/client.ts | 20 ++-- examples/state/client.ts | 20 ++-- examples/voting/client.ts | 20 ++-- package.json | 4 +- src/client/app-client.ts | 12 +-- src/client/app-factory.ts | 4 +- src/client/imports.ts | 4 +- 16 files changed, 207 insertions(+), 207 deletions(-) diff --git a/examples/arc56_test/client.ts b/examples/arc56_test/client.ts index bdf9329..6ad32f7 100644 --- a/examples/arc56_test/client.ts +++ b/examples/arc56_test/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -341,7 +341,7 @@ export class Arc56TestFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `Arc56TestFactory` @@ -349,7 +349,7 @@ export class Arc56TestFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -483,22 +483,22 @@ export class Arc56TestClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `Arc56TestClient` * * @param appClient An `AppClient` instance which has been created with the Arc56Test app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `Arc56TestClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -518,7 +518,7 @@ export class Arc56TestClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new Arc56TestClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new Arc56TestClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -531,7 +531,7 @@ export class Arc56TestClient { static async fromNetwork( params: Omit ): Promise { - return new Arc56TestClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new Arc56TestClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/duplicate_structs/client.ts b/examples/duplicate_structs/client.ts index 8d85fc4..f3fb594 100644 --- a/examples/duplicate_structs/client.ts +++ b/examples/duplicate_structs/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -209,7 +209,7 @@ export class DuplicateStructsContractFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `DuplicateStructsContractFactory` @@ -217,7 +217,7 @@ export class DuplicateStructsContractFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -350,22 +350,22 @@ export class DuplicateStructsContractClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `DuplicateStructsContractClient` * * @param appClient An `AppClient` instance which has been created with the DuplicateStructsContract app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `DuplicateStructsContractClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -385,7 +385,7 @@ export class DuplicateStructsContractClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new DuplicateStructsContractClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new DuplicateStructsContractClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -398,7 +398,7 @@ export class DuplicateStructsContractClient { static async fromNetwork( params: Omit ): Promise { - return new DuplicateStructsContractClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new DuplicateStructsContractClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/helloworld/client.ts b/examples/helloworld/client.ts index 0ff4cea..bd87419 100644 --- a/examples/helloworld/client.ts +++ b/examples/helloworld/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -220,7 +220,7 @@ export class HelloWorldAppFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `HelloWorldAppFactory` @@ -228,7 +228,7 @@ export class HelloWorldAppFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -391,22 +391,22 @@ export class HelloWorldAppClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `HelloWorldAppClient` * * @param appClient An `AppClient` instance which has been created with the HelloWorldApp app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `HelloWorldAppClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -426,7 +426,7 @@ export class HelloWorldAppClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new HelloWorldAppClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new HelloWorldAppClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -439,7 +439,7 @@ export class HelloWorldAppClient { static async fromNetwork( params: Omit ): Promise { - return new HelloWorldAppClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new HelloWorldAppClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/lifecycle/client.ts b/examples/lifecycle/client.ts index ab01728..bd9e4e4 100644 --- a/examples/lifecycle/client.ts +++ b/examples/lifecycle/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -294,7 +294,7 @@ export class LifeCycleAppFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `LifeCycleAppFactory` @@ -302,7 +302,7 @@ export class LifeCycleAppFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -519,22 +519,22 @@ export class LifeCycleAppClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `LifeCycleAppClient` * * @param appClient An `AppClient` instance which has been created with the LifeCycleApp app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `LifeCycleAppClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -554,7 +554,7 @@ export class LifeCycleAppClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new LifeCycleAppClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new LifeCycleAppClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -567,7 +567,7 @@ export class LifeCycleAppClient { static async fromNetwork( params: Omit ): Promise { - return new LifeCycleAppClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new LifeCycleAppClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/minimal/application.json b/examples/minimal/application.json index 544791b..01501d1 100644 --- a/examples/minimal/application.json +++ b/examples/minimal/application.json @@ -1,38 +1,38 @@ { - "h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ZGVsZXRlXzE6CnByb3RvIDAgMAp0eG4gU2VuZGVyCmdsb2JhbCBDcmVhdG9yQWRkcmVzcwo9PQovLyB1bmF1dGhvcml6ZWQKYXNzZXJ0CnB1c2hpbnQgVE1QTF9ERUxFVEFCTEUgLy8gVE1QTF9ERUxFVEFCTEUKLy8gQ2hlY2sgYXBwIGlzIGRlbGV0YWJsZQphc3NlcnQKcmV0c3Vi", + "clear": "I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu" + }, + "state": { + "global": { + "num_byte_slices": 0, + "num_uints": 0 }, - "state": { - "global": { - "num_byte_slices": 0, - "num_uints": 0 - }, - "local": { - "num_byte_slices": 0, - "num_uints": 0 - } - }, - "schema": { - "global": { - "declared": {}, - "reserved": {} - }, - "local": { - "declared": {}, - "reserved": {} - } - }, - "contract": { - "name": "MinimalApp", - "methods": [], - "networks": {}, - "desc": "An app that has no abi methods" + "local": { + "num_byte_slices": 0, + "num_uints": 0 + } + }, + "schema": { + "global": { + "declared": {}, + "reserved": {} }, - "bare_call_config": { - "delete_application": "CALL", - "no_op": "CREATE", - "update_application": "CALL" + "local": { + "declared": {}, + "reserved": {} } -} \ No newline at end of file + }, + "contract": { + "name": "App", + "methods": [], + "networks": {}, + "desc": "An app that has no abi methods" + }, + "bare_call_config": { + "delete_application": "CALL", + "no_op": "CREATE", + "update_application": "CALL" + } +} diff --git a/examples/minimal/client.spec.ts b/examples/minimal/client.spec.ts index 30c8b64..cb8897c 100644 --- a/examples/minimal/client.spec.ts +++ b/examples/minimal/client.spec.ts @@ -1,4 +1,4 @@ -import { MinimalAppFactory } from './client' +import { AppFactory } from './client' import { test, describe, beforeEach, beforeAll } from 'vitest' import { AlgorandFixture } from '@algorandfoundation/algokit-utils/types/testing' import { setUpLocalnet } from '../../src/tests/util' @@ -16,7 +16,7 @@ describe('minimal typed client', () => { test('Can be deployed and deleted', async () => { const { algorand, testAccount } = localnet.context - const factory = algorand.client.getTypedAppFactory(MinimalAppFactory, { + const factory = algorand.client.getTypedAppFactory(AppFactory, { defaultSender: testAccount.addr, }) diff --git a/examples/minimal/client.ts b/examples/minimal/client.ts index 213f2e1..ef0be9a 100644 --- a/examples/minimal/client.ts +++ b/examples/minimal/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,13 +18,13 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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 = {"arcs":[],"name":"MinimalApp","desc":"An app that has no abi methods","structs":{},"methods":[],"state":{"schema":{"global":{"ints":0,"bytes":0},"local":{"ints":0,"bytes":0}},"keys":{"global":{},"local":{},"box":{}},"maps":{"global":{},"local":{},"box":{}}},"source":{"approval":"I3ByYWdtYSB2ZXJzaW9uIDgKaW50Y2Jsb2NrIDAgMQp0eG4gTnVtQX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Vi","clear":"I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu"},"bareActions":{"create":["NoOp"],"call":["DeleteApplication","UpdateApplication"]}} as unknown as Arc56Contract +export const APP_SPEC: Arc56Contract = {"arcs":[],"name":"App","desc":"An app that has no abi methods","structs":{},"methods":[],"state":{"schema":{"global":{"ints":0,"bytes":0},"local":{"ints":0,"bytes":0}},"keys":{"global":{},"local":{},"box":{}},"maps":{"global":{},"local":{},"box":{}}},"source":{"approval":"I3ByYWdtYSB2ZXJzaW9uIDgKaW50Y2Jsb2NrIDAgMQp0eG4gTnVtQXBwQXJncwppbnRjXzAgLy8gMAo9PQpibnogbWFpbl9sMgplcnIKbWFpbl9sMjoKdHhuIE9uQ29tcGxldGlvbgppbnRjXzAgLy8gTm9PcAo9PQpibnogbWFpbl9sOAp0eG4gT25Db21wbGV0aW9uCnB1c2hpbnQgNCAvLyBVcGRhdGVBcHBsaWNhdGlvbgo9PQpibnogbWFpbl9sNwp0eG4gT25Db21wbGV0aW9uCnB1c2hpbnQgNSAvLyBEZWxldGVBcHBsaWNhdGlvbgo9PQpibnogbWFpbl9sNgplcnIKbWFpbl9sNjoKdHhuIEFwcGxpY2F0aW9uSUQKaW50Y18wIC8vIDAKIT0KYXNzZXJ0CmNhbGxzdWIgZGVsZXRlXzEKaW50Y18xIC8vIDEKcmV0dXJuCm1haW5fbDc6CnR4biBBcHBsaWNhdGlvbklECmludGNfMCAvLyAwCiE9CmFzc2VydApjYWxsc3ViIHVwZGF0ZV8wCmludGNfMSAvLyAxCnJldHVybgptYWluX2w4Ogp0eG4gQXBwbGljYXRpb25JRAppbnRjXzAgLy8gMAo9PQphc3NlcnQKaW50Y18xIC8vIDEKcmV0dXJuCgovLyB1cGRhdGUKdXBkYXRlXzA6CnByb3RvIDAgMAp0eG4gU2VuZGVyCmdsb2JhbCBDcmVhdG9yQWRkcmVzcwo9PQovLyB1bmF1dGhvcml6ZWQKYXNzZXJ0CnB1c2hpbnQgVE1QTF9VUERBVEFCTEUgLy8gVE1QTF9VUERBVEFCTEUKLy8gQ2hlY2sgYXBwIGlzIHVwZGF0YWJsZQphc3NlcnQKcmV0c3ViCgovLyBkZWxldGUKZGVsZXRlXzE6CnByb3RvIDAgMAp0eG4gU2VuZGVyCmdsb2JhbCBDcmVhdG9yQWRkcmVzcwo9PQovLyB1bmF1dGhvcml6ZWQKYXNzZXJ0CnB1c2hpbnQgVE1QTF9ERUxFVEFCTEUgLy8gVE1QTF9ERUxFVEFCTEUKLy8gQ2hlY2sgYXBwIGlzIGRlbGV0YWJsZQphc3NlcnQKcmV0c3Vi","clear":"I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu"},"bareActions":{"create":["NoOp"],"call":["DeleteApplication","UpdateApplication"]}} as unknown as Arc56Contract /** * A state record containing binary data @@ -64,9 +64,9 @@ export type Expand = T extends (...args: infer A) => infer R /** - * The argument types for the MinimalApp contract + * The argument types for the App contract */ -export type MinimalAppArgs = { +export type AppArgs = { /** * The object representation of the arguments for each method */ @@ -82,13 +82,13 @@ export type MinimalAppArgs = { /** * The return type for each method */ -export type MinimalAppReturns = { +export type AppReturns = { } /** - * Defines the types of available calls and state of the MinimalApp smart contract. + * Defines the types of available calls and state of the App smart contract. */ -export type MinimalAppTypes = { +export type AppTypes = { /** * Maps method signatures / names to their argument and return types. */ @@ -98,11 +98,11 @@ export type MinimalAppTypes = { /** * Defines the possible abi call signatures. */ -export type MinimalAppSignatures = keyof MinimalAppTypes['methods'] +export type AppSignatures = keyof AppTypes['methods'] /** * Defines the possible abi call signatures for methods that return a non-void value. */ -export type MinimalAppNonVoidMethodSignatures = keyof MinimalAppTypes['methods'] extends infer T ? T extends keyof MinimalAppTypes['methods'] ? MethodReturn extends void ? never : T : never : never +export type AppNonVoidMethodSignatures = keyof AppTypes['methods'] extends infer T ? T extends keyof AppTypes['methods'] ? MethodReturn extends void ? never : T : never : never /** * Defines an object containing all relevant parameters for a single call to the contract. */ @@ -114,71 +114,71 @@ export type CallParams = Expand< } > /** - * Maps a method signature from the MinimalApp smart contract to the method's arguments in either tuple or struct form + * Maps a method signature from the App smart contract to the method's arguments in either tuple or struct form */ -export type MethodArgs = MinimalAppTypes['methods'][TSignature]['argsObj' | 'argsTuple'] +export type MethodArgs = AppTypes['methods'][TSignature]['argsObj' | 'argsTuple'] /** - * Maps a method signature from the MinimalApp smart contract to the method's return type + * Maps a method signature from the App smart contract to the method's return type */ -export type MethodReturn = MinimalAppTypes['methods'][TSignature]['returns'] +export type MethodReturn = AppTypes['methods'][TSignature]['returns'] /** * Defines supported create method params for this smart contract */ -export type MinimalAppCreateCallParams = +export type AppCreateCallParams = | Expand /** * Defines supported update method params for this smart contract */ -export type MinimalAppUpdateCallParams = +export type AppUpdateCallParams = | Expand & {method?: undefined} /** * Defines supported delete method params for this smart contract */ -export type MinimalAppDeleteCallParams = +export type AppDeleteCallParams = | Expand & {method?: undefined} /** * Defines arguments required for the deploy method. */ -export type MinimalAppDeployParams = Expand & { +export type AppDeployParams = Expand & { /** * 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?: MinimalAppCreateCallParams + createParams?: AppCreateCallParams /** * Update 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) */ - updateParams?: MinimalAppUpdateCallParams + updateParams?: AppUpdateCallParams /** * Delete 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) */ - deleteParams?: MinimalAppDeleteCallParams + deleteParams?: AppDeleteCallParams }> /** - * Exposes methods for constructing `AppClient` params objects for ABI calls to the MinimalApp smart contract + * Exposes methods for constructing `AppClient` params objects for ABI calls to the App smart contract */ -export abstract class MinimalAppParamsFactory { +export abstract class AppParamsFactory { } /** - * A factory to create and deploy one or more instance of the MinimalApp smart contract and to create one or more app clients to interact with those (or other) app instances + * A factory to create and deploy one or more instance of the App smart contract and to create one or more app clients to interact with those (or other) app instances */ -export class MinimalAppFactory { +export class AppFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** - * Creates a new instance of `MinimalAppFactory` + * Creates a new instance of `AppFactory` * * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -208,7 +208,7 @@ export class MinimalAppFactory { * @returns The `AppClient` */ public getAppClientById(params: AppFactoryAppClientParams) { - return new MinimalAppClient(this.appFactory.getAppClientById(params)) + return new AppClient(this.appFactory.getAppClientById(params)) } /** @@ -223,20 +223,20 @@ export class MinimalAppFactory { public async getAppClientByCreatorAndName( params: AppFactoryResolveAppClientByCreatorAndNameParams, ) { - return new MinimalAppClient(await this.appFactory.getAppClientByCreatorAndName(params)) + return new AppClient(await this.appFactory.getAppClientByCreatorAndName(params)) } /** - * Idempotently deploys the MinimalApp smart contract. + * Idempotently deploys the App 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: MinimalAppDeployParams = {}) { + public async deploy(params: AppDeployParams = {}) { const result = await this.appFactory.deploy({ ...params, }) - return { result: result.result, appClient: new MinimalAppClient(result.appClient) } + return { result: result.result, appClient: new AppClient(result.appClient) } } /** @@ -248,7 +248,7 @@ export class MinimalAppFactory { */ create: { /** - * Creates a new instance of the MinimalApp smart contract using a bare call. + * Creates a new instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The params for a create call @@ -263,7 +263,7 @@ export class MinimalAppFactory { */ deployUpdate: { /** - * Updates an existing instance of the MinimalApp smart contract using a bare call. + * Updates an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The params for a deployUpdate call @@ -278,7 +278,7 @@ export class MinimalAppFactory { */ deployDelete: { /** - * Deletes an existing instance of the MinimalApp smart contract using a bare call. + * Deletes an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The params for a deployDelete call @@ -299,7 +299,7 @@ export class MinimalAppFactory { */ create: { /** - * Creates a new instance of the MinimalApp smart contract using a bare call. + * Creates a new instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The params for a create call @@ -320,14 +320,14 @@ export class MinimalAppFactory { */ create: { /** - * Creates a new instance of the MinimalApp smart contract using a bare call. + * Creates a new instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The create result */ bare: async (params?: Expand) => { const result = await this.appFactory.send.bare.create(params) - return { result: result.result, appClient: new MinimalAppClient(result.appClient) } + return { result: result.result, appClient: new AppClient(result.appClient) } }, }, @@ -335,28 +335,28 @@ export class MinimalAppFactory { } /** - * A client to make calls to the MinimalApp smart contract + * A client to make calls to the App smart contract */ -export class MinimalAppClient { +export class AppClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** - * Creates a new instance of `MinimalAppClient` + * Creates a new instance of `AppClient` * - * @param appClient An `AppClient` instance which has been created with the MinimalApp app spec + * @param appClient An `AppClient` instance which has been created with the App app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** - * Creates a new instance of `MinimalAppClient` + * Creates a new instance of `AppClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -366,21 +366,21 @@ export class MinimalAppClient { * 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(method: TSignature, returnValue: ABIReturn | undefined) { + decodeReturnValue(method: TSignature, returnValue: ABIReturn | undefined) { return returnValue !== undefined ? getArc56ReturnValue>(returnValue, this.appClient.getABIMethod(method), APP_SPEC.structs) : undefined } /** - * Returns a new `MinimalAppClient` client, resolving the app by creator address and name + * 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). * @param params The parameters to create the app client */ - public static async fromCreatorAndName(params: Omit): Promise { - return new MinimalAppClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + public static async fromCreatorAndName(params: Omit): Promise { + return new AppClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** - * Returns an `MinimalAppClient` instance for the current network based on + * Returns an `AppClient` 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. @@ -388,8 +388,8 @@ export class MinimalAppClient { */ static async fromNetwork( params: Omit - ): Promise { - return new MinimalAppClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + ): Promise { + return new AppClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ @@ -426,7 +426,7 @@ export class MinimalAppClient { */ update: { /** - * Updates an existing instance of the MinimalApp smart contract using a bare call. + * Updates an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The update result @@ -441,7 +441,7 @@ export class MinimalAppClient { */ delete: { /** - * Deletes an existing instance of the MinimalApp smart contract using a bare call. + * Deletes an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The delete result @@ -452,7 +452,7 @@ export class MinimalAppClient { }, /** - * Makes a clear_state call to an existing instance of the MinimalApp smart contract. + * Makes a clear_state call to an existing instance of the App smart contract. * * @param params The params for the bare (raw) call * @returns The clearState result @@ -472,7 +472,7 @@ export class MinimalAppClient { */ update: { /** - * Updates an existing instance of the MinimalApp smart contract using a bare call. + * Updates an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The update result @@ -487,7 +487,7 @@ export class MinimalAppClient { */ delete: { /** - * Deletes an existing instance of the MinimalApp smart contract using a bare call. + * Deletes an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The delete result @@ -498,7 +498,7 @@ export class MinimalAppClient { }, /** - * Makes a clear_state call to an existing instance of the MinimalApp smart contract. + * Makes a clear_state call to an existing instance of the App smart contract. * * @param params The params for the bare (raw) call * @returns The clearState result @@ -518,7 +518,7 @@ export class MinimalAppClient { */ update: { /** - * Updates an existing instance of the MinimalApp smart contract using a bare call. + * Updates an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The update result @@ -533,7 +533,7 @@ export class MinimalAppClient { */ delete: { /** - * Deletes an existing instance of the MinimalApp smart contract using a bare call. + * Deletes an existing instance of the App smart contract using a bare call. * * @param params The params for the bare (raw) call * @returns The delete result @@ -544,7 +544,7 @@ export class MinimalAppClient { }, /** - * Makes a clear_state call to an existing instance of the MinimalApp smart contract. + * Makes a clear_state call to an existing instance of the App smart contract. * * @param params The params for the bare (raw) call * @returns The clearState result @@ -562,16 +562,16 @@ export class MinimalAppClient { * @returns A new app client with the altered params */ public clone(params: CloneAppClientParams) { - return new MinimalAppClient(this.appClient.clone(params)) + return new AppClient(this.appClient.clone(params)) } /** - * Methods to access state for the current MinimalApp app + * Methods to access state for the current App app */ state = { } - public newGroup(): MinimalAppComposer { + public newGroup(): AppComposer { const client = this const composer = this.algorand.newGroup() let promiseChain:Promise = Promise.resolve() @@ -594,7 +594,7 @@ export class MinimalAppClient { } }, /** - * Add a clear state call to the MinimalApp contract + * Add a clear state call to the App contract */ clearState(params: AppClientBareCallParams) { promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params))) @@ -624,30 +624,30 @@ export class MinimalAppClient { returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i]!(val) : val.returnValue) } } - } as unknown as MinimalAppComposer + } as unknown as AppComposer } } -export type MinimalAppComposer = { +export type AppComposer = { /** * Gets available delete methods */ readonly delete: { /** - * Deletes an existing instance of the MinimalApp smart contract using a bare call. + * Deletes an existing instance of the App smart contract using a bare call. * * @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(params?: AppClientBareCallParams ): MinimalAppComposer<[...TReturns, undefined]> + bare(params?: AppClientBareCallParams ): AppComposer<[...TReturns, undefined]> } /** - * Makes a clear_state call to an existing instance of the MinimalApp smart contract. + * Makes a clear_state call to an existing instance of the App 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): MinimalAppComposer<[...TReturns, undefined]> + clearState(params?: AppClientBareCallParams): AppComposer<[...TReturns, undefined]> /** * Adds a transaction to the composer @@ -655,7 +655,7 @@ export type MinimalAppComposer = { * @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): MinimalAppComposer + addTransaction(txn: Transaction, signer?: TransactionSigner): AppComposer /** * Returns the underlying AtomicTransactionComposer instance */ @@ -663,13 +663,13 @@ export type MinimalAppComposer = { /** * Simulates the transaction group and returns the result */ - simulate(options?: SimulateOptions): Promise & { simulateResponse: SimulateResponse }> + simulate(options?: SimulateOptions): Promise & { simulateResponse: SimulateResponse }> /** * Sends the transaction group to the network and returns the results */ - send(params?: SendParams): Promise> + send(params?: SendParams): Promise> } -export type MinimalAppComposerResults = Expand = Expand diff --git a/examples/minimal/minimal.py b/examples/minimal/minimal.py index c5ac1bf..7c222bf 100644 --- a/examples/minimal/minimal.py +++ b/examples/minimal/minimal.py @@ -6,7 +6,7 @@ ) app = ( - beaker.Application("MinimalApp", descr="An app that has no abi methods") + beaker.Application("App", descr="An app that has no abi methods") .apply(deploy_time_immutability_control) .apply(deploy_time_permanence_control) ) diff --git a/examples/nested/client.ts b/examples/nested/client.ts index 4a48487..d1191d9 100644 --- a/examples/nested/client.ts +++ b/examples/nested/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -224,7 +224,7 @@ export class NestedContractFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `NestedContractFactory` @@ -232,7 +232,7 @@ export class NestedContractFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -365,22 +365,22 @@ export class NestedContractClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `NestedContractClient` * * @param appClient An `AppClient` instance which has been created with the NestedContract app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `NestedContractClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -400,7 +400,7 @@ export class NestedContractClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new NestedContractClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new NestedContractClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -413,7 +413,7 @@ export class NestedContractClient { static async fromNetwork( params: Omit ): Promise { - return new NestedContractClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new NestedContractClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/reti/client.ts b/examples/reti/client.ts index 5faa339..9519c53 100644 --- a/examples/reti/client.ts +++ b/examples/reti/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -1440,7 +1440,7 @@ export class ValidatorRegistryFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `ValidatorRegistryFactory` @@ -1448,7 +1448,7 @@ export class ValidatorRegistryFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -1582,22 +1582,22 @@ export class ValidatorRegistryClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `ValidatorRegistryClient` * * @param appClient An `AppClient` instance which has been created with the ValidatorRegistry app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `ValidatorRegistryClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -1617,7 +1617,7 @@ export class ValidatorRegistryClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new ValidatorRegistryClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new ValidatorRegistryClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -1630,7 +1630,7 @@ export class ValidatorRegistryClient { static async fromNetwork( params: Omit ): Promise { - return new ValidatorRegistryClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new ValidatorRegistryClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/state/client.ts b/examples/state/client.ts index 5dca924..0314469 100644 --- a/examples/state/client.ts +++ b/examples/state/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -733,7 +733,7 @@ export class StateAppFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `StateAppFactory` @@ -741,7 +741,7 @@ export class StateAppFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -953,22 +953,22 @@ export class StateAppClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `StateAppClient` * * @param appClient An `AppClient` instance which has been created with the StateApp app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `StateAppClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -988,7 +988,7 @@ export class StateAppClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new StateAppClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new StateAppClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -1001,7 +1001,7 @@ export class StateAppClient { static async fromNetwork( params: Omit ): Promise { - return new StateAppClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new StateAppClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/examples/voting/client.ts b/examples/voting/client.ts index fbce0cf..9b2645d 100644 --- a/examples/voting/client.ts +++ b/examples/voting/client.ts @@ -8,7 +8,7 @@ import { AlgorandClientInterface } from '@algorandfoundation/algokit-utils/types import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -18,7 +18,7 @@ import { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' -import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' +import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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' @@ -392,7 +392,7 @@ export class VotingRoundAppFactory { /** * The underlying `AppFactory` for when you want to have more flexibility */ - public readonly appFactory: AppFactory + public readonly appFactory: _AppFactory /** * Creates a new instance of `VotingRoundAppFactory` @@ -400,7 +400,7 @@ export class VotingRoundAppFactory { * @param params The parameters to initialise the app factory with */ constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) @@ -549,22 +549,22 @@ export class VotingRoundAppClient { /** * The underlying `AppClient` for when you want to have more flexibility */ - public readonly appClient: AppClient + public readonly appClient: _AppClient /** * Creates a new instance of `VotingRoundAppClient` * * @param appClient An `AppClient` instance which has been created with the VotingRoundApp app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of `VotingRoundAppClient` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -584,7 +584,7 @@ export class VotingRoundAppClient { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise { - return new VotingRoundAppClient(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new VotingRoundAppClient(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -597,7 +597,7 @@ export class VotingRoundAppClient { static async fromNetwork( params: Omit ): Promise { - return new VotingRoundAppClient(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new VotingRoundAppClient(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/package.json b/package.json index b1ff278..8a270ea 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "module": "index.mjs", "private": false, "engines": { - "node": ">=18.0" + "node": ">=20.0" }, "type": "commonjs", "scripts": { @@ -167,4 +167,4 @@ "@semantic-release/github" ] } -} \ No newline at end of file +} diff --git a/src/client/app-client.ts b/src/client/app-client.ts index afe3baa..11bb3c8 100644 --- a/src/client/app-client.ts +++ b/src/client/app-client.ts @@ -14,7 +14,7 @@ export function* appClient(ctx: GeneratorContext): DocumentParts { yield `export class ${name}Client {` yield IncIndent yield* jsDoc(`The underlying \`AppClient\` for when you want to have more flexibility`) - yield 'public readonly appClient: AppClient' + yield 'public readonly appClient: _AppClient' yield NewLine yield ` @@ -23,15 +23,15 @@ export function* appClient(ctx: GeneratorContext): DocumentParts { * * @param appClient An \`AppClient\` instance which has been created with the ${name} app spec */ - constructor(appClient: AppClient) + constructor(appClient: _AppClient) /** * Creates a new instance of \`${name}Client\` * * @param params The parameters to initialise the app client with */ constructor(params: Omit) - constructor(appClientOrParams: AppClient | Omit) { - this.appClient = appClientOrParams instanceof AppClient ? appClientOrParams : new AppClient({ + constructor(appClientOrParams: _AppClient | Omit) { + this.appClient = appClientOrParams instanceof _AppClient ? appClientOrParams : new _AppClient({ ...appClientOrParams, appSpec: APP_SPEC, }) @@ -51,7 +51,7 @@ export function* appClient(ctx: GeneratorContext): DocumentParts { * @param params The parameters to create the app client */ public static async fromCreatorAndName(params: Omit): Promise<${name}Client> { - return new ${name}Client(await AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) + return new ${name}Client(await _AppClient.fromCreatorAndName({...params, appSpec: APP_SPEC})) } /** @@ -64,7 +64,7 @@ export function* appClient(ctx: GeneratorContext): DocumentParts { static async fromNetwork( params: Omit ): Promise<${name}Client> { - return new ${name}Client(await AppClient.fromNetwork({...params, appSpec: APP_SPEC})) + return new ${name}Client(await _AppClient.fromNetwork({...params, appSpec: APP_SPEC})) } /** The ID of the app instance this client is linked to. */ diff --git a/src/client/app-factory.ts b/src/client/app-factory.ts index 2e1cad1..a84344e 100644 --- a/src/client/app-factory.ts +++ b/src/client/app-factory.ts @@ -14,7 +14,7 @@ export function* appFactory(ctx: GeneratorContext): DocumentParts { yield `export class ${name}Factory {` yield IncIndent yield* jsDoc(`The underlying \`AppFactory\` for when you want to have more flexibility`) - yield 'public readonly appFactory: AppFactory' + yield 'public readonly appFactory: _AppFactory' yield NewLine yield* jsDoc({ @@ -26,7 +26,7 @@ export function* appFactory(ctx: GeneratorContext): DocumentParts { yield ` constructor(params: Omit) { - this.appFactory = new AppFactory({ + this.appFactory = new _AppFactory({ ...params, appSpec: APP_SPEC, }) diff --git a/src/client/imports.ts b/src/client/imports.ts index 984fcbe..08e7890 100644 --- a/src/client/imports.ts +++ b/src/client/imports.ts @@ -6,7 +6,7 @@ export function* imports(): DocumentParts { import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app' import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56' import { - AppClient, + AppClient as _AppClient, AppClientMethodCallParams, AppClientParams, AppClientBareCallParams, @@ -16,7 +16,7 @@ export function* imports(): DocumentParts { ResolveAppClientByNetwork, CloneAppClientParams, } from '@algorandfoundation/algokit-utils/types/app-client' - import { AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' + import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory' import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions } 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'