@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-client.js
CHANGED
|
@@ -5,15 +5,13 @@ var buffer = require('buffer');
|
|
|
5
5
|
var app = require('../app.js');
|
|
6
6
|
var appDeploy = require('../app-deploy.js');
|
|
7
7
|
var config = require('../config.js');
|
|
8
|
-
var debugging = require('../debugging/debugging.js');
|
|
9
8
|
var legacyBridge = require('../transaction/legacy-bridge.js');
|
|
10
9
|
var transaction = require('../transaction/transaction.js');
|
|
11
10
|
var util = require('../util.js');
|
|
12
11
|
var types_app = require('./app.js');
|
|
13
12
|
var types_appArc56 = require('./app-arc56.js');
|
|
14
|
-
var types_appManager = require('./app-manager.js');
|
|
15
13
|
var types_appSpec = require('./app-spec.js');
|
|
16
|
-
var
|
|
14
|
+
var types_asyncEventEmitter = require('./async-event-emitter.js');
|
|
17
15
|
var types_logicError = require('./logic-error.js');
|
|
18
16
|
|
|
19
17
|
var ABIMethod = algosdk.ABIMethod;
|
|
@@ -61,10 +59,19 @@ class AppClient {
|
|
|
61
59
|
this._boxStateMethods = this.getBoxMethods();
|
|
62
60
|
this._paramsMethods = {
|
|
63
61
|
...this.getMethodCallParamsMethods(),
|
|
62
|
+
/** Get parameters to define bare (raw) transactions to the current app */
|
|
64
63
|
bare: this.getBareParamsMethods(),
|
|
65
64
|
};
|
|
66
|
-
this.
|
|
67
|
-
|
|
65
|
+
this._createTransactionsMethods = {
|
|
66
|
+
...this.getMethodCallCreateTransactionMethods(),
|
|
67
|
+
/** Get transactions for bare (raw) calls to the current app */
|
|
68
|
+
bare: this.getBareCreateTransactionMethods(),
|
|
69
|
+
};
|
|
70
|
+
this._sendMethods = {
|
|
71
|
+
...this.getMethodCallSendMethods(),
|
|
72
|
+
/** Send bare (raw) transactions to the current app */
|
|
73
|
+
bare: this.getBareSendMethods(),
|
|
74
|
+
};
|
|
68
75
|
}
|
|
69
76
|
/** Start a new `AlgoKitComposer` transaction group */
|
|
70
77
|
newGroup() {
|
|
@@ -140,18 +147,33 @@ class AppClient {
|
|
|
140
147
|
get appSpec() {
|
|
141
148
|
return this._appSpec;
|
|
142
149
|
}
|
|
143
|
-
/** Get parameters to
|
|
150
|
+
/** Get parameters to create transactions for the current app.
|
|
151
|
+
*
|
|
152
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
153
|
+
* @example Create a transaction in the future using Algorand Client
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
156
|
+
* // ...
|
|
157
|
+
* await algorand.send.AppMethodCall(myMethodCall)
|
|
158
|
+
* ```
|
|
159
|
+
* @example Define a nested transaction as an ABI argument
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
162
|
+
* await appClient.send.call({method: 'my_method2', args: [myMethodCall]})
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
144
165
|
get params() {
|
|
145
166
|
return this._paramsMethods;
|
|
146
167
|
}
|
|
147
|
-
/**
|
|
148
|
-
get
|
|
149
|
-
return this.
|
|
168
|
+
/** Create transactions for the current app */
|
|
169
|
+
get createTransaction() {
|
|
170
|
+
return this._createTransactionsMethods;
|
|
150
171
|
}
|
|
151
|
-
/** Send
|
|
172
|
+
/** Send transactions to the current app */
|
|
152
173
|
get send() {
|
|
153
174
|
return this._sendMethods;
|
|
154
175
|
}
|
|
176
|
+
/** Get state (local, global, box) from the current app */
|
|
155
177
|
get state() {
|
|
156
178
|
return {
|
|
157
179
|
/**
|
|
@@ -171,6 +193,8 @@ class AppClient {
|
|
|
171
193
|
}
|
|
172
194
|
/**
|
|
173
195
|
* Funds Algo into the app account for this app.
|
|
196
|
+
*
|
|
197
|
+
* An alias for `appClient.send.fundAppAccount(params)`.
|
|
174
198
|
* @param params The parameters for the funding transaction
|
|
175
199
|
* @returns The result of the funding
|
|
176
200
|
*/
|
|
@@ -283,7 +307,7 @@ class AppClient {
|
|
|
283
307
|
this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
|
|
284
308
|
}
|
|
285
309
|
/**
|
|
286
|
-
* Returns the ABI Method for the given method
|
|
310
|
+
* Returns the ABI Method spec for the given method string for the app represented by this application client instance
|
|
287
311
|
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
288
312
|
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
289
313
|
* @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
|
|
@@ -293,18 +317,37 @@ class AppClient {
|
|
|
293
317
|
}
|
|
294
318
|
/**
|
|
295
319
|
* Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
|
|
296
|
-
* on the ARC-56 method.
|
|
320
|
+
* on the ARC-56 method, replacing the `return` property with the decoded type.
|
|
297
321
|
*
|
|
298
|
-
* If the return type is
|
|
322
|
+
* If the return type is an ARC-56 struct then the struct will be returned.
|
|
299
323
|
*
|
|
300
324
|
* @param result The SendAppTransactionResult to be mapped
|
|
301
325
|
* @param method The method that was called
|
|
302
326
|
* @returns The smart contract response with an updated return value
|
|
303
327
|
*/
|
|
304
|
-
async
|
|
328
|
+
async processMethodCallReturn(result, method) {
|
|
305
329
|
const resultValue = await result;
|
|
306
330
|
return { ...resultValue, return: types_appArc56.getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
|
|
307
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
334
|
+
* performing any provided deploy-time parameter replacement and stores
|
|
335
|
+
* the source maps.
|
|
336
|
+
*
|
|
337
|
+
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
338
|
+
*
|
|
339
|
+
* Will store any generated source maps for later use in debugging.
|
|
340
|
+
*/
|
|
341
|
+
async compile(compilation) {
|
|
342
|
+
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
343
|
+
if (result.compiledApproval) {
|
|
344
|
+
this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
345
|
+
}
|
|
346
|
+
if (result.compiledClear) {
|
|
347
|
+
this._clearSourceMap = result.compiledClear.sourceMap;
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
350
|
+
}
|
|
308
351
|
/**
|
|
309
352
|
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
310
353
|
* error to include source code information via the source map and ARC-56 spec.
|
|
@@ -353,7 +396,9 @@ class AppClient {
|
|
|
353
396
|
}
|
|
354
397
|
return {
|
|
355
398
|
approvalProgram: buffer.Buffer.from(appSpec.byteCode.approval, 'base64'),
|
|
399
|
+
compiledApproval: undefined,
|
|
356
400
|
clearStateProgram: buffer.Buffer.from(appSpec.byteCode.clear, 'base64'),
|
|
401
|
+
compiledClear: undefined,
|
|
357
402
|
};
|
|
358
403
|
}
|
|
359
404
|
const approvalTemplate = buffer.Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
@@ -363,15 +408,12 @@ class AppClient {
|
|
|
363
408
|
});
|
|
364
409
|
const clearTemplate = buffer.Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
|
|
365
410
|
const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
|
|
366
|
-
if (config.Config.debug
|
|
367
|
-
|
|
411
|
+
if (config.Config.debug) {
|
|
412
|
+
await config.Config.events.emitAsync(types_asyncEventEmitter.EventType.AppCompiled, {
|
|
368
413
|
sources: [
|
|
369
|
-
|
|
370
|
-
|
|
414
|
+
{ compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },
|
|
415
|
+
{ compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },
|
|
371
416
|
],
|
|
372
|
-
projectRoot: config.Config.projectRoot,
|
|
373
|
-
appManager,
|
|
374
|
-
withSources: true,
|
|
375
417
|
});
|
|
376
418
|
}
|
|
377
419
|
return {
|
|
@@ -389,24 +431,53 @@ class AppClient {
|
|
|
389
431
|
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
390
432
|
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
391
433
|
* @param args The arguments to the method with `undefined` for any that should be populated with a default value
|
|
392
|
-
* @param appSpec The app spec for the app
|
|
393
434
|
*/
|
|
394
|
-
|
|
395
|
-
const m = types_appArc56.getArc56Method(methodNameOrSignature,
|
|
396
|
-
return args?.map((a, i) => {
|
|
435
|
+
async getABIArgsWithDefaultValues(methodNameOrSignature, args, sender) {
|
|
436
|
+
const m = types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
|
|
437
|
+
return await Promise.all(args?.map(async (a, i) => {
|
|
397
438
|
const arg = m.args[i];
|
|
398
439
|
if (a !== undefined) {
|
|
399
440
|
// If a struct then convert to tuple for the underlying call
|
|
400
441
|
return arg.struct && typeof a === 'object' && !Array.isArray(a)
|
|
401
|
-
? types_appArc56.getABITupleFromABIStruct(a,
|
|
442
|
+
? types_appArc56.getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
|
|
402
443
|
: a;
|
|
403
444
|
}
|
|
404
|
-
// todo: expand this to match previous ApplicationClient implementation when ARC-56 spec is updated to support other default value options
|
|
405
445
|
const defaultValue = arg.defaultValue;
|
|
406
|
-
if (defaultValue)
|
|
407
|
-
|
|
446
|
+
if (defaultValue) {
|
|
447
|
+
switch (defaultValue.source) {
|
|
448
|
+
case 'literal':
|
|
449
|
+
if (typeof defaultValue.data === 'number')
|
|
450
|
+
return defaultValue.data;
|
|
451
|
+
return types_appArc56.getABIDecodedValue(buffer.Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
452
|
+
// todo: When ARC-56 supports ABI calls as default args
|
|
453
|
+
// case 'abi': {
|
|
454
|
+
// const method = this.getABIMethod(defaultValue.data as string)
|
|
455
|
+
// const result = await this.send.call({
|
|
456
|
+
// method: defaultValue.data as string,
|
|
457
|
+
// methodArgs: method.args.map(() => undefined),
|
|
458
|
+
// sender,
|
|
459
|
+
// })
|
|
460
|
+
// return result.return!
|
|
461
|
+
// }
|
|
462
|
+
case 'local':
|
|
463
|
+
case 'global': {
|
|
464
|
+
const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
|
|
465
|
+
const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data);
|
|
466
|
+
if (!value) {
|
|
467
|
+
throw new Error(`Preparing default value for argument ${arg.name ?? `arg${i + 1}`} resulted in the failure: The key '${defaultValue.data}' could not be found in ${defaultValue.source} storage`);
|
|
468
|
+
}
|
|
469
|
+
return 'valueRaw' in value
|
|
470
|
+
? types_appArc56.getABIDecodedValue(value.valueRaw, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs)
|
|
471
|
+
: value.value;
|
|
472
|
+
}
|
|
473
|
+
case 'box': {
|
|
474
|
+
const value = await this.getBoxValue(buffer.Buffer.from(defaultValue.data, 'base64'));
|
|
475
|
+
return types_appArc56.getABIDecodedValue(value, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
408
479
|
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
409
|
-
});
|
|
480
|
+
}) ?? []);
|
|
410
481
|
}
|
|
411
482
|
getBareParamsMethods() {
|
|
412
483
|
return {
|
|
@@ -439,31 +510,31 @@ class AppClient {
|
|
|
439
510
|
},
|
|
440
511
|
};
|
|
441
512
|
}
|
|
442
|
-
|
|
513
|
+
getBareCreateTransactionMethods() {
|
|
443
514
|
return {
|
|
444
515
|
/** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
445
516
|
update: async (params) => {
|
|
446
|
-
return this._algorand.
|
|
517
|
+
return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params));
|
|
447
518
|
},
|
|
448
519
|
/** Returns a transaction for an opt-in call */
|
|
449
520
|
optIn: (params) => {
|
|
450
|
-
return this._algorand.
|
|
521
|
+
return this._algorand.createTransaction.appCall(this.params.bare.optIn(params));
|
|
451
522
|
},
|
|
452
523
|
/** Returns a transaction for a delete call */
|
|
453
524
|
delete: (params) => {
|
|
454
|
-
return this._algorand.
|
|
525
|
+
return this._algorand.createTransaction.appDelete(this.params.bare.delete(params));
|
|
455
526
|
},
|
|
456
527
|
/** Returns a transaction for a clear state call */
|
|
457
528
|
clearState: (params) => {
|
|
458
|
-
return this._algorand.
|
|
529
|
+
return this._algorand.createTransaction.appCall(this.params.bare.clearState(params));
|
|
459
530
|
},
|
|
460
531
|
/** Returns a transaction for a close out call */
|
|
461
532
|
closeOut: (params) => {
|
|
462
|
-
return this._algorand.
|
|
533
|
+
return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params));
|
|
463
534
|
},
|
|
464
535
|
/** Returns a transaction for a call (defaults to no-op) */
|
|
465
536
|
call: (params) => {
|
|
466
|
-
return this._algorand.
|
|
537
|
+
return this._algorand.createTransaction.appCall(this.params.bare.call(params));
|
|
467
538
|
},
|
|
468
539
|
};
|
|
469
540
|
}
|
|
@@ -507,26 +578,26 @@ class AppClient {
|
|
|
507
578
|
},
|
|
508
579
|
/** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
|
|
509
580
|
update: async (params) => {
|
|
510
|
-
return this.getABIParams({
|
|
581
|
+
return (await this.getABIParams({
|
|
511
582
|
...params,
|
|
512
583
|
...(await this.compile(params)),
|
|
513
|
-
}, OnApplicationComplete.UpdateApplicationOC);
|
|
584
|
+
}, OnApplicationComplete.UpdateApplicationOC));
|
|
514
585
|
},
|
|
515
586
|
/** Return params for an opt-in ABI call */
|
|
516
|
-
optIn: (params) => {
|
|
517
|
-
return this.getABIParams(params, OnApplicationComplete.OptInOC);
|
|
587
|
+
optIn: async (params) => {
|
|
588
|
+
return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
|
|
518
589
|
},
|
|
519
590
|
/** Return params for an delete ABI call */
|
|
520
|
-
delete: (params) => {
|
|
521
|
-
return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
|
|
591
|
+
delete: async (params) => {
|
|
592
|
+
return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
|
|
522
593
|
},
|
|
523
594
|
/** Return params for an close out ABI call */
|
|
524
|
-
closeOut: (params) => {
|
|
525
|
-
return this.getABIParams(params, OnApplicationComplete.CloseOutOC);
|
|
595
|
+
closeOut: async (params) => {
|
|
596
|
+
return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
|
|
526
597
|
},
|
|
527
598
|
/** Return params for an ABI call */
|
|
528
|
-
call: (params) => {
|
|
529
|
-
return this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC);
|
|
599
|
+
call: async (params) => {
|
|
600
|
+
return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
|
|
530
601
|
},
|
|
531
602
|
};
|
|
532
603
|
}
|
|
@@ -542,7 +613,7 @@ class AppClient {
|
|
|
542
613
|
update: async (params) => {
|
|
543
614
|
const compiled = await this.compile(params);
|
|
544
615
|
return {
|
|
545
|
-
...(await this.handleCallErrors(async () => this.
|
|
616
|
+
...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), types_appArc56.getArc56Method(params.method, this._appSpec)))),
|
|
546
617
|
...compiled,
|
|
547
618
|
};
|
|
548
619
|
},
|
|
@@ -550,19 +621,19 @@ class AppClient {
|
|
|
550
621
|
* Sign and send transactions for an opt-in ABI call
|
|
551
622
|
*/
|
|
552
623
|
optIn: (params) => {
|
|
553
|
-
return this.handleCallErrors(() => this.
|
|
624
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
554
625
|
},
|
|
555
626
|
/**
|
|
556
627
|
* Sign and send transactions for a delete ABI call
|
|
557
628
|
*/
|
|
558
629
|
delete: (params) => {
|
|
559
|
-
return this.handleCallErrors(() => this.
|
|
630
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
560
631
|
},
|
|
561
632
|
/**
|
|
562
633
|
* Sign and send transactions for a close out ABI call
|
|
563
634
|
*/
|
|
564
635
|
closeOut: (params) => {
|
|
565
|
-
return this.handleCallErrors(() => this.
|
|
636
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
566
637
|
},
|
|
567
638
|
/**
|
|
568
639
|
* Sign and send transactions for a call (defaults to no-op)
|
|
@@ -571,8 +642,11 @@ class AppClient {
|
|
|
571
642
|
// Read-only call - do it via simulate
|
|
572
643
|
if (params.onComplete === OnApplicationComplete.NoOpOC ||
|
|
573
644
|
(!params.onComplete && types_appArc56.getArc56Method(params.method, this._appSpec).method.readonly)) {
|
|
574
|
-
const result = await this._algorand
|
|
575
|
-
|
|
645
|
+
const result = await this._algorand
|
|
646
|
+
.newGroup()
|
|
647
|
+
.addAppCallMethodCall(await this.params.call(params))
|
|
648
|
+
.simulate();
|
|
649
|
+
return this.processMethodCallReturn({
|
|
576
650
|
...result,
|
|
577
651
|
transaction: result.transactions.at(-1),
|
|
578
652
|
confirmation: result.confirmations.at(-1),
|
|
@@ -580,67 +654,48 @@ class AppClient {
|
|
|
580
654
|
return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
|
|
581
655
|
}, types_appArc56.getArc56Method(params.method, this._appSpec));
|
|
582
656
|
}
|
|
583
|
-
return this.handleCallErrors(() => this.
|
|
657
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
584
658
|
},
|
|
585
659
|
};
|
|
586
660
|
}
|
|
587
|
-
|
|
661
|
+
getMethodCallCreateTransactionMethods() {
|
|
588
662
|
return {
|
|
589
663
|
/** Return transaction for a payment transaction to fund the app account */
|
|
590
664
|
fundAppAccount: (params) => {
|
|
591
|
-
return this._algorand.
|
|
665
|
+
return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
|
|
592
666
|
},
|
|
593
667
|
/**
|
|
594
668
|
* Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
595
669
|
*/
|
|
596
670
|
update: async (params) => {
|
|
597
|
-
return this._algorand.
|
|
671
|
+
return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
|
|
598
672
|
},
|
|
599
673
|
/**
|
|
600
674
|
* Return transactions for an opt-in ABI call
|
|
601
675
|
*/
|
|
602
|
-
optIn: (params) => {
|
|
603
|
-
return this._algorand.
|
|
676
|
+
optIn: async (params) => {
|
|
677
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
|
|
604
678
|
},
|
|
605
679
|
/**
|
|
606
680
|
* Return transactions for a delete ABI call
|
|
607
681
|
*/
|
|
608
|
-
delete: (params) => {
|
|
609
|
-
return this._algorand.
|
|
682
|
+
delete: async (params) => {
|
|
683
|
+
return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
|
|
610
684
|
},
|
|
611
685
|
/**
|
|
612
686
|
* Return transactions for a close out ABI call
|
|
613
687
|
*/
|
|
614
|
-
closeOut: (params) => {
|
|
615
|
-
return this._algorand.
|
|
688
|
+
closeOut: async (params) => {
|
|
689
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
|
|
616
690
|
},
|
|
617
691
|
/**
|
|
618
692
|
* Return transactions for an ABI call (defaults to no-op)
|
|
619
693
|
*/
|
|
620
|
-
call: (params) => {
|
|
621
|
-
return this._algorand.
|
|
694
|
+
call: async (params) => {
|
|
695
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
|
|
622
696
|
},
|
|
623
697
|
};
|
|
624
698
|
}
|
|
625
|
-
/**
|
|
626
|
-
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
627
|
-
* performing any provided deploy-time parameter replacement and stores
|
|
628
|
-
* the source maps.
|
|
629
|
-
*
|
|
630
|
-
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
631
|
-
*
|
|
632
|
-
* Will store any generated source maps for later use in debugging.
|
|
633
|
-
*/
|
|
634
|
-
async compile(compilation) {
|
|
635
|
-
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
636
|
-
if (result.compiledApproval) {
|
|
637
|
-
this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
638
|
-
}
|
|
639
|
-
if (result.compiledClear) {
|
|
640
|
-
this._clearSourceMap = result.compiledClear.sourceMap;
|
|
641
|
-
}
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
699
|
/** Returns the sender for a call, using the `defaultSender`
|
|
645
700
|
* if none provided and throws an error if neither provided */
|
|
646
701
|
getSender(sender) {
|
|
@@ -657,13 +712,14 @@ class AppClient {
|
|
|
657
712
|
onComplete,
|
|
658
713
|
};
|
|
659
714
|
}
|
|
660
|
-
getABIParams(params, onComplete) {
|
|
715
|
+
async getABIParams(params, onComplete) {
|
|
716
|
+
const sender = this.getSender(params.sender);
|
|
661
717
|
const method = types_appArc56.getArc56Method(params.method, this._appSpec);
|
|
662
|
-
const args =
|
|
718
|
+
const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender);
|
|
663
719
|
return {
|
|
664
720
|
...params,
|
|
665
721
|
appId: this._appId,
|
|
666
|
-
sender:
|
|
722
|
+
sender: sender,
|
|
667
723
|
method,
|
|
668
724
|
onComplete,
|
|
669
725
|
args,
|
|
@@ -878,15 +934,12 @@ class ApplicationClient {
|
|
|
878
934
|
const clear = appDeploy.performTemplateSubstitution(clearTemplate, deployTimeParams ?? this.deployTimeParams);
|
|
879
935
|
const clearCompiled = await app.compileTeal(clear, this.algod);
|
|
880
936
|
this._clearSourceMap = clearCompiled?.sourceMap;
|
|
881
|
-
if (config.Config.debug
|
|
882
|
-
|
|
937
|
+
if (config.Config.debug) {
|
|
938
|
+
await config.Config.events.emitAsync(types_asyncEventEmitter.EventType.AppCompiled, {
|
|
883
939
|
sources: [
|
|
884
|
-
|
|
885
|
-
|
|
940
|
+
{ compiledTeal: approvalCompiled, appName: this._appName, fileName: 'approval' },
|
|
941
|
+
{ compiledTeal: clearCompiled, appName: this._appName, fileName: 'clear' },
|
|
886
942
|
],
|
|
887
|
-
projectRoot: config.Config.projectRoot,
|
|
888
|
-
appManager: new types_appManager.AppManager(this.algod),
|
|
889
|
-
withSources: true,
|
|
890
943
|
});
|
|
891
944
|
}
|
|
892
945
|
return { approvalCompiled, clearCompiled };
|
|
@@ -1046,7 +1099,7 @@ class ApplicationClient {
|
|
|
1046
1099
|
}
|
|
1047
1100
|
}
|
|
1048
1101
|
/**
|
|
1049
|
-
* @deprecated Use `appClient.send.update` or `appClient.
|
|
1102
|
+
* @deprecated Use `appClient.send.update` or `appClient.createTransaction.update` from an `AppClient` instance instead.
|
|
1050
1103
|
*
|
|
1051
1104
|
* Updates the smart contract app.
|
|
1052
1105
|
* @param update The parameters to update the app with
|
|
@@ -1080,7 +1133,7 @@ class ApplicationClient {
|
|
|
1080
1133
|
}
|
|
1081
1134
|
}
|
|
1082
1135
|
/**
|
|
1083
|
-
* @deprecated Use `appClient.send.call` or `appClient.
|
|
1136
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1084
1137
|
*
|
|
1085
1138
|
* Issues a no_op (normal) call to the app.
|
|
1086
1139
|
* @param call The call details.
|
|
@@ -1115,7 +1168,7 @@ class ApplicationClient {
|
|
|
1115
1168
|
return await this.callOfType(call, 'no_op');
|
|
1116
1169
|
}
|
|
1117
1170
|
/**
|
|
1118
|
-
* @deprecated Use `appClient.send.optIn` or `appClient.
|
|
1171
|
+
* @deprecated Use `appClient.send.optIn` or `appClient.createTransaction.optIn` from an `AppClient` instance instead.
|
|
1119
1172
|
*
|
|
1120
1173
|
* Issues a opt_in call to the app.
|
|
1121
1174
|
* @param call The call details.
|
|
@@ -1125,7 +1178,7 @@ class ApplicationClient {
|
|
|
1125
1178
|
return await this.callOfType(call, 'opt_in');
|
|
1126
1179
|
}
|
|
1127
1180
|
/**
|
|
1128
|
-
* @deprecated Use `appClient.send.closeOut` or `appClient.
|
|
1181
|
+
* @deprecated Use `appClient.send.closeOut` or `appClient.createTransaction.closeOut` from an `AppClient` instance instead.
|
|
1129
1182
|
*
|
|
1130
1183
|
* Issues a close_out call to the app.
|
|
1131
1184
|
* @param call The call details.
|
|
@@ -1135,7 +1188,7 @@ class ApplicationClient {
|
|
|
1135
1188
|
return await this.callOfType(call, 'close_out');
|
|
1136
1189
|
}
|
|
1137
1190
|
/**
|
|
1138
|
-
* @deprecated Use `appClient.send.clearState` or `appClient.
|
|
1191
|
+
* @deprecated Use `appClient.send.clearState` or `appClient.createTransaction.clearState` from an `AppClient` instance instead.
|
|
1139
1192
|
*
|
|
1140
1193
|
* Issues a clear_state call to the app.
|
|
1141
1194
|
* @param call The call details.
|
|
@@ -1145,7 +1198,7 @@ class ApplicationClient {
|
|
|
1145
1198
|
return await this.callOfType(call, 'clear_state');
|
|
1146
1199
|
}
|
|
1147
1200
|
/**
|
|
1148
|
-
* @deprecated Use `appClient.send.delete` or `appClient.
|
|
1201
|
+
* @deprecated Use `appClient.send.delete` or `appClient.createTransaction.delete` from an `AppClient` instance instead.
|
|
1149
1202
|
*
|
|
1150
1203
|
* Issues a delete_application call to the app.
|
|
1151
1204
|
* @param call The call details.
|
|
@@ -1155,7 +1208,7 @@ class ApplicationClient {
|
|
|
1155
1208
|
return await this.callOfType(call, 'delete_application');
|
|
1156
1209
|
}
|
|
1157
1210
|
/**
|
|
1158
|
-
* @deprecated Use `appClient.send.call` or `appClient.
|
|
1211
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1159
1212
|
*
|
|
1160
1213
|
* Issues a call to the app with the given call type.
|
|
1161
1214
|
* @param call The call details.
|