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