@algorandfoundation/algokit-utils 7.0.0-beta.5 → 7.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -24
- package/account/account.d.ts +1 -2
- package/account/account.js.map +1 -1
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +0 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +0 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +0 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +0 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +0 -1
- package/amount.js.map +1 -1
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +0 -1
- package/app-client.js.map +1 -1
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +0 -1
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +6 -7
- package/app.js +6 -6
- package/app.js.map +1 -1
- package/app.mjs +6 -6
- package/app.mjs.map +1 -1
- package/asset.d.ts +3 -4
- package/asset.js +3 -3
- package/asset.js.map +1 -1
- package/asset.mjs +3 -3
- package/asset.mjs.map +1 -1
- package/config.d.ts +0 -1
- package/config.js.map +1 -1
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/debugging.js +4 -127
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +4 -108
- package/debugging/debugging.mjs.map +1 -1
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +0 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +6 -2
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/indexer-lookup.d.ts +0 -1
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +0 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +0 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +0 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +0 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +0 -1
- package/network-client.js.map +1 -1
- package/network-client.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/_asset.d.ts +0 -1
- package/testing/account.d.ts +0 -1
- package/testing/account.js.map +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.js +1 -1
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/indexer.d.ts +0 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +3 -4
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +1 -4
- package/transaction/transaction.js +26 -31
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +26 -31
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +1 -2
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -2
- package/transfer/transfer.js +1 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +1 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +13 -5
- package/types/account-manager.js +17 -3
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +17 -3
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +0 -1
- package/types/account.js.map +1 -1
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +0 -1
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +1 -2
- package/types/algorand-client-transaction-creator.d.ts +30 -31
- package/types/algorand-client-transaction-creator.js +30 -30
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +30 -30
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +19 -20
- package/types/algorand-client-transaction-sender.js +2 -2
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +2 -2
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +8 -9
- package/types/algorand-client.js +8 -8
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +8 -8
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +0 -1
- package/types/amount.js.map +1 -1
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +60 -38
- package/types/app-arc56.js +37 -16
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +37 -16
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +100 -75
- package/types/app-client.js +154 -101
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +154 -101
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +2 -3
- package/types/app-deployer.js +24 -24
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +24 -24
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +141 -87
- package/types/app-factory.js +106 -34
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +107 -35
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +0 -1
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +0 -1
- package/types/app-spec.js +15 -9
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +15 -9
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +0 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +3 -4
- package/types/asset-manager.js +3 -3
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -3
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +0 -1
- package/types/async-event-emitter.d.ts +23 -0
- package/types/async-event-emitter.js +55 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +53 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +30 -9
- package/types/client-manager.js +6 -0
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +6 -0
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +57 -5
- package/types/composer.js +30 -14
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +30 -14
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -102
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +0 -1
- package/types/dispenser-client.js +5 -4
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +5 -4
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +0 -1
- package/types/indexer.d.ts +0 -1
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +0 -1
- package/types/kmd-account-manager.js +2 -2
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +2 -2
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +0 -1
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +0 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +0 -1
- package/types/transaction.d.ts +4 -7
- package/types/transfer.d.ts +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -1
- package/types/urlTokenBaseHTTPClient.js +1 -1
- package/types/urlTokenBaseHTTPClient.js.map +1 -1
- package/types/urlTokenBaseHTTPClient.mjs +1 -1
- package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
- package/util.d.ts +0 -1
- package/util.js +0 -9
- package/util.js.map +1 -1
- package/util.mjs +1 -9
- package/util.mjs.map +1 -1
- package/account/account.d.ts.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/amount.d.ts.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app.d.ts.map +0 -1
- package/asset.d.ts.map +0 -1
- package/config.d.ts.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/legacy-bridge.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client-interface.d.ts.map +0 -1
- package/types/algorand-client-transaction-creator.d.ts.map +0 -1
- package/types/algorand-client-transaction-sender.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-arc56.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-deployer.d.ts.map +0 -1
- package/types/app-factory.d.ts.map +0 -1
- package/types/app-manager.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset-manager.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/expand.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/util.d.ts.map +0 -1
package/types/app-factory.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import algosdk from 'algosdk';
|
|
3
2
|
import { AlgorandClientInterface } from './algorand-client-interface';
|
|
4
3
|
import { AppReturn, SendAppTransactionResult, TealTemplateParams } from './app';
|
|
@@ -6,8 +5,9 @@ import { ABIStruct, Arc56Contract, Arc56Method } from './app-arc56';
|
|
|
6
5
|
import { AppClient, AppClientBareCallParams, AppClientCompilationParams, AppClientMethodCallParams, AppClientParams, AppSourceMaps, ResolveAppClientByCreatorAndName } from './app-client';
|
|
7
6
|
import { AppDeployParams } from './app-deployer';
|
|
8
7
|
import { AppSpec } from './app-spec';
|
|
8
|
+
import { AppMethodCall, AppMethodCallTransactionArgument } from './composer';
|
|
9
9
|
import { Expand } from './expand';
|
|
10
|
-
import {
|
|
10
|
+
import { SendParams } from './transaction';
|
|
11
11
|
import OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
12
12
|
import ABIValue = algosdk.ABIValue;
|
|
13
13
|
/** Parameters to create an app client */
|
|
@@ -76,8 +76,14 @@ export type CreateSchema = {
|
|
|
76
76
|
* This is immutable once the app is created. */
|
|
77
77
|
extraProgramPages?: number;
|
|
78
78
|
};
|
|
79
|
-
/**
|
|
80
|
-
export type AppFactoryCreateParams = Expand<
|
|
79
|
+
/** Params to specify a bare (raw) create call for an app */
|
|
80
|
+
export type AppFactoryCreateParams = Expand<AppClientBareCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema>;
|
|
81
|
+
/** Params to specify a create method call for an app */
|
|
82
|
+
export type AppFactoryCreateMethodCallParams = Expand<AppClientMethodCallParams & AppClientCompilationParams & CreateOnComplete & CreateSchema>;
|
|
83
|
+
/** Params to get an app client by ID from an app factory. */
|
|
84
|
+
export type AppFactoryAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>;
|
|
85
|
+
/** Params to get an app client by creator address and name from an app factory. */
|
|
86
|
+
export type AppFactoryResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>;
|
|
81
87
|
/** Parameters to define a deployment for an `AppFactory` */
|
|
82
88
|
export type AppFactoryDeployParams = Expand<Omit<AppDeployParams, 'createParams' | 'updateParams' | 'deleteParams' | 'metadata'> & {
|
|
83
89
|
/** Create transaction parameters to use if a create needs to be issued as part of deployment */
|
|
@@ -115,7 +121,21 @@ export declare class AppFactory {
|
|
|
115
121
|
private _clearSourceMap;
|
|
116
122
|
private _paramsMethods;
|
|
117
123
|
constructor(params: AppFactoryParams);
|
|
118
|
-
/** Get parameters to
|
|
124
|
+
/** Get parameters to create transactions (create and deploy related calls) for the current app.
|
|
125
|
+
*
|
|
126
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
127
|
+
* @example Create a transaction in the future using Algorand Client
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
130
|
+
* // ...
|
|
131
|
+
* await algorand.send.AppCreateMethodCall(createAppParams)
|
|
132
|
+
* ```
|
|
133
|
+
* @example Define a nested transaction as an ABI argument
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
136
|
+
* await appClient.send.call({method: 'my_method', args: [createAppParams]})
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
119
139
|
get params(): {
|
|
120
140
|
/** Return params for a create ABI call, including deploy-time TEAL template replacements and compilation if provided */
|
|
121
141
|
create: (params: {
|
|
@@ -136,7 +156,7 @@ export declare class AppFactory {
|
|
|
136
156
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
137
157
|
sender?: string | undefined;
|
|
138
158
|
method: string;
|
|
139
|
-
args?: (algosdk.ABIValue |
|
|
159
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
140
160
|
deployTimeParams?: TealTemplateParams | undefined;
|
|
141
161
|
updatable?: boolean | undefined;
|
|
142
162
|
deletable?: boolean | undefined;
|
|
@@ -152,10 +172,10 @@ export declare class AppFactory {
|
|
|
152
172
|
} | undefined;
|
|
153
173
|
extraProgramPages?: number | undefined;
|
|
154
174
|
}) => Promise<({
|
|
155
|
-
approvalProgram:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
compiledClear
|
|
175
|
+
approvalProgram: Uint8Array;
|
|
176
|
+
compiledApproval: undefined;
|
|
177
|
+
clearStateProgram: Uint8Array;
|
|
178
|
+
compiledClear: undefined;
|
|
159
179
|
deployTimeParams: TealTemplateParams | undefined;
|
|
160
180
|
schema: {
|
|
161
181
|
/** The number of integers saved in global state. */
|
|
@@ -184,7 +204,7 @@ export declare class AppFactory {
|
|
|
184
204
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
185
205
|
sender?: string | undefined;
|
|
186
206
|
method: string;
|
|
187
|
-
args?: (algosdk.ABIValue |
|
|
207
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
188
208
|
updatable?: boolean | undefined;
|
|
189
209
|
deletable?: boolean | undefined;
|
|
190
210
|
extraProgramPages?: number | undefined;
|
|
@@ -221,14 +241,14 @@ export declare class AppFactory {
|
|
|
221
241
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
222
242
|
sender?: string | undefined;
|
|
223
243
|
method: string;
|
|
224
|
-
args?: (algosdk.ABIValue |
|
|
244
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
225
245
|
updatable?: boolean | undefined;
|
|
226
246
|
deletable?: boolean | undefined;
|
|
227
247
|
extraProgramPages?: number | undefined;
|
|
228
248
|
}) & {
|
|
229
249
|
sender: string;
|
|
230
250
|
method: Arc56Method;
|
|
231
|
-
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> |
|
|
251
|
+
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> | AppMethodCall<{
|
|
232
252
|
lease?: string | Uint8Array | undefined;
|
|
233
253
|
note?: string | Uint8Array | undefined;
|
|
234
254
|
maxFee?: import("./amount").AlgoAmount | undefined;
|
|
@@ -255,7 +275,7 @@ export declare class AppFactory {
|
|
|
255
275
|
localByteSlices: number;
|
|
256
276
|
} | undefined;
|
|
257
277
|
extraProgramPages?: number | undefined;
|
|
258
|
-
}> |
|
|
278
|
+
}> | AppMethodCall<{
|
|
259
279
|
sender: string;
|
|
260
280
|
signer?: algosdk.TransactionSigner | import("./account").TransactionSignerAccount | undefined;
|
|
261
281
|
rekeyTo?: string | undefined;
|
|
@@ -276,7 +296,7 @@ export declare class AppFactory {
|
|
|
276
296
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
277
297
|
approvalProgram: string | Uint8Array;
|
|
278
298
|
clearStateProgram: string | Uint8Array;
|
|
279
|
-
}> |
|
|
299
|
+
}> | AppMethodCall<import("./composer").AppMethodCallParams>)[] | undefined;
|
|
280
300
|
onComplete: algosdk.OnApplicationComplete.NoOpOC | algosdk.OnApplicationComplete.OptInOC | algosdk.OnApplicationComplete.CloseOutOC | algosdk.OnApplicationComplete.UpdateApplicationOC | algosdk.OnApplicationComplete.DeleteApplicationOC;
|
|
281
301
|
}>;
|
|
282
302
|
/** Return params for a deployment update ABI call */
|
|
@@ -298,7 +318,7 @@ export declare class AppFactory {
|
|
|
298
318
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
299
319
|
sender?: string | undefined;
|
|
300
320
|
method: string;
|
|
301
|
-
args?: (algosdk.ABIValue |
|
|
321
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
302
322
|
}) => {
|
|
303
323
|
lease?: string | Uint8Array | undefined;
|
|
304
324
|
note?: string | Uint8Array | undefined;
|
|
@@ -317,11 +337,11 @@ export declare class AppFactory {
|
|
|
317
337
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
318
338
|
sender?: string | undefined;
|
|
319
339
|
method: string;
|
|
320
|
-
args?: (algosdk.ABIValue |
|
|
340
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
321
341
|
} & {
|
|
322
342
|
sender: string;
|
|
323
343
|
method: Arc56Method;
|
|
324
|
-
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> |
|
|
344
|
+
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> | AppMethodCall<{
|
|
325
345
|
lease?: string | Uint8Array | undefined;
|
|
326
346
|
note?: string | Uint8Array | undefined;
|
|
327
347
|
maxFee?: import("./amount").AlgoAmount | undefined;
|
|
@@ -348,7 +368,7 @@ export declare class AppFactory {
|
|
|
348
368
|
localByteSlices: number;
|
|
349
369
|
} | undefined;
|
|
350
370
|
extraProgramPages?: number | undefined;
|
|
351
|
-
}> |
|
|
371
|
+
}> | AppMethodCall<{
|
|
352
372
|
sender: string;
|
|
353
373
|
signer?: algosdk.TransactionSigner | import("./account").TransactionSignerAccount | undefined;
|
|
354
374
|
rekeyTo?: string | undefined;
|
|
@@ -369,7 +389,7 @@ export declare class AppFactory {
|
|
|
369
389
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
370
390
|
approvalProgram: string | Uint8Array;
|
|
371
391
|
clearStateProgram: string | Uint8Array;
|
|
372
|
-
}> |
|
|
392
|
+
}> | AppMethodCall<import("./composer").AppMethodCallParams>)[] | undefined;
|
|
373
393
|
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC;
|
|
374
394
|
};
|
|
375
395
|
/** Return params for a deployment delete ABI call */
|
|
@@ -391,7 +411,7 @@ export declare class AppFactory {
|
|
|
391
411
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
392
412
|
sender?: string | undefined;
|
|
393
413
|
method: string;
|
|
394
|
-
args?: (algosdk.ABIValue |
|
|
414
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
395
415
|
}) => {
|
|
396
416
|
lease?: string | Uint8Array | undefined;
|
|
397
417
|
note?: string | Uint8Array | undefined;
|
|
@@ -410,11 +430,11 @@ export declare class AppFactory {
|
|
|
410
430
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
411
431
|
sender?: string | undefined;
|
|
412
432
|
method: string;
|
|
413
|
-
args?: (algosdk.ABIValue |
|
|
433
|
+
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
414
434
|
} & {
|
|
415
435
|
sender: string;
|
|
416
436
|
method: Arc56Method;
|
|
417
|
-
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> |
|
|
437
|
+
args: (algosdk.Transaction | algosdk.ABIValue | algosdk.TransactionWithSigner | Promise<algosdk.Transaction> | AppMethodCall<{
|
|
418
438
|
lease?: string | Uint8Array | undefined;
|
|
419
439
|
note?: string | Uint8Array | undefined;
|
|
420
440
|
maxFee?: import("./amount").AlgoAmount | undefined;
|
|
@@ -441,7 +461,7 @@ export declare class AppFactory {
|
|
|
441
461
|
localByteSlices: number;
|
|
442
462
|
} | undefined;
|
|
443
463
|
extraProgramPages?: number | undefined;
|
|
444
|
-
}> |
|
|
464
|
+
}> | AppMethodCall<{
|
|
445
465
|
sender: string;
|
|
446
466
|
signer?: algosdk.TransactionSigner | import("./account").TransactionSignerAccount | undefined;
|
|
447
467
|
rekeyTo?: string | undefined;
|
|
@@ -462,7 +482,7 @@ export declare class AppFactory {
|
|
|
462
482
|
boxReferences?: (import("./app-manager").BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
463
483
|
approvalProgram: string | Uint8Array;
|
|
464
484
|
clearStateProgram: string | Uint8Array;
|
|
465
|
-
}> |
|
|
485
|
+
}> | AppMethodCall<import("./composer").AppMethodCallParams>)[] | undefined;
|
|
466
486
|
onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC;
|
|
467
487
|
};
|
|
468
488
|
bare: {
|
|
@@ -500,10 +520,10 @@ export declare class AppFactory {
|
|
|
500
520
|
} | undefined;
|
|
501
521
|
extraProgramPages?: number | undefined;
|
|
502
522
|
} | undefined) => Promise<({
|
|
503
|
-
approvalProgram:
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
compiledClear
|
|
523
|
+
approvalProgram: Uint8Array;
|
|
524
|
+
compiledApproval: undefined;
|
|
525
|
+
clearStateProgram: Uint8Array;
|
|
526
|
+
compiledClear: undefined;
|
|
507
527
|
deployTimeParams: TealTemplateParams | undefined;
|
|
508
528
|
schema: {
|
|
509
529
|
/** The number of integers saved in global state. */
|
|
@@ -655,44 +675,68 @@ export declare class AppFactory {
|
|
|
655
675
|
};
|
|
656
676
|
};
|
|
657
677
|
};
|
|
658
|
-
/**
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
app: AppClient;
|
|
668
|
-
result: {
|
|
669
|
-
compiledApproval?: import("./app").CompiledTeal | undefined;
|
|
670
|
-
compiledClear?: import("./app").CompiledTeal | undefined;
|
|
671
|
-
appId: bigint;
|
|
672
|
-
groupId: string;
|
|
673
|
-
txIds: string[];
|
|
674
|
-
returns?: import("./app").ABIReturn[] | undefined;
|
|
675
|
-
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
676
|
-
transactions: algosdk.Transaction[];
|
|
677
|
-
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
678
|
-
transaction: algosdk.Transaction;
|
|
679
|
-
appAddress: string;
|
|
680
|
-
return?: algosdk.ABIValue | ABIStruct | undefined;
|
|
681
|
-
} | {
|
|
682
|
-
compiledApproval?: import("./app").CompiledTeal | undefined;
|
|
683
|
-
compiledClear?: import("./app").CompiledTeal | undefined;
|
|
684
|
-
return: undefined;
|
|
685
|
-
groupId: string;
|
|
686
|
-
txIds: string[];
|
|
687
|
-
returns?: import("./app").ABIReturn[] | undefined;
|
|
688
|
-
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
678
|
+
/** Create transactions for the current app */
|
|
679
|
+
readonly createTransaction: {
|
|
680
|
+
/** Create bare (raw) transactions for the current app */
|
|
681
|
+
bare: {
|
|
682
|
+
/** Create a create call transaction, including deploy-time TEAL template replacements and compilation if provided */
|
|
683
|
+
create: (params?: AppFactoryCreateParams) => Promise<algosdk.Transaction>;
|
|
684
|
+
};
|
|
685
|
+
/** Create a create ABI call transaction, including deploy-time TEAL template replacements and compilation if provided */
|
|
686
|
+
create: (params: AppFactoryCreateMethodCallParams) => Promise<{
|
|
689
687
|
transactions: algosdk.Transaction[];
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
688
|
+
methodCalls: Map<number, algosdk.ABIMethod>;
|
|
689
|
+
signers: Map<number, algosdk.TransactionSigner>;
|
|
690
|
+
}>;
|
|
691
|
+
};
|
|
692
|
+
/** Send transactions to the current app */
|
|
693
|
+
readonly send: {
|
|
694
|
+
/** Send bare (raw) transactions for the current app */
|
|
695
|
+
bare: {
|
|
696
|
+
create: (params?: AppFactoryCreateParams & SendParams) => Promise<{
|
|
697
|
+
appClient: AppClient;
|
|
698
|
+
result: {
|
|
699
|
+
compiledApproval?: import("./app").CompiledTeal | undefined;
|
|
700
|
+
compiledClear?: import("./app").CompiledTeal | undefined;
|
|
701
|
+
return: undefined;
|
|
702
|
+
groupId: string;
|
|
703
|
+
txIds: string[];
|
|
704
|
+
returns?: import("./app").ABIReturn[] | undefined;
|
|
705
|
+
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
706
|
+
transactions: algosdk.Transaction[];
|
|
707
|
+
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
708
|
+
transaction: algosdk.Transaction;
|
|
709
|
+
appId: bigint;
|
|
710
|
+
appAddress: string;
|
|
711
|
+
};
|
|
712
|
+
}>;
|
|
694
713
|
};
|
|
695
|
-
|
|
714
|
+
/**
|
|
715
|
+
* Creates an instance of the app and returns the result of the creation
|
|
716
|
+
* transaction and an app client to interact with that app instance.
|
|
717
|
+
*
|
|
718
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
719
|
+
* @param params The parameters to create the app
|
|
720
|
+
* @returns The app client and the result of the creation transaction
|
|
721
|
+
*/
|
|
722
|
+
create: (params: AppFactoryCreateMethodCallParams & SendParams) => Promise<{
|
|
723
|
+
appClient: AppClient;
|
|
724
|
+
result: {
|
|
725
|
+
compiledApproval?: import("./app").CompiledTeal | undefined;
|
|
726
|
+
compiledClear?: import("./app").CompiledTeal | undefined;
|
|
727
|
+
appId: bigint;
|
|
728
|
+
groupId: string;
|
|
729
|
+
txIds: string[];
|
|
730
|
+
returns?: import("./app").ABIReturn[] | undefined;
|
|
731
|
+
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
732
|
+
transactions: algosdk.Transaction[];
|
|
733
|
+
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
734
|
+
transaction: algosdk.Transaction;
|
|
735
|
+
appAddress: string;
|
|
736
|
+
return?: algosdk.ABIValue | ABIStruct | undefined;
|
|
737
|
+
};
|
|
738
|
+
}>;
|
|
739
|
+
};
|
|
696
740
|
/**
|
|
697
741
|
* Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).
|
|
698
742
|
*
|
|
@@ -705,14 +749,14 @@ export declare class AppFactory {
|
|
|
705
749
|
* @returns The app client and the result of the deployment
|
|
706
750
|
*/
|
|
707
751
|
deploy(params: AppFactoryDeployParams): Promise<{
|
|
708
|
-
|
|
752
|
+
appClient: AppClient;
|
|
709
753
|
result: {
|
|
710
754
|
return: algosdk.ABIValue | ABIStruct | undefined;
|
|
711
755
|
deleteReturn: algosdk.ABIValue | ABIStruct | undefined;
|
|
712
|
-
approvalProgram:
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
compiledClear
|
|
756
|
+
approvalProgram: Uint8Array;
|
|
757
|
+
compiledApproval: undefined;
|
|
758
|
+
clearStateProgram: Uint8Array;
|
|
759
|
+
compiledClear: undefined;
|
|
716
760
|
operationPerformed: "create";
|
|
717
761
|
version: string;
|
|
718
762
|
name: string;
|
|
@@ -759,10 +803,10 @@ export declare class AppFactory {
|
|
|
759
803
|
} | {
|
|
760
804
|
return: algosdk.ABIValue | ABIStruct | undefined;
|
|
761
805
|
deleteReturn: algosdk.ABIValue | ABIStruct | undefined;
|
|
762
|
-
approvalProgram:
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
compiledClear
|
|
806
|
+
approvalProgram: Uint8Array;
|
|
807
|
+
compiledApproval: undefined;
|
|
808
|
+
clearStateProgram: Uint8Array;
|
|
809
|
+
compiledClear: undefined;
|
|
766
810
|
operationPerformed: "update";
|
|
767
811
|
appId: bigint;
|
|
768
812
|
appAddress: string;
|
|
@@ -809,10 +853,10 @@ export declare class AppFactory {
|
|
|
809
853
|
} | {
|
|
810
854
|
return: algosdk.ABIValue | ABIStruct | undefined;
|
|
811
855
|
deleteReturn: algosdk.ABIValue | ABIStruct | undefined;
|
|
812
|
-
approvalProgram:
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
compiledClear
|
|
856
|
+
approvalProgram: Uint8Array;
|
|
857
|
+
compiledApproval: undefined;
|
|
858
|
+
clearStateProgram: Uint8Array;
|
|
859
|
+
compiledClear: undefined;
|
|
816
860
|
operationPerformed: "replace";
|
|
817
861
|
version: string;
|
|
818
862
|
name: string;
|
|
@@ -861,10 +905,10 @@ export declare class AppFactory {
|
|
|
861
905
|
} | {
|
|
862
906
|
return: algosdk.ABIValue | ABIStruct | undefined;
|
|
863
907
|
deleteReturn: algosdk.ABIValue | ABIStruct | undefined;
|
|
864
|
-
approvalProgram:
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
compiledClear
|
|
908
|
+
approvalProgram: Uint8Array;
|
|
909
|
+
compiledApproval: undefined;
|
|
910
|
+
clearStateProgram: Uint8Array;
|
|
911
|
+
compiledClear: undefined;
|
|
868
912
|
operationPerformed: "nothing";
|
|
869
913
|
appId: bigint;
|
|
870
914
|
appAddress: string;
|
|
@@ -904,7 +948,7 @@ export declare class AppFactory {
|
|
|
904
948
|
* @param params The parameters to create the app client
|
|
905
949
|
* @returns The `AppClient`
|
|
906
950
|
*/
|
|
907
|
-
getAppClientById(params:
|
|
951
|
+
getAppClientById(params: AppFactoryAppClientParams): AppClient;
|
|
908
952
|
/**
|
|
909
953
|
* Returns a new `AppClient` client, resolving the app by creator address and name
|
|
910
954
|
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
@@ -914,7 +958,7 @@ export declare class AppFactory {
|
|
|
914
958
|
* @param params The parameters to create the app client
|
|
915
959
|
* @returns The `AppClient`
|
|
916
960
|
*/
|
|
917
|
-
|
|
961
|
+
getAppClientByCreatorAndName(params: AppFactoryResolveAppClientByCreatorAndNameParams): Promise<AppClient>;
|
|
918
962
|
/**
|
|
919
963
|
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
920
964
|
* error to include source code information via the source map and ARC-56 spec.
|
|
@@ -946,9 +990,20 @@ export declare class AppFactory {
|
|
|
946
990
|
*
|
|
947
991
|
* Will store any generated source maps for later use in debugging.
|
|
948
992
|
*/
|
|
949
|
-
|
|
993
|
+
compile(compilation?: AppClientCompilationParams): Promise<{
|
|
994
|
+
approvalProgram: Uint8Array;
|
|
995
|
+
compiledApproval: undefined;
|
|
996
|
+
clearStateProgram: Uint8Array;
|
|
997
|
+
compiledClear: undefined;
|
|
998
|
+
} | {
|
|
999
|
+
approvalProgram: Uint8Array;
|
|
1000
|
+
compiledApproval: import("./app").CompiledTeal;
|
|
1001
|
+
clearStateProgram: Uint8Array;
|
|
1002
|
+
compiledClear: import("./app").CompiledTeal;
|
|
1003
|
+
}>;
|
|
950
1004
|
private getBareParams;
|
|
951
1005
|
private getABIParams;
|
|
1006
|
+
private getCreateABIArgsWithDefaultValues;
|
|
952
1007
|
/** Returns the sender for a call, using the `defaultSender`
|
|
953
1008
|
* if none provided and throws an error if neither provided */
|
|
954
1009
|
private getSender;
|
|
@@ -962,6 +1017,5 @@ export declare class AppFactory {
|
|
|
962
1017
|
* @param method The method that was called
|
|
963
1018
|
* @returns The smart contract response with an updated return value
|
|
964
1019
|
*/
|
|
965
|
-
parseMethodCallReturn<TReturn extends Uint8Array | ABIValue | ABIStruct | undefined, TResult extends SendAppTransactionResult = SendAppTransactionResult>(result: Promise<TResult> | TResult, method: Arc56Method): Promise<
|
|
1020
|
+
parseMethodCallReturn<TReturn extends Uint8Array | ABIValue | ABIStruct | undefined, TResult extends SendAppTransactionResult = SendAppTransactionResult>(result: Promise<TResult> | TResult, method: Arc56Method): Promise<Omit<TResult, 'return'> & AppReturn<TReturn>>;
|
|
966
1021
|
}
|
|
967
|
-
//# sourceMappingURL=app-factory.d.ts.map
|
package/types/app-factory.js
CHANGED
|
@@ -14,6 +14,69 @@ var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
|
14
14
|
*/
|
|
15
15
|
class AppFactory {
|
|
16
16
|
constructor(params) {
|
|
17
|
+
/** Create transactions for the current app */
|
|
18
|
+
this.createTransaction = {
|
|
19
|
+
/** Create bare (raw) transactions for the current app */
|
|
20
|
+
bare: {
|
|
21
|
+
/** Create a create call transaction, including deploy-time TEAL template replacements and compilation if provided */
|
|
22
|
+
create: async (params) => {
|
|
23
|
+
return this._algorand.createTransaction.appCreate(await this.params.bare.create(params));
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
/** Create a create ABI call transaction, including deploy-time TEAL template replacements and compilation if provided */
|
|
27
|
+
create: async (params) => {
|
|
28
|
+
return this._algorand.createTransaction.appCreateMethodCall(await this.params.create(params));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/** Send transactions to the current app */
|
|
32
|
+
this.send = {
|
|
33
|
+
/** Send bare (raw) transactions for the current app */
|
|
34
|
+
bare: {
|
|
35
|
+
create: async (params) => {
|
|
36
|
+
const updatable = params?.updatable ?? this._updatable;
|
|
37
|
+
const deletable = params?.deletable ?? this._deletable;
|
|
38
|
+
const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams;
|
|
39
|
+
const compiled = await this.compile({ deployTimeParams, updatable, deletable });
|
|
40
|
+
const result = await this.handleCallErrors(async () => ({
|
|
41
|
+
...(await this._algorand.send.appCreate(await this.params.bare.create({ ...params, updatable, deletable, deployTimeParams }))),
|
|
42
|
+
return: undefined,
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
appClient: this.getAppClientById({
|
|
46
|
+
appId: result.appId,
|
|
47
|
+
}),
|
|
48
|
+
result: {
|
|
49
|
+
...result,
|
|
50
|
+
...compiled,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Creates an instance of the app and returns the result of the creation
|
|
57
|
+
* transaction and an app client to interact with that app instance.
|
|
58
|
+
*
|
|
59
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
60
|
+
* @param params The parameters to create the app
|
|
61
|
+
* @returns The app client and the result of the creation transaction
|
|
62
|
+
*/
|
|
63
|
+
create: async (params) => {
|
|
64
|
+
const updatable = params?.updatable ?? this._updatable;
|
|
65
|
+
const deletable = params?.deletable ?? this._deletable;
|
|
66
|
+
const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams;
|
|
67
|
+
const compiled = await this.compile({ deployTimeParams, updatable, deletable });
|
|
68
|
+
const result = await this.handleCallErrors(async () => this.parseMethodCallReturn(this._algorand.send.appCreateMethodCall(await this.params.create({ ...params, updatable, deletable, deployTimeParams })), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
69
|
+
return {
|
|
70
|
+
appClient: this.getAppClientById({
|
|
71
|
+
appId: result.appId,
|
|
72
|
+
}),
|
|
73
|
+
result: {
|
|
74
|
+
...result,
|
|
75
|
+
...compiled,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
|
17
80
|
this._appSpec = types_appClient.AppClient.normaliseAppSpec(params.appSpec);
|
|
18
81
|
this._appName = params.appName ?? this._appSpec.name;
|
|
19
82
|
this._algorand = params.algorand;
|
|
@@ -24,38 +87,23 @@ class AppFactory {
|
|
|
24
87
|
this._deletable = params.deletable;
|
|
25
88
|
this._paramsMethods = this.getParamsMethods();
|
|
26
89
|
}
|
|
27
|
-
/** Get parameters to
|
|
28
|
-
get params() {
|
|
29
|
-
return this._paramsMethods;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates an instance of the app and returns the result of the creation
|
|
33
|
-
* transaction and an app client to interact with that app instance.
|
|
90
|
+
/** Get parameters to create transactions (create and deploy related calls) for the current app.
|
|
34
91
|
*
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
92
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
93
|
+
* @example Create a transaction in the future using Algorand Client
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
96
|
+
* // ...
|
|
97
|
+
* await algorand.send.AppCreateMethodCall(createAppParams)
|
|
98
|
+
* ```
|
|
99
|
+
* @example Define a nested transaction as an ABI argument
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
102
|
+
* await appClient.send.call({method: 'my_method', args: [createAppParams]})
|
|
103
|
+
* ```
|
|
38
104
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const deletable = params?.deletable ?? this._deletable;
|
|
42
|
-
const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams;
|
|
43
|
-
const compiled = await this.compile({ deployTimeParams, updatable, deletable });
|
|
44
|
-
const result = await this.handleCallErrors(async () => params && 'method' in params
|
|
45
|
-
? this.parseMethodCallReturn(this._algorand.send.appCreateMethodCall(await this.params.create({ ...params, updatable, deletable, deployTimeParams })), types_appArc56.getArc56Method(params.method, this._appSpec))
|
|
46
|
-
: {
|
|
47
|
-
...(await this._algorand.send.appCreate(await this.params.bare.create({ ...params, updatable, deletable, deployTimeParams }))),
|
|
48
|
-
return: undefined,
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
app: this.getAppClientById({
|
|
52
|
-
appId: result.appId,
|
|
53
|
-
}),
|
|
54
|
-
result: {
|
|
55
|
-
...result,
|
|
56
|
-
...compiled,
|
|
57
|
-
},
|
|
58
|
-
};
|
|
105
|
+
get params() {
|
|
106
|
+
return this._paramsMethods;
|
|
59
107
|
}
|
|
60
108
|
/**
|
|
61
109
|
* Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).
|
|
@@ -91,7 +139,7 @@ class AppFactory {
|
|
|
91
139
|
deletable,
|
|
92
140
|
},
|
|
93
141
|
});
|
|
94
|
-
const
|
|
142
|
+
const appClient = this.getAppClientById({
|
|
95
143
|
appId: deployResult.appId,
|
|
96
144
|
});
|
|
97
145
|
const result = {
|
|
@@ -99,7 +147,7 @@ class AppFactory {
|
|
|
99
147
|
...compiled,
|
|
100
148
|
};
|
|
101
149
|
return {
|
|
102
|
-
|
|
150
|
+
appClient,
|
|
103
151
|
result: {
|
|
104
152
|
...result,
|
|
105
153
|
return: 'return' in result
|
|
@@ -145,7 +193,7 @@ class AppFactory {
|
|
|
145
193
|
* @param params The parameters to create the app client
|
|
146
194
|
* @returns The `AppClient`
|
|
147
195
|
*/
|
|
148
|
-
|
|
196
|
+
getAppClientByCreatorAndName(params) {
|
|
149
197
|
return types_appClient.AppClient.fromCreatorAndName({
|
|
150
198
|
...params,
|
|
151
199
|
algorand: this._algorand,
|
|
@@ -290,10 +338,34 @@ class AppFactory {
|
|
|
290
338
|
...params,
|
|
291
339
|
sender: this.getSender(params.sender),
|
|
292
340
|
method: types_appArc56.getArc56Method(params.method, this._appSpec),
|
|
293
|
-
args:
|
|
341
|
+
args: this.getCreateABIArgsWithDefaultValues(params.method, params.args),
|
|
294
342
|
onComplete,
|
|
295
343
|
};
|
|
296
344
|
}
|
|
345
|
+
getCreateABIArgsWithDefaultValues(methodNameOrSignature, args) {
|
|
346
|
+
const m = types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
|
|
347
|
+
return args?.map((a, i) => {
|
|
348
|
+
const arg = m.args[i];
|
|
349
|
+
if (a !== undefined) {
|
|
350
|
+
// If a struct then convert to tuple for the underlying call
|
|
351
|
+
return arg.struct && typeof a === 'object' && !Array.isArray(a)
|
|
352
|
+
? types_appArc56.getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
|
|
353
|
+
: a;
|
|
354
|
+
}
|
|
355
|
+
const defaultValue = arg.defaultValue;
|
|
356
|
+
if (defaultValue) {
|
|
357
|
+
switch (defaultValue.source) {
|
|
358
|
+
case 'literal':
|
|
359
|
+
if (typeof defaultValue.data === 'number')
|
|
360
|
+
return defaultValue.data;
|
|
361
|
+
return types_appArc56.getABIDecodedValue(Buffer.from(defaultValue.data, 'base64'), m.method.args[i].type, this._appSpec.structs);
|
|
362
|
+
default:
|
|
363
|
+
throw new Error(`Can't provide default value for ${defaultValue.source} for a contract creation call`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
297
369
|
/** Returns the sender for a call, using the `defaultSender`
|
|
298
370
|
* if none provided and throws an error if neither provided */
|
|
299
371
|
getSender(sender) {
|