@algorandfoundation/algokit-utils 7.0.0-beta.9 → 8.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +21 -3
- package/account/account.d.ts +4 -1
- package/account/account.js +10 -7
- package/account/account.js.map +1 -1
- package/account/account.mjs +11 -8
- package/account/account.mjs.map +1 -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.js.map +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +1 -0
- package/amount.js +3 -2
- package/amount.js.map +1 -1
- package/amount.mjs +3 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +4 -4
- package/app-client.js +4 -4
- package/app-client.js.map +1 -1
- package/app-client.mjs +4 -4
- package/app-client.mjs.map +1 -1
- package/app-deploy.js +25 -15
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +27 -17
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +2 -2
- package/app.js +9 -6
- package/app.js.map +1 -1
- package/app.mjs +9 -6
- package/app.mjs.map +1 -1
- package/asset.js.map +1 -1
- package/asset.mjs.map +1 -1
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +7 -1
- package/index.js.map +1 -1
- package/index.mjs +3 -2
- package/index.mjs.map +1 -1
- package/indexer-lookup.d.ts +10 -8
- package/indexer-lookup.js +14 -10
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +14 -10
- package/indexer-lookup.mjs.map +1 -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.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -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/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +1 -7
- package/network-client.js +2 -9
- package/network-client.js.map +1 -1
- package/network-client.mjs +2 -9
- package/network-client.mjs.map +1 -1
- package/package.json +5 -5
- package/testing/_asset.d.ts +2 -1
- package/testing/account.d.ts +4 -3
- package/testing/account.js +8 -2
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +9 -3
- package/testing/account.mjs.map +1 -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.js +5 -6
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +5 -6
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.js +7 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +7 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +2 -2
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +3 -3
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +13 -22
- package/transaction/transaction.js +164 -110
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +163 -109
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.js +3 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +3 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +20 -20
- package/types/account-manager.js +36 -27
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +38 -29
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +17 -8
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -2
- package/types/algo-http-client-with-retry.js +33 -3
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +32 -2
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +2 -2
- package/types/algorand-client-transaction-creator.d.ts +16 -14
- package/types/algorand-client-transaction-creator.js +3 -1
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +3 -1
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +109 -105
- package/types/algorand-client-transaction-sender.js +6 -2
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +6 -2
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +6 -7
- package/types/algorand-client.js +3 -6
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +5 -5
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.js.map +1 -1
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +31 -20
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +298 -286
- package/types/app-client.js +148 -41
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +147 -40
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +4 -4
- package/types/app-deployer.js +23 -24
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +25 -26
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +130 -130
- package/types/app-factory.js +4 -5
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +5 -6
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +5 -5
- package/types/app-manager.js +116 -38
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +117 -39
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.js +8 -2
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +8 -2
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +12 -11
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +9 -9
- package/types/asset-manager.js +10 -13
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +10 -13
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +1 -10
- package/types/async-event-emitter.js +0 -5
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +1 -6
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +2 -9
- package/types/client-manager.js +11 -21
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +11 -21
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +58 -46
- package/types/composer.js +154 -105
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +156 -105
- package/types/composer.mjs.map +1 -1
- package/types/config.js.map +1 -1
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +1 -1
- package/types/debugging.js +1 -1
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +1 -1
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +2 -1
- package/types/dispenser-client.js +5 -1
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +5 -1
- package/types/dispenser-client.mjs.map +1 -1
- package/types/indexer.d.ts +74 -755
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +2 -2
- package/types/kmd-account-manager.js +1 -1
- 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/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -3
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +1 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +6 -7
- package/util.js.map +1 -1
- package/util.mjs.map +1 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -40
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
package/types/app-client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import algosdk from 'algosdk';
|
|
1
|
+
import algosdk, { Address } from 'algosdk';
|
|
2
2
|
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';
|
|
@@ -9,7 +9,7 @@ import { binaryStartsWith } from '../util.mjs';
|
|
|
9
9
|
import { UPDATABLE_TEMPLATE_NAME, DELETABLE_TEMPLATE_NAME } from './app.mjs';
|
|
10
10
|
import { getArc56Method, getArc56ReturnValue, getABITupleFromABIStruct, getABIDecodedValue, getABIEncodedValue } from './app-arc56.mjs';
|
|
11
11
|
import { arc32ToArc56 } from './app-spec.mjs';
|
|
12
|
-
import { EventType } from './
|
|
12
|
+
import { EventType } from './lifecycle-events.mjs';
|
|
13
13
|
import { LogicError } from './logic-error.mjs';
|
|
14
14
|
|
|
15
15
|
var ABIMethod = algosdk.ABIMethod;
|
|
@@ -17,7 +17,7 @@ var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
|
17
17
|
var getApplicationAddress = algosdk.getApplicationAddress;
|
|
18
18
|
var Indexer = algosdk.Indexer;
|
|
19
19
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
20
|
-
var SourceMap = algosdk.
|
|
20
|
+
var SourceMap = algosdk.ProgramSourceMap;
|
|
21
21
|
/**
|
|
22
22
|
* Determines deploy time control (UPDATABLE, DELETABLE) value by inspecting application specification
|
|
23
23
|
* @param approval TEAL Approval program, not the base64 version found on the appSpec
|
|
@@ -40,6 +40,57 @@ function getDeployTimeControl(approval, appSpec, templateVariableName, callConfi
|
|
|
40
40
|
return !!abiCallConfig && abiCallConfig !== 'NEVER';
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
const BYTE_CBLOCK = 38;
|
|
44
|
+
const INT_CBLOCK = 32;
|
|
45
|
+
/**
|
|
46
|
+
* Get the offset of the last constant block at the beginning of the program
|
|
47
|
+
* This value is used to calculate the program counter for an ARC56 program that has a pcOffsetMethod of "cblocks"
|
|
48
|
+
*
|
|
49
|
+
* @param program The program to parse
|
|
50
|
+
* @returns The PC value of the opcode after the last constant block
|
|
51
|
+
*/
|
|
52
|
+
function getConstantBlockOffset(program) {
|
|
53
|
+
const bytes = [...program];
|
|
54
|
+
const programSize = bytes.length;
|
|
55
|
+
bytes.shift(); // remove version
|
|
56
|
+
/** The PC of the opcode after the bytecblock */
|
|
57
|
+
let bytecblockOffset;
|
|
58
|
+
/** The PC of the opcode after the intcblock */
|
|
59
|
+
let intcblockOffset;
|
|
60
|
+
while (bytes.length > 0) {
|
|
61
|
+
/** The current byte from the beginning of the byte array */
|
|
62
|
+
const byte = bytes.shift();
|
|
63
|
+
// If the byte is a constant block...
|
|
64
|
+
if (byte === BYTE_CBLOCK || byte === INT_CBLOCK) {
|
|
65
|
+
const isBytecblock = byte === BYTE_CBLOCK;
|
|
66
|
+
/** The byte following the opcode is the number of values in the constant block */
|
|
67
|
+
const valuesRemaining = bytes.shift();
|
|
68
|
+
// Iterate over all the values in the constant block
|
|
69
|
+
for (let i = 0; i < valuesRemaining; i++) {
|
|
70
|
+
if (isBytecblock) {
|
|
71
|
+
/** The byte following the opcode is the length of the next element */
|
|
72
|
+
const length = bytes.shift();
|
|
73
|
+
bytes.splice(0, length);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// intcblock is a uvarint, so we need to keep reading until we find the end (MSB is not set)
|
|
77
|
+
while ((bytes.shift() & 0x80) !== 0) {
|
|
78
|
+
// Do nothing...
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (isBytecblock)
|
|
83
|
+
bytecblockOffset = programSize - bytes.length - 1;
|
|
84
|
+
else
|
|
85
|
+
intcblockOffset = programSize - bytes.length - 1;
|
|
86
|
+
if (bytes[0] !== BYTE_CBLOCK && bytes[0] !== INT_CBLOCK) {
|
|
87
|
+
// if the next opcode isn't a constant block, we're done
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return Math.max(bytecblockOffset ?? 0, intcblockOffset ?? 0);
|
|
93
|
+
}
|
|
43
94
|
/** ARC-56/ARC-32 application client that allows you to manage calls and
|
|
44
95
|
* state for a specific deployed instance of an app (with a known app ID). */
|
|
45
96
|
class AppClient {
|
|
@@ -49,7 +100,7 @@ class AppClient {
|
|
|
49
100
|
this._appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
50
101
|
this._appName = params.appName ?? this._appSpec.name;
|
|
51
102
|
this._algorand = params.algorand;
|
|
52
|
-
this._defaultSender = params.defaultSender;
|
|
103
|
+
this._defaultSender = typeof params.defaultSender === 'string' ? Address.fromString(params.defaultSender) : params.defaultSender;
|
|
53
104
|
this._defaultSigner = params.defaultSigner;
|
|
54
105
|
this._approvalSourceMap = params.approvalSourceMap;
|
|
55
106
|
this._clearSourceMap = params.clearSourceMap;
|
|
@@ -72,9 +123,24 @@ class AppClient {
|
|
|
72
123
|
bare: this.getBareSendMethods(),
|
|
73
124
|
};
|
|
74
125
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Clone this app client with different params
|
|
128
|
+
*
|
|
129
|
+
* @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.
|
|
130
|
+
* @returns A new app client with the altered params
|
|
131
|
+
*/
|
|
132
|
+
clone(params) {
|
|
133
|
+
return new AppClient({
|
|
134
|
+
appId: this._appId,
|
|
135
|
+
appSpec: this._appSpec,
|
|
136
|
+
algorand: this._algorand,
|
|
137
|
+
appName: this._appName,
|
|
138
|
+
defaultSender: this._defaultSender,
|
|
139
|
+
defaultSigner: this._defaultSigner,
|
|
140
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
141
|
+
clearSourceMap: this._clearSourceMap,
|
|
142
|
+
...params,
|
|
143
|
+
});
|
|
78
144
|
}
|
|
79
145
|
/**
|
|
80
146
|
* Returns a new `AppClient` client, resolving the app by creator address and name
|
|
@@ -138,7 +204,7 @@ class AppClient {
|
|
|
138
204
|
get appAddress() {
|
|
139
205
|
return this._appAddress;
|
|
140
206
|
}
|
|
141
|
-
/** The name of the app (from the ARC-32 / ARC-56 app spec). */
|
|
207
|
+
/** The name of the app (from the ARC-32 / ARC-56 app spec or override). */
|
|
142
208
|
get appName() {
|
|
143
209
|
return this._appName;
|
|
144
210
|
}
|
|
@@ -281,11 +347,19 @@ class AppClient {
|
|
|
281
347
|
* @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)
|
|
282
348
|
* @returns The new error, or if there was no logic error or source map then the wrapped error with source details
|
|
283
349
|
*/
|
|
284
|
-
exposeLogicError(e, isClearStateProgram) {
|
|
350
|
+
async exposeLogicError(e, isClearStateProgram) {
|
|
351
|
+
const pcOffsetMethod = this._appSpec.sourceInfo?.[isClearStateProgram ? 'clear' : 'approval']?.pcOffsetMethod;
|
|
352
|
+
let program;
|
|
353
|
+
if (pcOffsetMethod === 'cblocks') {
|
|
354
|
+
// TODO: Cache this if we deploy the app and it's not updateable
|
|
355
|
+
const appInfo = await this._algorand.app.getById(this.appId);
|
|
356
|
+
program = isClearStateProgram ? appInfo.clearStateProgram : appInfo.approvalProgram;
|
|
357
|
+
}
|
|
285
358
|
return AppClient.exposeLogicError(e, this._appSpec, {
|
|
286
359
|
isClearStateProgram,
|
|
287
360
|
approvalSourceMap: this._approvalSourceMap,
|
|
288
361
|
clearSourceMap: this._clearSourceMap,
|
|
362
|
+
program,
|
|
289
363
|
});
|
|
290
364
|
}
|
|
291
365
|
/**
|
|
@@ -360,17 +434,45 @@ class AppClient {
|
|
|
360
434
|
* @returns The new error, or if there was no logic error or source map then the wrapped error with source details
|
|
361
435
|
*/
|
|
362
436
|
static exposeLogicError(e, appSpec, details) {
|
|
363
|
-
const { isClearStateProgram, approvalSourceMap, clearSourceMap } = details;
|
|
364
|
-
|
|
365
|
-
return e;
|
|
437
|
+
const { isClearStateProgram, approvalSourceMap, clearSourceMap, program } = details;
|
|
438
|
+
const sourceMap = isClearStateProgram ? clearSourceMap : approvalSourceMap;
|
|
366
439
|
const errorDetails = LogicError.parseLogicError(e);
|
|
367
|
-
|
|
368
|
-
if (errorDetails
|
|
440
|
+
// Return the error if we don't have a PC
|
|
441
|
+
if (errorDetails === undefined || errorDetails?.pc === undefined)
|
|
442
|
+
return e;
|
|
443
|
+
/** The PC value to find in the ARC56 SourceInfo */
|
|
444
|
+
let arc56Pc = errorDetails?.pc;
|
|
445
|
+
const programSourceInfo = isClearStateProgram ? appSpec.sourceInfo?.clear : appSpec.sourceInfo?.approval;
|
|
446
|
+
/** The offset to apply to the PC if using the cblocks pc offset method */
|
|
447
|
+
let cblocksOffset = 0;
|
|
448
|
+
// If the program uses cblocks offset, then we need to adjust the PC accordingly
|
|
449
|
+
if (programSourceInfo?.pcOffsetMethod === 'cblocks') {
|
|
450
|
+
if (program === undefined)
|
|
451
|
+
throw new Error('Program bytes are required to calculate the ARC56 cblocks PC offset');
|
|
452
|
+
cblocksOffset = getConstantBlockOffset(program);
|
|
453
|
+
arc56Pc = errorDetails.pc - cblocksOffset;
|
|
454
|
+
}
|
|
455
|
+
// Find the source info for this PC and get the error message
|
|
456
|
+
const sourceInfo = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(arc56Pc));
|
|
457
|
+
const errorMessage = sourceInfo?.errorMessage;
|
|
458
|
+
// If we have the source we can display the TEAL in the error message
|
|
459
|
+
if (appSpec.source) {
|
|
460
|
+
let getLineForPc = (inputPc) => sourceMap?.getLocationForPc?.(inputPc)?.line;
|
|
461
|
+
// If the SourceMap is not defined, we need to provide our own function for going from a PC to TEAL based on ARC56 SourceInfo[]
|
|
462
|
+
if (sourceMap === undefined) {
|
|
463
|
+
getLineForPc = (inputPc) => {
|
|
464
|
+
const teal = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(inputPc - cblocksOffset))?.teal;
|
|
465
|
+
if (teal === undefined)
|
|
466
|
+
return undefined;
|
|
467
|
+
return teal - 1;
|
|
468
|
+
};
|
|
469
|
+
}
|
|
369
470
|
e = new LogicError(errorDetails, Buffer.from(isClearStateProgram ? appSpec.source.clear : appSpec.source.approval, 'base64')
|
|
370
471
|
.toString()
|
|
371
472
|
.split('\n'),
|
|
372
473
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
373
|
-
|
|
474
|
+
getLineForPc);
|
|
475
|
+
}
|
|
374
476
|
if (errorMessage) {
|
|
375
477
|
const appId = JSON.stringify(e).match(/(?<=app=)\d+/)?.[0] || '';
|
|
376
478
|
const txId = JSON.stringify(e).match(/(?<=transaction )\S+(?=:)/)?.[0];
|
|
@@ -447,19 +549,22 @@ class AppClient {
|
|
|
447
549
|
if (defaultValue) {
|
|
448
550
|
switch (defaultValue.source) {
|
|
449
551
|
case 'literal':
|
|
450
|
-
if (typeof defaultValue.data === 'number')
|
|
451
|
-
return defaultValue.data;
|
|
452
552
|
return getABIDecodedValue(Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
553
|
+
case 'method': {
|
|
554
|
+
const method = this.getABIMethod(defaultValue.data);
|
|
555
|
+
const result = await this.send.call({
|
|
556
|
+
method: defaultValue.data,
|
|
557
|
+
args: method.args.map(() => undefined),
|
|
558
|
+
sender,
|
|
559
|
+
});
|
|
560
|
+
if (result.return === undefined) {
|
|
561
|
+
throw new Error('Default value method call did not return a value');
|
|
562
|
+
}
|
|
563
|
+
if (typeof result.return === 'object' && !(result.return instanceof Uint8Array) && !Array.isArray(result.return)) {
|
|
564
|
+
return getABITupleFromABIStruct(result.return, this._appSpec.structs[method.returns.struct], this._appSpec.structs);
|
|
565
|
+
}
|
|
566
|
+
return result.return;
|
|
567
|
+
}
|
|
463
568
|
case 'local':
|
|
464
569
|
case 'global': {
|
|
465
570
|
const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
|
|
@@ -477,7 +582,9 @@ class AppClient {
|
|
|
477
582
|
}
|
|
478
583
|
}
|
|
479
584
|
}
|
|
480
|
-
|
|
585
|
+
if (!algosdk.abiTypeIsTransaction(arg.type)) {
|
|
586
|
+
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
587
|
+
}
|
|
481
588
|
}) ?? []);
|
|
482
589
|
}
|
|
483
590
|
getBareParamsMethods() {
|
|
@@ -646,13 +753,13 @@ class AppClient {
|
|
|
646
753
|
*/
|
|
647
754
|
call: async (params) => {
|
|
648
755
|
// Read-only call - do it via simulate
|
|
649
|
-
if (params.onComplete === OnApplicationComplete.NoOpOC ||
|
|
650
|
-
|
|
756
|
+
if ((params.onComplete === OnApplicationComplete.NoOpOC || !params.onComplete) &&
|
|
757
|
+
getArc56Method(params.method, this._appSpec).method.readonly) {
|
|
651
758
|
const result = await this._algorand
|
|
652
759
|
.newGroup()
|
|
653
760
|
.addAppCallMethodCall(await this.params.call(params))
|
|
654
761
|
.simulate({
|
|
655
|
-
allowUnnamedResources: params.populateAppCallResources,
|
|
762
|
+
allowUnnamedResources: params.populateAppCallResources ?? true,
|
|
656
763
|
// Simulate calls for a readonly method shouldn't invoke signing
|
|
657
764
|
skipSignatures: true,
|
|
658
765
|
});
|
|
@@ -712,7 +819,7 @@ class AppClient {
|
|
|
712
819
|
if (!sender && !this._defaultSender) {
|
|
713
820
|
throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`);
|
|
714
821
|
}
|
|
715
|
-
return sender ?? this._defaultSender;
|
|
822
|
+
return typeof sender === 'string' ? Address.fromString(sender) : (sender ?? this._defaultSender);
|
|
716
823
|
}
|
|
717
824
|
/** Returns the signer for a call, using the provided signer or the `defaultSigner`
|
|
718
825
|
* if no signer was provided and the call will use default sender
|
|
@@ -749,7 +856,7 @@ class AppClient {
|
|
|
749
856
|
return await call();
|
|
750
857
|
}
|
|
751
858
|
catch (e) {
|
|
752
|
-
throw this.exposeLogicError(e);
|
|
859
|
+
throw await this.exposeLogicError(e);
|
|
753
860
|
}
|
|
754
861
|
}
|
|
755
862
|
getBoxMethods() {
|
|
@@ -917,7 +1024,7 @@ class ApplicationClient {
|
|
|
917
1024
|
}
|
|
918
1025
|
else {
|
|
919
1026
|
this._appId = 0;
|
|
920
|
-
this._creator = appIdentifier.creatorAddress;
|
|
1027
|
+
this._creator = appIdentifier.creatorAddress?.toString();
|
|
921
1028
|
if (appIdentifier.findExistingUsing instanceof Indexer) {
|
|
922
1029
|
this.indexer = appIdentifier.findExistingUsing;
|
|
923
1030
|
}
|
|
@@ -928,7 +1035,7 @@ class ApplicationClient {
|
|
|
928
1035
|
this.existingDeployments = appIdentifier.findExistingUsing;
|
|
929
1036
|
}
|
|
930
1037
|
}
|
|
931
|
-
this._appAddress = algosdk.getApplicationAddress(this._appId);
|
|
1038
|
+
this._appAddress = algosdk.getApplicationAddress(this._appId).toString();
|
|
932
1039
|
this.sender = sender;
|
|
933
1040
|
this.params = params;
|
|
934
1041
|
}
|
|
@@ -1108,12 +1215,12 @@ class ApplicationClient {
|
|
|
1108
1215
|
if (result.confirmation) {
|
|
1109
1216
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1110
1217
|
this._appId = result.confirmation.applicationIndex;
|
|
1111
|
-
this._appAddress = getApplicationAddress(this._appId);
|
|
1218
|
+
this._appAddress = getApplicationAddress(this._appId).toString();
|
|
1112
1219
|
}
|
|
1113
1220
|
return { ...result, ...{ compiledApproval: approvalCompiled, compiledClear: clearCompiled } };
|
|
1114
1221
|
}
|
|
1115
1222
|
catch (e) {
|
|
1116
|
-
throw this.exposeLogicError(e);
|
|
1223
|
+
throw await this.exposeLogicError(e);
|
|
1117
1224
|
}
|
|
1118
1225
|
}
|
|
1119
1226
|
/**
|
|
@@ -1147,7 +1254,7 @@ class ApplicationClient {
|
|
|
1147
1254
|
return { ...result, ...{ compiledApproval: approvalCompiled, compiledClear: clearCompiled } };
|
|
1148
1255
|
}
|
|
1149
1256
|
catch (e) {
|
|
1150
|
-
throw this.exposeLogicError(e);
|
|
1257
|
+
throw await this.exposeLogicError(e);
|
|
1151
1258
|
}
|
|
1152
1259
|
}
|
|
1153
1260
|
/**
|
|
@@ -1473,7 +1580,7 @@ class ApplicationClient {
|
|
|
1473
1580
|
if (!app) {
|
|
1474
1581
|
return {
|
|
1475
1582
|
appId: 0,
|
|
1476
|
-
appAddress: getApplicationAddress(0),
|
|
1583
|
+
appAddress: getApplicationAddress(0).toString(),
|
|
1477
1584
|
};
|
|
1478
1585
|
}
|
|
1479
1586
|
return app;
|
|
@@ -1500,7 +1607,7 @@ class ApplicationClient {
|
|
|
1500
1607
|
.toString()
|
|
1501
1608
|
.split('\n'),
|
|
1502
1609
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1503
|
-
isClear ? this._clearSourceMap : this._approvalSourceMap);
|
|
1610
|
+
(pc) => (isClear ? this._clearSourceMap : this._approvalSourceMap)?.getLocationForPc(pc)?.line);
|
|
1504
1611
|
else
|
|
1505
1612
|
return e;
|
|
1506
1613
|
}
|