@algorandfoundation/algorand-typescript-testing 1.2.0-beta.5 → 1.2.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.
Files changed (37) hide show
  1. package/abi-metadata.d.ts +1 -4
  2. package/{arc4-n2Wsvn7m.js → arc4-BJqa8OLY.js} +8 -8
  3. package/arc4-BJqa8OLY.js.map +1 -0
  4. package/{asset-params-h3yvuYRB.js → asset-params-fNVQR9zo.js} +139 -180
  5. package/asset-params-fNVQR9zo.js.map +1 -0
  6. package/impl/primitives.d.ts +5 -5
  7. package/index.mjs +74 -146
  8. package/index.mjs.map +1 -1
  9. package/{inner-transactions-zu413Oyy.js → inner-transactions-CyOfHlQE.js} +12 -12
  10. package/inner-transactions-CyOfHlQE.js.map +1 -0
  11. package/internal/arc4.mjs +5 -5
  12. package/internal/index.mjs +22 -22
  13. package/internal/index.mjs.map +1 -1
  14. package/internal/op.mjs +5 -5
  15. package/{op-DALTbhcE.js → op-CoVj3SKE.js} +5 -5
  16. package/{op-DALTbhcE.js.map → op-CoVj3SKE.js.map} +1 -1
  17. package/package.json +1 -1
  18. package/{program-factory-Dwx3qOoD.js → program-factory-Ce2FTkME.js} +69 -103
  19. package/program-factory-Ce2FTkME.js.map +1 -0
  20. package/{pure-n2ao0Pz-.js → pure-CF6gNkhc.js} +79 -82
  21. package/pure-CF6gNkhc.js.map +1 -0
  22. package/{runtime-helpers-Dr08TIYb.js → runtime-helpers-CgzUP5Nx.js} +22 -34
  23. package/runtime-helpers-CgzUP5Nx.js.map +1 -0
  24. package/runtime-helpers.mjs +3 -3
  25. package/subcontexts/ledger-context.d.ts +3 -3
  26. package/test-execution-context.d.ts +9 -15
  27. package/test-transformer/jest-transformer.mjs +1 -1
  28. package/test-transformer/vitest-transformer.mjs +1 -1
  29. package/{utils-CUFDPzEr.js → utils-Dm6-NB1d.js} +78 -161
  30. package/utils-Dm6-NB1d.js.map +1 -0
  31. package/arc4-n2Wsvn7m.js.map +0 -1
  32. package/asset-params-h3yvuYRB.js.map +0 -1
  33. package/inner-transactions-zu413Oyy.js.map +0 -1
  34. package/program-factory-Dwx3qOoD.js.map +0 -1
  35. package/pure-n2ao0Pz-.js.map +0 -1
  36. package/runtime-helpers-Dr08TIYb.js.map +0 -1
  37. package/utils-CUFDPzEr.js.map +0 -1
package/abi-metadata.d.ts CHANGED
@@ -1,4 +1 @@
1
- import { Contract } from './impl/contract';
2
- export declare const getContractByName: (contractFullname: string) => {
3
- new (): Contract;
4
- } | undefined;
1
+ export {};
@@ -1,9 +1,9 @@
1
1
  import * as arc4$1 from '@algorandfoundation/algorand-typescript/arc4';
2
2
  import { OnCompleteAction } from '@algorandfoundation/algorand-typescript';
3
- import { b as getContractMethod, g as getContractMethodAbiMetadata, C as Contract, c as abimethod, d as baremethod, r as readonly } from './runtime-helpers-Dr08TIYb.js';
4
- import { w as lazyContext, a0 as sizeOf } from './utils-CUFDPzEr.js';
5
- import { A as ApplicationCallInnerTxnContext, m as methodSelector } from './inner-transactions-zu413Oyy.js';
6
- import { A as Address, B as Bool, c as Byte, d as DynamicArray, D as DynamicBytes, F as FixedArray, R as ReferenceArray, e as StaticArray, f as StaticBytes, S as Str, h as Struct, T as Tuple, i as UFixed, U as Uint, j as convertBytes, k as decodeArc4, l as encodeArc4 } from './asset-params-h3yvuYRB.js';
3
+ import { b as getContractMethod, g as getContractMethodAbiMetadata, C as Contract, c as abimethod, d as baremethod, r as readonly } from './runtime-helpers-CgzUP5Nx.js';
4
+ import { v as lazyContext, a0 as sizeOf } from './utils-Dm6-NB1d.js';
5
+ import { A as ApplicationCallInnerTxnContext, m as methodSelector } from './inner-transactions-CyOfHlQE.js';
6
+ import { A as Address, B as Bool, c as Byte, d as DynamicArray, D as DynamicBytes, F as FixedArray, R as ReferenceArray, e as StaticArray, f as StaticBytes, S as Str, h as Struct, T as Tuple, i as UFixed, U as Uint, j as convertBytes, k as decodeArc4, l as encodeArc4 } from './asset-params-fNVQR9zo.js';
7
7
 
8
8
  function _mergeNamespaces(n, m) {
9
9
  m.forEach(function (e) {
@@ -23,9 +23,9 @@ function _mergeNamespaces(n, m) {
23
23
  /** @internal */
24
24
  function compileArc4(contract, options) {
25
25
  let app;
26
- const compiledAppEntry = lazyContext.value.getCompiledAppEntry(contract);
27
- if (compiledAppEntry !== undefined) {
28
- app = lazyContext.ledger.applicationDataMap.get(compiledAppEntry.value);
26
+ const compiledAppId = lazyContext.value.getCompiledApp(contract);
27
+ if (compiledAppId !== undefined) {
28
+ app = lazyContext.ledger.applicationDataMap.get(compiledAppId);
29
29
  }
30
30
  if (options?.templateVars) {
31
31
  Object.entries(options.templateVars).forEach(([key, value]) => {
@@ -135,4 +135,4 @@ var arc4 = /*#__PURE__*/_mergeNamespaces({
135
135
  }, [arc4$1]);
136
136
 
137
137
  export { arc4 as a, abiCall as b, compileArc4 as c, getApplicationCallInnerTxnContext as g };
138
- //# sourceMappingURL=arc4-n2Wsvn7m.js.map
138
+ //# sourceMappingURL=arc4-BJqa8OLY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arc4-BJqa8OLY.js","sources":["../src/impl/c2c.ts","../src/internal/arc4.ts"],"sourcesContent":["import { type CompileContractOptions, type Contract, OnCompleteAction } from '@algorandfoundation/algorand-typescript'\nimport type {\n BareCreateApplicationCallFields,\n ContractProxy,\n TypedApplicationCallFields,\n} from '@algorandfoundation/algorand-typescript/arc4'\nimport { getContractMethod, getContractMethodAbiMetadata } from '../abi-metadata'\nimport { lazyContext } from '../context-helpers/internal-context'\nimport type { ConstructorFor, DeliberateAny, InstanceMethod } from '../typescript-helpers'\nimport type { ApplicationCallInnerTxn } from './inner-transactions'\nimport { ApplicationCallInnerTxnContext } from './inner-transactions'\nimport { methodSelector } from './method-selector'\nimport type { ApplicationData } from './reference'\n\n/** @internal */\nexport function compileArc4<TContract extends Contract>(\n contract: ConstructorFor<TContract>,\n options?: CompileContractOptions,\n): ContractProxy<TContract> {\n let app: ApplicationData | undefined\n const compiledAppId = lazyContext.value.getCompiledApp(contract)\n if (compiledAppId !== undefined) {\n app = lazyContext.ledger.applicationDataMap.get(compiledAppId)\n }\n\n if (options?.templateVars) {\n Object.entries(options.templateVars).forEach(([key, value]) => {\n lazyContext.value.setTemplateVar(key, value, options.templateVarsPrefix)\n })\n }\n\n return {\n call: new Proxy({} as unknown as TContract, {\n get: (_target, prop) => {\n return (methodArgs: TypedApplicationCallFields<DeliberateAny[]>) => {\n const selector = methodSelector({ method: prop as string, contract })\n const abiMetadata = getContractMethodAbiMetadata(contract, prop as string)\n const onCompleteActions = abiMetadata?.allowActions?.map((action) => OnCompleteAction[action])\n const itxnContext = ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields(\n {\n ...getCommonApplicationCallFields(app, options),\n onCompletion: onCompleteActions?.[0],\n ...methodArgs,\n },\n selector,\n abiMetadata?.resourceEncoding,\n )\n invokeAbiCall(itxnContext)\n return {\n itxn: itxnContext,\n returnValue: itxnContext.loggedReturnValue,\n }\n }\n },\n }),\n\n bareCreate: (methodArgs?: BareCreateApplicationCallFields) => {\n const itxnContext = ApplicationCallInnerTxnContext.createFromBareCreateApplicationCallFields({\n ...getCommonApplicationCallFields(app, options),\n ...methodArgs,\n })\n invokeAbiCall(itxnContext)\n return itxnContext\n },\n approvalProgram: app?.application.approvalProgram ?? [lazyContext.any.bytes(10), lazyContext.any.bytes(10)],\n clearStateProgram: app?.application.clearStateProgram ?? [lazyContext.any.bytes(10), lazyContext.any.bytes(10)],\n extraProgramPages: options?.extraProgramPages ?? app?.application.extraProgramPages ?? lazyContext.any.uint64(),\n globalUints: options?.globalUints ?? app?.application.globalNumUint ?? lazyContext.any.uint64(),\n globalBytes: options?.globalBytes ?? app?.application.globalNumBytes ?? lazyContext.any.uint64(),\n localUints: options?.localUints ?? app?.application.localNumUint ?? lazyContext.any.uint64(),\n localBytes: options?.localBytes ?? app?.application.localNumBytes ?? lazyContext.any.uint64(),\n } as unknown as ContractProxy<TContract>\n}\n\n/** @internal */\nexport const invokeAbiCall = (itxnContext: ApplicationCallInnerTxnContext) => {\n lazyContext.value.notifyApplicationSpies(itxnContext)\n lazyContext.txn.activeGroup.addInnerTransactionGroup(...(itxnContext.itxns ?? []), itxnContext)\n}\nconst getCommonApplicationCallFields = (app: ApplicationData | undefined, options: CompileContractOptions | undefined) => ({\n approvalProgram: app?.application.approvalProgram ?? [lazyContext.any.bytes(10), lazyContext.any.bytes(10)],\n clearStateProgram: app?.application.clearStateProgram ?? [lazyContext.any.bytes(10), lazyContext.any.bytes(10)],\n extraProgramPages: options?.extraProgramPages ?? app?.application.extraProgramPages ?? lazyContext.any.uint64(),\n globalNumUint: options?.globalUints ?? app?.application.globalNumUint ?? lazyContext.any.uint64(),\n globalNumBytes: options?.globalBytes ?? app?.application.globalNumBytes ?? lazyContext.any.uint64(),\n localNumUint: options?.localUints ?? app?.application.localNumUint ?? lazyContext.any.uint64(),\n localNumBytes: options?.localBytes ?? app?.application.localNumBytes ?? lazyContext.any.uint64(),\n})\n\n/** @internal */\nexport function getApplicationCallInnerTxnContext<TArgs extends DeliberateAny[], TReturn = void>(\n method: InstanceMethod<Contract, TArgs, TReturn>,\n methodArgs: TypedApplicationCallFields<TArgs>,\n contract?: Contract | { new (): Contract },\n) {\n const abiMetadata = contract ? getContractMethodAbiMetadata(contract, method.name) : undefined\n const selector = methodSelector({ method, contract })\n return ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields<TReturn>(\n {\n ...methodArgs,\n onCompletion: methodArgs.onCompletion ?? abiMetadata?.allowActions?.map((action) => OnCompleteAction[action])[0],\n },\n selector,\n abiMetadata?.resourceEncoding,\n )\n}\n/** @internal */\nexport function abiCall<TArgs extends DeliberateAny[], TReturn>(\n contractFullName: string,\n method: string,\n methodArgs: TypedApplicationCallFields<TArgs>,\n): { itxn: ApplicationCallInnerTxn; returnValue: TReturn | undefined } {\n const { method: methodInstance, contract: contractInstance } = getContractMethod(contractFullName, method)\n\n const itxnContext = getApplicationCallInnerTxnContext<TArgs, TReturn>(methodInstance, methodArgs, contractInstance)\n\n invokeAbiCall(itxnContext)\n\n return {\n itxn: itxnContext,\n returnValue: itxnContext.loggedReturnValue,\n }\n}\n","/** @internal */\nexport * from '@algorandfoundation/algorand-typescript/arc4'\n/** @internal */\nexport { abiCall, compileArc4 } from '../impl/c2c'\n/** @internal */\nexport { abimethod, baremethod, Contract, readonly } from '../impl/contract'\n/** @internal */\nexport {\n Address,\n Bool,\n Byte,\n convertBytes,\n decodeArc4,\n DynamicArray,\n DynamicBytes,\n encodeArc4,\n FixedArray,\n ReferenceArray,\n sizeOf,\n StaticArray,\n StaticBytes,\n Str,\n Struct,\n Tuple,\n UFixed,\n Uint,\n} from '../impl/encoded-types'\n/** @internal */\nexport { methodSelector } from '../impl/method-selector'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAcA;AACM,SAAU,WAAW,CACzB,QAAmC,EACnC,OAAgC,EAAA;AAEhC,IAAA,IAAI,GAAgC;IACpC,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;AAChE,IAAA,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC;IAChE;AAEA,IAAA,IAAI,OAAO,EAAE,YAAY,EAAE;AACzB,QAAA,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC5D,YAAA,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC;AAC1E,QAAA,CAAC,CAAC;IACJ;IAEA,OAAO;AACL,QAAA,IAAI,EAAE,IAAI,KAAK,CAAC,EAA0B,EAAE;AAC1C,YAAA,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,KAAI;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