@algorandfoundation/algorand-typescript-testing 1.0.0-alpha.15 → 1.0.0-alpha.16
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/impl/compiled.d.ts +3 -0
- package/impl/encoded-types.d.ts +1 -1
- package/index.mjs +60 -4
- package/index.mjs.map +1 -1
- package/package.json +2 -2
- package/{runtime-helpers-BtUWpK9t.js → runtime-helpers-qRDREJih.js} +44 -4
- package/runtime-helpers-qRDREJih.js.map +1 -0
- package/runtime-helpers.d.ts +1 -0
- package/runtime-helpers.mjs +1 -1
- package/subcontexts/ledger-context.d.ts +2 -1
- package/test-execution-context.d.ts +7 -3
- package/test-transformer/index.mjs +1 -1
- package/test-transformer/index.mjs.map +1 -1
- package/typescript-helpers.d.ts +1 -0
- package/runtime-helpers-BtUWpK9t.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BaseContract, CompileContractOptions, CompiledContract, CompiledLogicSig, CompileLogicSigOptions, LogicSig } from '@algorandfoundation/algorand-typescript';
|
|
2
|
+
import { ConstructorFor } from '../typescript-helpers';
|
|
3
|
+
export declare function compileImpl(artefact: ConstructorFor<BaseContract> | ConstructorFor<LogicSig>, options?: CompileContractOptions | CompileLogicSigOptions): CompiledLogicSig | CompiledContract;
|
package/impl/encoded-types.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ export declare function interpretAsArc4Impl<T extends ARC4Encoded>(typeInfoStrin
|
|
|
177
177
|
export declare const arc4Encoders: Record<string, fromBytes<DeliberateAny>>;
|
|
178
178
|
export declare const getArc4Encoder: <T>(typeInfo: TypeInfo, encoders?: Record<string, fromBytes<DeliberateAny>>) => fromBytes<T>;
|
|
179
179
|
export declare const getArc4TypeName: (typeInfo: TypeInfo) => string | undefined;
|
|
180
|
-
export declare function decodeArc4Impl<T>(sourceTypeInfoString: string, bytes: internal.primitives.StubBytesCompat): T;
|
|
180
|
+
export declare function decodeArc4Impl<T>(sourceTypeInfoString: string, bytes: internal.primitives.StubBytesCompat, prefix?: 'none' | 'log'): T;
|
|
181
181
|
export declare function encodeArc4Impl<T>(_targetTypeInfoString: string, source: T): bytes;
|
|
182
182
|
export declare const getArc4Encoded: (value: DeliberateAny) => ARC4Encoded;
|
|
183
183
|
export {};
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bytes, Uint64, Account, internal, Base64, op, arc4, TransactionType, Asset, Application, BigUint, BaseContract, Contract } from '@algorandfoundation/algorand-typescript';
|
|
2
|
-
import { a as asMaybeUint64Cls, l as lazyContext, b as asUint64, c as asBytes, t as toBytes, d as asMaybeBytesCls, e as asBigUint, B as BITS_IN_BYTE, M as MAX_BYTES_SIZE, f as asUint64Cls, g as asBytesCls, h as testInvariant, i as MAX_UINT8, j as binaryStringToBytes, U as UINT64_SIZE, n as notImplementedError, k as MAX_UINT64, m as asNumber, o as MAX_BOX_SIZE, p as asUint8Array, q as conactUint8Arrays, r as getObjectReference, s as getApplicationAddress, u as MIN_TXN_FEE, D as DEFAULT_ACCOUNT_MIN_BALANCE, v as DEFAULT_MAX_TXN_LIFE, Z as ZERO_ADDRESS, w as DEFAULT_ASSET_CREATE_MIN_BALANCE, x as DEFAULT_ASSET_OPT_IN_MIN_BALANCE, y as DEFAULT_GLOBAL_GENESIS_HASH, E as EllipticCurve, z as ecdsaPkDecompress, A as ecdsaPkRecover, C as ecdsaVerify, F as ed25519verify, G as ed25519verifyBare, H as keccak256, I as sha256, J as sha3_256, K as sha512_256, L as vrfVerify, N as combineIntoMaxBytePages, O as MAX_ITEMS_IN_LOG, P as ABI_RETURN_VALUE_LOG_PREFIX, Q as getRandomBytes, R as getArc4Encoder, S as AccountCls, T as ApplicationCls, V as AssetCls, W as arc4Encoders, X as AccountMap, Y as getGenericTypeInfo, _ as getArc4Selector, $ as isContractProxy, a0 as getContractMethodAbiMetadata, a1 as copyAbiMetadatas, a2 as getContractAbiMetadata, a3 as BytesMap, a4 as iterBigInt, a5 as Uint64Map, a6 as AssetHolding$1, a7 as asBigInt, a8 as TRANSACTION_GROUP_MAX_SIZE, a9 as getRandomBigInt, aa as AccountData, ab as ApplicationData, ac as AddressImpl, ad as UintNImpl, ae as getRandomNumber, af as MAX_UINT16, ag as MAX_UINT32, ah as MAX_UINT128, ai as MAX_UINT256, aj as MAX_UINT512, ak as DynamicBytesImpl, al as StrImpl, am as captureMethodConfig, an as DEFAULT_TEMPLATE_VAR_PREFIX } from './runtime-helpers-
|
|
2
|
+
import { a as asMaybeUint64Cls, l as lazyContext, b as asUint64, c as asBytes, t as toBytes, d as asMaybeBytesCls, e as asBigUint, B as BITS_IN_BYTE, M as MAX_BYTES_SIZE, f as asUint64Cls, g as asBytesCls, h as testInvariant, i as MAX_UINT8, j as binaryStringToBytes, U as UINT64_SIZE, n as notImplementedError, k as MAX_UINT64, m as asNumber, o as MAX_BOX_SIZE, p as asUint8Array, q as conactUint8Arrays, r as getObjectReference, s as getApplicationAddress, u as MIN_TXN_FEE, D as DEFAULT_ACCOUNT_MIN_BALANCE, v as DEFAULT_MAX_TXN_LIFE, Z as ZERO_ADDRESS, w as DEFAULT_ASSET_CREATE_MIN_BALANCE, x as DEFAULT_ASSET_OPT_IN_MIN_BALANCE, y as DEFAULT_GLOBAL_GENESIS_HASH, E as EllipticCurve, z as ecdsaPkDecompress, A as ecdsaPkRecover, C as ecdsaVerify, F as ed25519verify, G as ed25519verifyBare, H as keccak256, I as sha256, J as sha3_256, K as sha512_256, L as vrfVerify, N as combineIntoMaxBytePages, O as MAX_ITEMS_IN_LOG, P as ABI_RETURN_VALUE_LOG_PREFIX, Q as getRandomBytes, R as getArc4Encoder, S as AccountCls, T as ApplicationCls, V as AssetCls, W as arc4Encoders, X as AccountMap, Y as getGenericTypeInfo, _ as getArc4Selector, $ as isContractProxy, a0 as getContractMethodAbiMetadata, a1 as copyAbiMetadatas, a2 as getContractAbiMetadata, a3 as BytesMap, a4 as iterBigInt, a5 as Uint64Map, a6 as AssetHolding$1, a7 as asBigInt, a8 as TRANSACTION_GROUP_MAX_SIZE, a9 as getRandomBigInt, aa as AccountData, ab as ApplicationData, ac as AddressImpl, ad as UintNImpl, ae as getRandomNumber, af as MAX_UINT16, ag as MAX_UINT32, ah as MAX_UINT128, ai as MAX_UINT256, aj as MAX_UINT512, ak as DynamicBytesImpl, al as StrImpl, am as captureMethodConfig, an as DEFAULT_TEMPLATE_VAR_PREFIX } from './runtime-helpers-qRDREJih.js';
|
|
3
3
|
import { randomBytes } from 'crypto';
|
|
4
4
|
import '@algorandfoundation/algorand-typescript/arc4';
|
|
5
5
|
import '@algorandfoundation/puya-ts';
|
|
@@ -2864,8 +2864,15 @@ class ApplicationInnerTxn extends ApplicationTransaction {
|
|
|
2864
2864
|
/* @internal */
|
|
2865
2865
|
constructor(fields) {
|
|
2866
2866
|
const { appId, approvalProgram, clearStateProgram, onCompletion, appArgs, accounts, assets, apps, ...rest } = mapCommonFields(fields);
|
|
2867
|
+
const compiledApp = appId === undefined && approvalProgram !== undefined
|
|
2868
|
+
? lazyContext.ledger.getApplicationForApprovalProgram(approvalProgram)
|
|
2869
|
+
: undefined;
|
|
2867
2870
|
super({
|
|
2868
|
-
appId: appId
|
|
2871
|
+
appId: appId === undefined && compiledApp
|
|
2872
|
+
? compiledApp
|
|
2873
|
+
: appId instanceof internal.primitives.Uint64Cls
|
|
2874
|
+
? getApp(appId)
|
|
2875
|
+
: appId,
|
|
2869
2876
|
onCompletion: typeof onCompletion === 'string'
|
|
2870
2877
|
? onCompletion
|
|
2871
2878
|
: onCompletion !== undefined
|
|
@@ -2879,6 +2886,7 @@ class ApplicationInnerTxn extends ApplicationTransaction {
|
|
|
2879
2886
|
accounts: accounts?.map((x) => x),
|
|
2880
2887
|
assets: assets?.map((x) => x),
|
|
2881
2888
|
apps: apps?.map((x) => x),
|
|
2889
|
+
createdApp: compiledApp,
|
|
2882
2890
|
...rest,
|
|
2883
2891
|
});
|
|
2884
2892
|
}
|
|
@@ -3562,6 +3570,27 @@ class LedgerContext {
|
|
|
3562
3570
|
}
|
|
3563
3571
|
throw internal.errors.internalError('Unknown contract, check correct testing context is active');
|
|
3564
3572
|
}
|
|
3573
|
+
getApplicationForApprovalProgram(approvalProgram) {
|
|
3574
|
+
if (approvalProgram === undefined) {
|
|
3575
|
+
return undefined;
|
|
3576
|
+
}
|
|
3577
|
+
const entries = this.applicationDataMap.entries();
|
|
3578
|
+
let next = entries.next().value;
|
|
3579
|
+
let found = false;
|
|
3580
|
+
while (next && !found) {
|
|
3581
|
+
found = next[1].application.approvalProgram === approvalProgram;
|
|
3582
|
+
if (!found) {
|
|
3583
|
+
next = entries.next().value;
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
if (found && next) {
|
|
3587
|
+
const appId = asUint64(next[0]);
|
|
3588
|
+
if (this.applicationDataMap.has(appId)) {
|
|
3589
|
+
return Application(appId);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
return undefined;
|
|
3593
|
+
}
|
|
3565
3594
|
/**
|
|
3566
3595
|
* Update asset holdings for account, only specified values will be updated.
|
|
3567
3596
|
* Account will also be opted-in to asset
|
|
@@ -4206,6 +4235,8 @@ class TestExecutionContext {
|
|
|
4206
4235
|
#defaultSender;
|
|
4207
4236
|
#activeLogicSigArgs;
|
|
4208
4237
|
#template_vars = {};
|
|
4238
|
+
#compiledApps = [];
|
|
4239
|
+
#compiledLogicSigs = [];
|
|
4209
4240
|
constructor(defaultSenderAddress) {
|
|
4210
4241
|
internal.ctxMgr.instance = this;
|
|
4211
4242
|
this.#contractContext = new ContractContext();
|
|
@@ -4299,8 +4330,32 @@ class TestExecutionContext {
|
|
|
4299
4330
|
this.#activeLogicSigArgs = [];
|
|
4300
4331
|
}
|
|
4301
4332
|
}
|
|
4302
|
-
setTemplateVar(name, value) {
|
|
4303
|
-
this.#template_vars[DEFAULT_TEMPLATE_VAR_PREFIX + name] = value;
|
|
4333
|
+
setTemplateVar(name, value, prefix) {
|
|
4334
|
+
this.#template_vars[(prefix ?? DEFAULT_TEMPLATE_VAR_PREFIX) + name] = value;
|
|
4335
|
+
}
|
|
4336
|
+
getCompiledApp(contract) {
|
|
4337
|
+
return this.#compiledApps.find(([c, _]) => c === contract);
|
|
4338
|
+
}
|
|
4339
|
+
setCompiledApp(c, appId) {
|
|
4340
|
+
const existing = this.getCompiledApp(c);
|
|
4341
|
+
if (existing) {
|
|
4342
|
+
existing[1] = appId;
|
|
4343
|
+
}
|
|
4344
|
+
else {
|
|
4345
|
+
this.#compiledApps.push([c, appId]);
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
getCompiledLogicSig(logicsig) {
|
|
4349
|
+
return this.#compiledLogicSigs.find(([c, _]) => c === logicsig);
|
|
4350
|
+
}
|
|
4351
|
+
setCompiledLogicSig(c, account) {
|
|
4352
|
+
const existing = this.getCompiledLogicSig(c);
|
|
4353
|
+
if (existing) {
|
|
4354
|
+
existing[1] = account;
|
|
4355
|
+
}
|
|
4356
|
+
else {
|
|
4357
|
+
this.#compiledLogicSigs.push([c, account]);
|
|
4358
|
+
}
|
|
4304
4359
|
}
|
|
4305
4360
|
reset() {
|
|
4306
4361
|
this.#contractContext = new ContractContext();
|
|
@@ -4308,6 +4363,7 @@ class TestExecutionContext {
|
|
|
4308
4363
|
this.#txnContext = new TransactionContext();
|
|
4309
4364
|
this.#activeLogicSigArgs = [];
|
|
4310
4365
|
this.#template_vars = {};
|
|
4366
|
+
this.#compiledApps = [];
|
|
4311
4367
|
internal.ctxMgr.reset();
|
|
4312
4368
|
internal.ctxMgr.instance = this;
|
|
4313
4369
|
}
|