@algorandfoundation/algorand-typescript-testing 1.0.0-alpha.20 → 1.0.0-alpha.22

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/{arc4-CC8mc2EI.js → arc4-B_K-EWzS.js} +9 -5
  2. package/{arc4-CC8mc2EI.js.map → arc4-B_K-EWzS.js.map} +1 -1
  3. package/{asset-params-C0sz_Aya.js → asset-params-DJfgJaRP.js} +9 -5
  4. package/asset-params-DJfgJaRP.js.map +1 -0
  5. package/constants.d.ts +9 -0
  6. package/{crypto-DumZR3uP.js → crypto-Bl2XtehF.js} +152 -82
  7. package/crypto-Bl2XtehF.js.map +1 -0
  8. package/encoders.d.ts +1 -0
  9. package/impl/encoded-types.d.ts +10 -9
  10. package/impl/primitives.d.ts +4 -4
  11. package/impl/state.d.ts +4 -0
  12. package/index.mjs +6 -6
  13. package/{inner-transactions-DrYPl6aW.js → inner-transactions-CTb4hThO.js} +45 -8
  14. package/inner-transactions-CTb4hThO.js.map +1 -0
  15. package/internal/arc4.mjs +5 -5
  16. package/internal/index.mjs +14 -12
  17. package/internal/index.mjs.map +1 -1
  18. package/internal/op.mjs +4 -4
  19. package/{op-gBBDFbF6.js → op-B_DdAxoB.js} +4 -4
  20. package/{op-gBBDFbF6.js.map → op-B_DdAxoB.js.map} +1 -1
  21. package/package.json +3 -3
  22. package/{program-factory-7SPe2HW0.js → program-factory-CArwYuh6.js} +15 -8
  23. package/program-factory-CArwYuh6.js.map +1 -0
  24. package/{pure-A1MFEXtY.js → pure-bxVJhKDo.js} +3 -3
  25. package/{pure-A1MFEXtY.js.map → pure-bxVJhKDo.js.map} +1 -1
  26. package/{runtime-helpers-BszTaREL.js → runtime-helpers-CMc2bPR1.js} +40 -3
  27. package/runtime-helpers-CMc2bPR1.js.map +1 -0
  28. package/runtime-helpers.mjs +2 -2
  29. package/test-transformer/jest-transformer.mjs +1 -1
  30. package/test-transformer/node-factory.d.ts +1 -1
  31. package/test-transformer/vitest-transformer.mjs +1 -1
  32. package/util.d.ts +1 -1
  33. package/asset-params-C0sz_Aya.js.map +0 -1
  34. package/crypto-DumZR3uP.js.map +0 -1
  35. package/inner-transactions-DrYPl6aW.js.map +0 -1
  36. package/program-factory-7SPe2HW0.js.map +0 -1
  37. package/runtime-helpers-BszTaREL.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import * as arc4$1 from '@algorandfoundation/algorand-typescript/arc4';
2
2
  import { OnCompleteAction } from '@algorandfoundation/algorand-typescript';
3
- import { g as getContractMethodAbiMetadata, C as Contract, b as abimethod, c as baremethod } from './runtime-helpers-BszTaREL.js';
4
- import { v as lazyContext } from './crypto-DumZR3uP.js';
5
- import { m as methodSelector, q as ApplicationCallInnerTxnContext } from './inner-transactions-DrYPl6aW.js';
3
+ import { g as getContractMethodAbiMetadata, C as Contract, b as abimethod, c as baremethod } from './runtime-helpers-CMc2bPR1.js';
4
+ import { v as lazyContext } from './crypto-Bl2XtehF.js';
5
+ import { m as methodSelector, q as ApplicationCallInnerTxnContext } from './inner-transactions-CTb4hThO.js';
6
6
 
7
7
  function _mergeNamespaces(n, m) {
8
8
  m.forEach(function (e) {
@@ -81,8 +81,12 @@ const getCommonApplicationCallFields = (app, options) => ({
81
81
  localNumBytes: options?.localBytes ?? app?.application.localNumBytes ?? lazyContext.any.uint64(),
82
82
  });
83
83
  function abiCall(method, methodArgs, contract) {
84
+ const abiMetadata = contract ? getContractMethodAbiMetadata(contract, method.name) : undefined;
84
85
  const selector = methodSelector(method, contract);
85
- const itxnContext = ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields(methodArgs, selector);
86
+ const itxnContext = ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields({
87
+ ...methodArgs,
88
+ onCompletion: methodArgs.onCompletion ?? abiMetadata?.allowActions?.map((action) => OnCompleteAction[action])[0],
89
+ }, selector);
86
90
  invokeCallback(itxnContext);
87
91
  return {
88
92
  itxn: itxnContext,
@@ -101,4 +105,4 @@ var arc4 = /*#__PURE__*/_mergeNamespaces({
101
105
  }, [arc4$1]);
102
106
 
103
107
  export { arc4 as a, abiCall as b, compileArc4 as c };
104
- //# sourceMappingURL=arc4-CC8mc2EI.js.map
108
+ //# sourceMappingURL=arc4-B_K-EWzS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"arc4-CC8mc2EI.js","sources":["../src/impl/c2c.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 { 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\nexport function compileArc4<TContract extends Contract>(\n contract: ConstructorFor<TContract>,\n options?: CompileContractOptions,\n): ContractProxy<TContract> {\n let app: ApplicationData | undefined\n const compiledAppEntry = lazyContext.value.getCompiledAppEntry(contract)\n if (compiledAppEntry !== undefined) {\n app = lazyContext.ledger.applicationDataMap.get(compiledAppEntry.value)\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(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 )\n invokeCallback(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 invokeCallback(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\nconst invokeCallback = (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\nexport function abiCall<TArgs extends DeliberateAny[], TReturn>(\n method: InstanceMethod<Contract, TArgs, TReturn>,\n methodArgs: TypedApplicationCallFields<TArgs>,\n contract?: Contract | { new (): Contract },\n): { itxn: ApplicationCallInnerTxn; returnValue: TReturn | undefined } {\n const selector = methodSelector(method, contract)\n const itxnContext = ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields<TReturn>(methodArgs, selector)\n invokeCallback(itxnContext)\n\n return {\n itxn: itxnContext,\n returnValue: itxnContext.loggedReturnValue,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAcgB,SAAA,WAAW,CACzB,QAAmC,EACnC,OAAgC,EAAA;AAEhC,IAAA,IAAI,GAAgC;IACpC,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC;AACxE,IAAA,IAAI,gBAAgB,KAAK,SAAS,EAAE;AAClC,QAAA,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC;;AAGzE,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,SAAC,CAAC;;IAGJ,OAAO;AACL,QAAA,IAAI,EAAE,IAAI,KAAK,CAAC,EAA0B,EAAE;AAC1C,YAAA,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,KAAI;gBACrB,OAAO,CAAC,UAAuD,KAAI;oBACjE,MAAM,QA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AE,CAAC,CAAC;AAC/G,IAAA,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,GAAG,EAAE,WAAW,CAAC,iBAAiB,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AAC/G,IAAA,aAAa,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,WAAW,CAAC,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AACjG,IAAA,cAAc,EAAE,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,WAAW,CAAC,cAAc,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AACnG,IAAA,YAAY,EAAE,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AAC9F,IAAA,aAAa,EAAE,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,WAAW,CAAC,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AACjG,CAAA,CAAC;SAEc,OAAO,CACrB,MAAgD,EAChD,UAA6C,EAC7C,QAA0C,EAAA;IAE1C,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC;IACjD,MAAM,WAAW,GAAG,8BAA8B,CAAC,oCAAoC,CAAU,UAAU,EAAE,QAAQ,CAAC;IACtH,cAAc,CAAC,WAAW,CAAC;IAE3B,OAAO;AACL,QAAA,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,WAAW,CAAC,iBAAiB;KAC3C;AACH;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"arc4-B_K-EWzS.js","sources":["../src/impl/c2c.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 { 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\nexport function compileArc4<TContract extends Contract>(\n contract: ConstructorFor<TContract>,\n options?: CompileContractOptions,\n): ContractProxy<TContract> {\n let app: ApplicationData | undefined\n const compiledAppEntry = lazyContext.value.getCompiledAppEntry(contract)\n if (compiledAppEntry !== undefined) {\n app = lazyContext.ledger.applicationDataMap.get(compiledAppEntry.value)\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(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 )\n invokeCallback(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 invokeCallback(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\nconst invokeCallback = (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\nexport function abiCall<TArgs extends DeliberateAny[], TReturn>(\n method: InstanceMethod<Contract, TArgs, TReturn>,\n methodArgs: TypedApplicationCallFields<TArgs>,\n contract?: Contract | { new (): Contract },\n): { itxn: ApplicationCallInnerTxn; returnValue: TReturn | undefined } {\n const abiMetadata = contract ? getContractMethodAbiMetadata(contract, method.name) : undefined\n const selector = methodSelector(method, contract)\n const itxnContext = ApplicationCallInnerTxnContext.createFromTypedApplicationCallFields<TReturn>(\n {\n ...methodArgs,\n onCompletion: methodArgs.onCompletion ?? abiMetadata?.allowActions?.map((action) => OnCompleteAction[action])[0],\n },\n selector,\n )\n invokeCallback(itxnContext)\n\n return {\n itxn: itxnContext,\n returnValue: itxnContext.loggedReturnValue,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAcgB,SAAA,WAAW,CACzB,QAAmC,EACnC,OAAgC,EAAA;AAEhC,IAAA,IAAI,GAAgC;IACpC,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,QAAQ,CAAC;AACxE,IAAA,IAAI,gBAAgB,KAAK,SAAS,EAAE;AAClC,QAAA,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC;;AAGzE,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,SAAC,CAAC;;IAGJ,OAAO;AACL,QAAA,IAAI,EAAE,IAAI,KAAK,CAAC,EAA0B,EAAE;AAC1C,YAAA,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,KAAI;gBACrB,OAAO,CAAC,UAAuD,KAAI;oBACjE,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAc,EAAE,QAAQ,CAAC;oBACzD,MAAM,WAAW,GAAG,4BAA4B,CAAC,QAAQ,EAAE,IAAc,CAAC;AAC1E,oBAAA,MAAM,iBAAiB,GAAG,WAAW,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC9F,oBAAA,MAAM,WAAW,GAAG,8BAA8B,CAAC,oCAAoC,CACrF;AACE,wBAAA,GAAG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,GAAG,EAAE,WAAW,CAAC,cAAc,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AACnG,IAAA,YAAY,EAAE,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AAC9F,IAAA,aAAa,EAAE,OAAO,EAAE,UAAU,IAAI,GAAG,EAAE,WAAW,CAAC,aAAa,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE;AACjG,CAAA,CAAC;SAEc,OAAO,CACrB,MAAgD,EAChD,UAA6C,EAC7C,QAA0C,EAAA;AAE1C,IAAA,MAAM,WAAW,GAAG,QAAQ,GAAG,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS;IAC9F,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC;AACjD,IAAA,MAAM,WAAW,GAAG,8BAA8B,CAAC,oCAAoC,CACrF;AACE,QAAA,GAAG,UAAU;QACb,YAAY,EAAE,UAAU,CAAC,YAAY,IAAI,WAAW,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KACjH,EACD,QAAQ,CACT;IACD,cAAc,CAAC,WAAW,CAAC;IAE3B,OAAO;AACL,QAAA,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,WAAW,CAAC,iBAAiB;KAC3C;AACH;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { ARC4Encoded } from '@algorandfoundation/algorand-typescript/arc4';
2
2
  import { encodingUtil } from '@algorandfoundation/puya-ts';
3
- import { k as asMaybeUint64Cls, r as asMaybeBytesCls, a6 as asMaybeBigUintCls, a4 as BytesBackedCls, a5 as Uint64BackedCls, l as asUint64Cls, ai as encodeArc4Impl, I as InternalError, an as nameOfType, aD as getArc4Encoder, aC as arc4Encoders, H as AssetCls, t as ApplicationCls, A as AccountCls, x as Uint64, s as asUint8Array, f as asBytes, C as BigUint, F as Account, E as Bytes, v as lazyContext, h as asUint64 } from './crypto-DumZR3uP.js';
3
+ import { k as asMaybeUint64Cls, r as asMaybeBytesCls, a6 as asMaybeBigUintCls, a4 as BytesBackedCls, a5 as Uint64BackedCls, l as asUint64Cls, aj as encodeArc4Impl, I as InternalError, ap as nameOfType, aF as getArc4Encoder, aE as arc4Encoders, H as AssetCls, t as ApplicationCls, A as AccountCls, ac as tryArc4EncodedLengthImpl, x as Uint64, s as asUint8Array, f as asBytes, C as BigUint, F as Account, E as Bytes, v as lazyContext, h as asUint64 } from './crypto-Bl2XtehF.js';
4
4
 
5
5
  const booleanFromBytes = (val) => {
6
6
  return encodingUtil.uint8ArrayToBigInt(asUint8Array(val)) > 0n;
@@ -40,7 +40,7 @@ const getEncoder = (typeInfo) => {
40
40
  return getArc4Encoder(typeInfo, encoders);
41
41
  };
42
42
  const toBytes = (val) => {
43
- const uint64Val = asMaybeUint64Cls(val);
43
+ const uint64Val = asMaybeUint64Cls(val, false);
44
44
  if (uint64Val !== undefined) {
45
45
  return uint64Val.toBytes().asAlgoTs();
46
46
  }
@@ -62,10 +62,14 @@ const toBytes = (val) => {
62
62
  return val.bytes;
63
63
  }
64
64
  if (Array.isArray(val) || typeof val === 'object') {
65
- return encodeArc4Impl('', val);
65
+ return encodeArc4Impl(undefined, val);
66
66
  }
67
67
  throw new InternalError(`Invalid type for bytes: ${nameOfType(val)}`);
68
68
  };
69
+ const minLengthForType = (typeInfo) => {
70
+ const minArc4StaticLength = tryArc4EncodedLengthImpl(typeInfo);
71
+ return minArc4StaticLength ?? 0;
72
+ };
69
73
 
70
74
  const resolveAppIndex = (appIdOrIndex) => {
71
75
  const input = asUint64(appIdOrIndex);
@@ -197,5 +201,5 @@ const AssetParams = {
197
201
  },
198
202
  };
199
203
 
200
- export { AppParams as A, getApp as a, getAsset as b, AssetParams as c, getEncoder as g, toBytes as t };
201
- //# sourceMappingURL=asset-params-C0sz_Aya.js.map
204
+ export { AppParams as A, getApp as a, getAsset as b, AssetParams as c, getEncoder as g, minLengthForType as m, toBytes as t };
205
+ //# sourceMappingURL=asset-params-DJfgJaRP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-params-DJfgJaRP.js","sources":["../src/encoders.ts","../src/impl/app-params.ts","../src/impl/asset-params.ts"],"sourcesContent":["import type { biguint, bytes, OnCompleteAction, TransactionType, uint64 } from '@algorandfoundation/algorand-typescript'\nimport { ARC4Encoded } from '@algorandfoundation/algorand-typescript/arc4'\nimport { encodingUtil } from '@algorandfoundation/puya-ts'\nimport { InternalError } from './errors'\nimport { BytesBackedCls, Uint64BackedCls } from './impl/base'\nimport { arc4Encoders, encodeArc4Impl, getArc4Encoder, tryArc4EncodedLengthImpl } from './impl/encoded-types'\nimport { BigUint, Uint64, type StubBytesCompat } from './impl/primitives'\nimport { AccountCls, ApplicationCls, AssetCls } from './impl/reference'\nimport type { DeliberateAny } from './typescript-helpers'\nimport { asBytes, asMaybeBigUintCls, asMaybeBytesCls, asMaybeUint64Cls, asUint64Cls, asUint8Array, nameOfType } from './util'\n\nexport type TypeInfo = {\n name: string\n genericArgs?: TypeInfo[] | Record<string, TypeInfo>\n}\n\nexport type fromBytes<T> = (val: Uint8Array | StubBytesCompat, typeInfo: TypeInfo, prefix?: 'none' | 'log') => T\n\nconst booleanFromBytes: fromBytes<boolean> = (val) => {\n return encodingUtil.uint8ArrayToBigInt(asUint8Array(val)) > 0n\n}\n\nconst bigUintFromBytes: fromBytes<biguint> = (val) => {\n return BigUint(encodingUtil.uint8ArrayToBigInt(asUint8Array(val)))\n}\n\nconst bytesFromBytes: fromBytes<bytes> = (val) => {\n return asBytes(val)\n}\n\nconst stringFromBytes: fromBytes<string> = (val) => {\n return asBytes(val).toString()\n}\n\nconst uint64FromBytes: fromBytes<uint64> = (val) => {\n return Uint64(encodingUtil.uint8ArrayToBigInt(asUint8Array(val)))\n}\n\nconst onCompletionFromBytes: fromBytes<OnCompleteAction> = (val) => {\n return Uint64(encodingUtil.uint8ArrayToBigInt(asUint8Array(val))) as OnCompleteAction\n}\n\nconst transactionTypeFromBytes: fromBytes<TransactionType> = (val) => {\n return Uint64(encodingUtil.uint8ArrayToBigInt(asUint8Array(val))) as TransactionType\n}\n\nexport const encoders: Record<string, fromBytes<DeliberateAny>> = {\n account: AccountCls.fromBytes,\n application: ApplicationCls.fromBytes,\n asset: AssetCls.fromBytes,\n boolean: booleanFromBytes,\n biguint: bigUintFromBytes,\n bytes: bytesFromBytes,\n string: stringFromBytes,\n uint64: uint64FromBytes,\n OnCompleteAction: onCompletionFromBytes,\n TransactionType: transactionTypeFromBytes,\n ...arc4Encoders,\n}\n\nexport const getEncoder = <T>(typeInfo: TypeInfo): fromBytes<T> => {\n return getArc4Encoder<T>(typeInfo, encoders)\n}\n\nexport const toBytes = (val: unknown): bytes => {\n const uint64Val = asMaybeUint64Cls(val, false)\n if (uint64Val !== undefined) {\n return uint64Val.toBytes().asAlgoTs()\n }\n const bytesVal = asMaybeBytesCls(val)\n if (bytesVal !== undefined) {\n return bytesVal.asAlgoTs()\n }\n const bigUintVal = asMaybeBigUintCls(val)\n if (bigUintVal !== undefined) {\n return bigUintVal.toBytes().asAlgoTs()\n }\n if (val instanceof BytesBackedCls) {\n return val.bytes\n }\n if (val instanceof Uint64BackedCls) {\n return asUint64Cls(val.uint64).toBytes().asAlgoTs()\n }\n if (val instanceof ARC4Encoded) {\n return val.bytes\n }\n if (Array.isArray(val) || typeof val === 'object') {\n return encodeArc4Impl(undefined, val)\n }\n throw new InternalError(`Invalid type for bytes: ${nameOfType(val)}`)\n}\n\nexport const minLengthForType = (typeInfo: TypeInfo): number => {\n const minArc4StaticLength = tryArc4EncodedLengthImpl(typeInfo)\n return minArc4StaticLength ?? 0\n}\n","import type {\n Account as AccountType,\n Application as ApplicationType,\n bytes,\n gtxn,\n op,\n uint64,\n} from '@algorandfoundation/algorand-typescript'\nimport { lazyContext } from '../context-helpers/internal-context'\nimport { asMaybeUint64Cls, asUint64 } from '../util'\nimport { Bytes, Uint64, type StubUint64Compat } from './primitives'\nimport { Account } from './reference'\n\nconst resolveAppIndex = (appIdOrIndex: StubUint64Compat): uint64 => {\n const input = asUint64(appIdOrIndex)\n if (input >= 1001) {\n return input\n }\n const txn = lazyContext.activeGroup.activeTransaction as gtxn.ApplicationCallTxn\n return txn.apps(input).id\n}\n\nexport const getApp = (app: ApplicationType | StubUint64Compat): ApplicationType | undefined => {\n try {\n const appId = asMaybeUint64Cls(app)\n if (appId !== undefined) {\n return lazyContext.ledger.getApplication(resolveAppIndex(appId))\n }\n return app as ApplicationType\n } catch {\n return undefined\n }\n}\n\nexport const AppParams: typeof op.AppParams = {\n appApprovalProgram(a: ApplicationType | StubUint64Compat): readonly [bytes, boolean] {\n const app = getApp(a)\n return app === undefined ? [Bytes(), false] : [app.approvalProgram, true]\n },\n appClearStateProgram(a: ApplicationType | StubUint64Compat): readonly [bytes, boolean] {\n const app = getApp(a)\n return app === undefined ? [Bytes(), false] : [app.clearStateProgram, true]\n },\n appGlobalNumUint(a: ApplicationType | StubUint64Compat): readonly [uint64, boolean] {\n const app = getApp(a)\n return app === undefined ? [Uint64(0), false] : [app.globalNumUint, true]\n },\n appGlobalNumByteSlice(a: ApplicationType | StubUint64Compat): readonly [uint64, boolean] {\n const app = getApp(a)\n return app === undefined ? [Uint64(0), false] : [app.globalNumBytes, true]\n },\n appLocalNumUint(a: ApplicationType | StubUint64Compat): readonly [uint64, boolean] {\n const app = getApp(a)\n return app === undefined ? [Uint64(0), false] : [app.localNumUint, true]\n },\n appLocalNumByteSlice(a: ApplicationType | StubUint64Compat): readonly [uint64, boolean] {\n const app = getApp(a)\n return app === undefined ? [Uint64(0), false] : [app.localNumBytes, true]\n },\n appExtraProgramPages(a: ApplicationType | StubUint64Compat): readonly [uint64, boolean] {\n const app = getApp(a)\n return app === undefined ? [Uint64(0), false] : [app.extraProgramPages, true]\n },\n appCreator(a: ApplicationType | StubUint64Compat): readonly [AccountType, boolean] {\n const app = getApp(a)\n return app === undefined ? [Account(), false] : [app.creator, true]\n },\n appAddress(a: ApplicationType | StubUint64Compat): readonly [AccountType, boolean] {\n const app = getApp(a)\n return app === undefined ? [Account(), false] : [app.address, true]\n },\n}\n","import type { Account as AccountType, Asset as AssetType, bytes, gtxn, op, uint64 } from '@algorandfoundation/algorand-typescript'\nimport { lazyContext } from '../context-helpers/internal-context'\nimport { asMaybeUint64Cls, asUint64 } from '../util'\nimport { Bytes, Uint64, type StubUint64Compat } from './primitives'\nimport { Account } from './reference'\n\nconst resolveAssetIndex = (assetIdOrIndex: StubUint64Compat): uint64 => {\n const input = asUint64(assetIdOrIndex)\n if (input >= 1001) {\n return input\n }\n const txn = lazyContext.activeGroup.activeTransaction as gtxn.ApplicationCallTxn\n return txn.assets(input).id\n}\n\nexport const getAsset = (asset: AssetType | StubUint64Compat): AssetType | undefined => {\n try {\n const assetId = asMaybeUint64Cls(asset)\n if (assetId !== undefined) {\n return lazyContext.ledger.getAsset(resolveAssetIndex(assetId))\n }\n return asset as AssetType\n } catch {\n return undefined\n }\n}\n\nexport const AssetParams: typeof op.AssetParams = {\n assetTotal(a: AssetType | StubUint64Compat): readonly [uint64, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Uint64(0), false] : [asset.total, true]\n },\n assetDecimals(a: AssetType | StubUint64Compat): readonly [uint64, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Uint64(0), false] : [asset.decimals, true]\n },\n assetDefaultFrozen(a: AssetType | StubUint64Compat): readonly [boolean, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [false, false] : [asset.defaultFrozen, true]\n },\n assetUnitName(a: AssetType | StubUint64Compat): readonly [bytes, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Bytes(), false] : [asset.unitName, true]\n },\n assetName(a: AssetType | StubUint64Compat): readonly [bytes, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Bytes(), false] : [asset.name, true]\n },\n assetUrl(a: AssetType | StubUint64Compat): readonly [bytes, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Bytes(), false] : [asset.url, true]\n },\n assetMetadataHash(a: AssetType | StubUint64Compat): readonly [bytes, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Bytes(), false] : [asset.metadataHash, true]\n },\n assetManager(a: AssetType | StubUint64Compat): readonly [AccountType, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Account(), false] : [asset.manager, true]\n },\n assetReserve(a: AssetType | StubUint64Compat): readonly [AccountType, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Account(), false] : [asset.reserve, true]\n },\n assetFreeze(a: AssetType | StubUint64Compat): readonly [AccountType, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Account(), false] : [asset.freeze, true]\n },\n assetClawback(a: AssetType | StubUint64Compat): readonly [AccountType, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Account(), false] : [asset.clawback, true]\n },\n assetCreator(a: AssetType | StubUint64Compat): readonly [AccountType, boolean] {\n const asset = getAsset(a)\n return asset === undefined ? [Account(), false] : [asset.creator, true]\n },\n}\n"],"names":[],"mappings":";;;;AAkBA,MAAM,gBAAgB,GAAuB,CAAC,GAAG,KAAI;IACnD,OAAO,YAAY,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;AAChE,CAAC;AAED,MAAM,gBAAgB,GAAuB,CAAC,GAAG,KAAI;AACnD,IAAA,OAAO,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,cAAc,GAAqB,CAAC,GAAG,KAAI;AAC/C,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC;AACrB,CAAC;AAED,MAAM,eAAe,GAAsB,CAAC,GAAG,KAAI;AACjD,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;A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AS,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;KACxE;AACD,IAAA,WAAW,CAAC,CAA+B,EAAA;AACzC,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;QACzB,OAAO,KAAK,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC;KACvE;AACD,IAAA,aAAa,CAAC,CAA+B,EAAA;AAC3C,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;QACzB,OAAO,KAAK,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;KACzE;AACD,IAAA,YAAY,CAAC,CAA+B,EAAA;AAC1C,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;QACzB,OAAO,KAAK,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;KACxE;;;;;"}
package/constants.d.ts CHANGED
@@ -44,3 +44,12 @@ export declare enum OnApplicationComplete {
44
44
  UpdateApplicationOC = 4,
45
45
  DeleteApplicationOC = 5
46
46
  }
47
+ export declare const ConventionalRouting: {
48
+ methodNames: {
49
+ closeOutOfApplication: string;
50
+ createApplication: string;
51
+ deleteApplication: string;
52
+ optInToApplication: string;
53
+ updateApplication: string;
54
+ };
55
+ };
@@ -10,26 +10,6 @@ import nacl from 'tweetnacl';
10
10
  import { n as nameOfType$1 } from './typescript-helpers-CAukFXpp.js';
11
11
  import { randomBytes } from 'crypto';
12
12
 
13
- class BaseContract {
14
- static isArc4 = false;
15
- clearStateProgram() {
16
- return true;
17
- }
18
- }
19
- const ContractOptionsSymbol = Symbol('ContractOptions');
20
- function contract(options) {
21
- return (contract, ctx) => {
22
- ctx.addInitializer(function () {
23
- Object.defineProperty(this, ContractOptionsSymbol, {
24
- value: options,
25
- writable: false,
26
- enumerable: false,
27
- });
28
- });
29
- return contract;
30
- };
31
- }
32
-
33
13
  /**
34
14
  * Raised when an `err` op is encountered, or when the testing VM is asked to do something that would cause
35
15
  * the AVM to fail.
@@ -556,6 +536,35 @@ var OnApplicationComplete;
556
536
  OnApplicationComplete[OnApplicationComplete["UpdateApplicationOC"] = 4] = "UpdateApplicationOC";
557
537
  OnApplicationComplete[OnApplicationComplete["DeleteApplicationOC"] = 5] = "DeleteApplicationOC";
558
538
  })(OnApplicationComplete || (OnApplicationComplete = {}));
539
+ const ConventionalRouting = {
540
+ methodNames: {
541
+ closeOutOfApplication: 'closeOutOfApplication',
542
+ createApplication: 'createApplication',
543
+ deleteApplication: 'deleteApplication',
544
+ optInToApplication: 'optInToApplication',
545
+ updateApplication: 'updateApplication',
546
+ },
547
+ };
548
+
549
+ class BaseContract {
550
+ static isArc4 = false;
551
+ clearStateProgram() {
552
+ return true;
553
+ }
554
+ }
555
+ const ContractOptionsSymbol = Symbol('ContractOptions');
556
+ function contract(options) {
557
+ return (contract, ctx) => {
558
+ ctx.addInitializer(function () {
559
+ Object.defineProperty(this, ContractOptionsSymbol, {
560
+ value: options,
561
+ writable: false,
562
+ enumerable: false,
563
+ });
564
+ });
565
+ return contract;
566
+ };
567
+ }
559
568
 
560
569
  class ContextManager {
561
570
  static _instance;
@@ -663,12 +672,13 @@ const asUint64 = (val) => asUint64Cls(val).asAlgoTs();
663
672
  const asBigUint = (val) => asBigUintCls(val).asAlgoTs();
664
673
  const asBytes = (val) => asBytesCls(val).asAlgoTs();
665
674
  const asUint8Array = (val) => asBytesCls(val).asUint8Array();
666
- const asMaybeUint64Cls = (val) => {
675
+ const asMaybeUint64Cls = (val, throwsOverflow = true) => {
667
676
  try {
668
677
  return Uint64Cls.fromCompat(val);
669
678
  }
670
679
  catch (e) {
671
680
  if (e instanceof InternalError) ;
681
+ else if (!throwsOverflow && e instanceof AvmError && e.message.includes('overflow')) ;
672
682
  else {
673
683
  throw e;
674
684
  }
@@ -797,6 +807,35 @@ function err(message) {
797
807
  throw new AvmError(message ?? 'err opcode executed');
798
808
  }
799
809
 
810
+ class BytesBackedCls {
811
+ #value;
812
+ // #typeInfo: GenericTypeInfo | undefined
813
+ get bytes() {
814
+ return this.#value;
815
+ }
816
+ constructor(value, _typeInfo) {
817
+ this.#value = value;
818
+ // this.#typeInfo = typeInfo
819
+ }
820
+ static fromBytes(value, typeInfo) {
821
+ return new this(BytesCls.fromCompat(value).asAlgoTs(), typeInfo);
822
+ }
823
+ }
824
+ class Uint64BackedCls {
825
+ #value;
826
+ get uint64() {
827
+ return this.#value;
828
+ }
829
+ constructor(value) {
830
+ this.#value = value;
831
+ }
832
+ static fromBytes(value) {
833
+ const uint8ArrayValue = value instanceof Uint8Array ? value : BytesCls.fromCompat(value).asUint8Array();
834
+ const uint64Value = Uint64(encodingUtil.uint8ArrayToBigInt(uint8ArrayValue));
835
+ return new this(uint64Value);
836
+ }
837
+ }
838
+
800
839
  class CustomKeyMap {
801
840
  #keySerializer;
802
841
  #map = new Map();
@@ -873,35 +912,6 @@ class Uint64Map extends CustomKeyMap {
873
912
  }
874
913
  }
875
914
 
876
- class BytesBackedCls {
877
- #value;
878
- // #typeInfo: GenericTypeInfo | undefined
879
- get bytes() {
880
- return this.#value;
881
- }
882
- constructor(value, _typeInfo) {
883
- this.#value = value;
884
- // this.#typeInfo = typeInfo
885
- }
886
- static fromBytes(value, typeInfo) {
887
- return new this(BytesCls.fromCompat(value).asAlgoTs(), typeInfo);
888
- }
889
- }
890
- class Uint64BackedCls {
891
- #value;
892
- get uint64() {
893
- return this.#value;
894
- }
895
- constructor(value) {
896
- this.#value = value;
897
- }
898
- static fromBytes(value) {
899
- const uint8ArrayValue = value instanceof Uint8Array ? value : BytesCls.fromCompat(value).asUint8Array();
900
- const uint64Value = Uint64(encodingUtil.uint8ArrayToBigInt(uint8ArrayValue));
901
- return new this(uint64Value);
902
- }
903
- }
904
-
905
915
  class AssetHolding {
906
916
  balance;
907
917
  frozen;
@@ -1231,7 +1241,7 @@ class UFixedNxMImpl extends UFixedNxM {
1231
1241
  const genericArgs = this.typeInfo.genericArgs;
1232
1242
  this.bitSize = UFixedNxMImpl.getMaxBitsLength(this.typeInfo);
1233
1243
  this.precision = parseInt(genericArgs.m.name, 10);
1234
- const trimmedValue = trimTrailingDecimalZeros(v);
1244
+ const trimmedValue = trimTrailingDecimalZeros(v ?? '0.0');
1235
1245
  assert$1(regExpNxM(this.precision).test(trimmedValue), `expected positive decimal literal with max of ${this.precision} decimal places`);
1236
1246
  const bigIntValue = BigInt(trimmedValue.replace('.', ''));
1237
1247
  const maxValue = maxBigIntValue(this.bitSize);
@@ -1405,6 +1415,7 @@ const arrayProxyHandler = () => ({
1405
1415
  return Reflect.set(target, prop, value);
1406
1416
  },
1407
1417
  });
1418
+ const isInitialisingFromBytesSymbol = Symbol('IsInitialisingFromBytes');
1408
1419
  class StaticArrayImpl extends StaticArray {
1409
1420
  value;
1410
1421
  uint8ArrayValue;
@@ -1412,18 +1423,29 @@ class StaticArrayImpl extends StaticArray {
1412
1423
  typeInfo;
1413
1424
  genericArgs;
1414
1425
  constructor(typeInfo, ...items) {
1415
- super(...items);
1426
+ // if first item is the symbol, we are initialising from bytes
1427
+ // so we don't need to pass the items to the super constructor
1428
+ const isInitialisingFromBytes = items.length === 1 && items[0] === isInitialisingFromBytesSymbol;
1429
+ super(...(isInitialisingFromBytes ? [] : items));
1416
1430
  this.typeInfo = typeof typeInfo === 'string' ? JSON.parse(typeInfo) : typeInfo;
1417
1431
  this.genericArgs = this.typeInfo.genericArgs;
1418
1432
  this.size = parseInt(this.genericArgs.size.name, 10);
1419
- if (items.length && items.length !== this.size) {
1420
- throw new CodeError(`expected ${this.size} items, not ${items.length}`);
1433
+ // if we are not initialising from bytes, we need to check and set the items
1434
+ if (!isInitialisingFromBytes) {
1435
+ if (items.length && items.length !== this.size) {
1436
+ throw new CodeError(`expected ${this.size} items, not ${items.length}`);
1437
+ }
1438
+ assert$1(areAllARC4Encoded(items), 'expected ARC4 type');
1439
+ items.forEach((item) => {
1440
+ checkItemTypeName(this.genericArgs.elementType, item);
1441
+ });
1442
+ if (items.length) {
1443
+ this.value = items;
1444
+ }
1445
+ else {
1446
+ this.uint8ArrayValue = new Uint8Array(StaticArrayImpl.getMaxBytesLength(this.typeInfo));
1447
+ }
1421
1448
  }
1422
- assert$1(areAllARC4Encoded(items), 'expected ARC4 type');
1423
- items.forEach((item) => {
1424
- checkItemTypeName(this.genericArgs.elementType, item);
1425
- });
1426
- this.value = items.length ? items : undefined;
1427
1449
  return new Proxy(this, arrayProxyHandler());
1428
1450
  }
1429
1451
  get bytes() {
@@ -1476,7 +1498,8 @@ class StaticArrayImpl extends StaticArray {
1476
1498
  assert$1(bytesValue.slice(0, 4).equals(ABI_RETURN_VALUE_LOG_PREFIX), 'ABI return prefix not found');
1477
1499
  bytesValue = bytesValue.slice(4);
1478
1500
  }
1479
- const result = new StaticArrayImpl(typeInfo);
1501
+ // pass the symbol to the constructor to let it know we are initialising from bytes
1502
+ const result = new StaticArrayImpl(typeInfo, isInitialisingFromBytesSymbol);
1480
1503
  result.uint8ArrayValue = asUint8Array(bytesValue);
1481
1504
  return result;
1482
1505
  }
@@ -1660,14 +1683,25 @@ class TupleImpl extends Tuple {
1660
1683
  typeInfo;
1661
1684
  genericArgs;
1662
1685
  constructor(typeInfo, ...items) {
1663
- super(...items);
1686
+ // if first item is the symbol, we are initialising from bytes
1687
+ // so we don't need to pass the items to the super constructor
1688
+ const isInitialisingFromBytes = items.length === 1 && items[0] === isInitialisingFromBytesSymbol;
1689
+ super(...(isInitialisingFromBytes ? [] : items));
1664
1690
  this.typeInfo = typeof typeInfo === 'string' ? JSON.parse(typeInfo) : typeInfo;
1665
1691
  this.genericArgs = Object.values(this.typeInfo.genericArgs);
1666
- assert$1(areAllARC4Encoded(items), 'expected ARC4 type');
1667
- items.forEach((item, index) => {
1668
- checkItemTypeName(this.genericArgs[index], item);
1669
- });
1670
- this.value = items.length ? items : undefined;
1692
+ // if we are not initialising from bytes, we need to check and set the items
1693
+ if (!isInitialisingFromBytes) {
1694
+ assert$1(areAllARC4Encoded(items), 'expected ARC4 type');
1695
+ items.forEach((item, index) => {
1696
+ checkItemTypeName(this.genericArgs[index], item);
1697
+ });
1698
+ if (items.length) {
1699
+ this.value = items;
1700
+ }
1701
+ else {
1702
+ this.uint8ArrayValue = new Uint8Array(TupleImpl.getMaxBytesLength(this.typeInfo));
1703
+ }
1704
+ }
1671
1705
  }
1672
1706
  get bytes() {
1673
1707
  return Bytes(this.uint8ArrayValue ?? encode(this.items));
@@ -1705,7 +1739,8 @@ class TupleImpl extends Tuple {
1705
1739
  assert$1(bytesValue.slice(0, 4).equals(ABI_RETURN_VALUE_LOG_PREFIX), 'ABI return prefix not found');
1706
1740
  bytesValue = bytesValue.slice(4);
1707
1741
  }
1708
- const result = new TupleImpl(typeInfo);
1742
+ // pass the symbol to the constructor to let it know we are initialising from bytes
1743
+ const result = new TupleImpl(typeInfo, isInitialisingFromBytesSymbol);
1709
1744
  result.uint8ArrayValue = asUint8Array(bytesValue);
1710
1745
  return result;
1711
1746
  }
@@ -1884,9 +1919,9 @@ class StaticBytesImpl extends StaticBytes {
1884
1919
  typeInfo;
1885
1920
  constructor(typeInfo, value) {
1886
1921
  super(value);
1887
- const uint8ArrayValue = asUint8Array(value ?? new Uint8Array());
1888
- this.value = StaticArrayImpl.fromBytesImpl(uint8ArrayValue, typeInfo);
1889
1922
  this.typeInfo = typeof typeInfo === 'string' ? JSON.parse(typeInfo) : typeInfo;
1923
+ const uint8ArrayValue = asUint8Array(value ?? new Uint8Array(StaticBytesImpl.getMaxBytesLength(this.typeInfo)));
1924
+ this.value = StaticArrayImpl.fromBytesImpl(uint8ArrayValue, typeInfo);
1890
1925
  return new Proxy(this, arrayProxyHandler());
1891
1926
  }
1892
1927
  get bytes() {
@@ -2033,6 +2068,8 @@ const getMaxLengthOfStaticContentType = (type) => {
2033
2068
  case 'biguint':
2034
2069
  return UINT512_SIZE / BITS_IN_BYTE;
2035
2070
  case 'boolean':
2071
+ return 8;
2072
+ case 'Bool':
2036
2073
  return 1;
2037
2074
  case 'Address':
2038
2075
  return AddressImpl.getMaxBytesLength(type);
@@ -2050,8 +2087,9 @@ const getMaxLengthOfStaticContentType = (type) => {
2050
2087
  return TupleImpl.getMaxBytesLength(type);
2051
2088
  case 'Struct':
2052
2089
  return StructImpl.getMaxBytesLength(type);
2090
+ default:
2091
+ throw new CodeError(`unsupported type ${type.name}`);
2053
2092
  }
2054
- throw new CodeError(`unsupported type ${type.name}`);
2055
2093
  };
2056
2094
  const encode = (values) => {
2057
2095
  const length = values.length;
@@ -2202,30 +2240,43 @@ const getArc4TypeName = (typeInfo) => {
2202
2240
  return name(typeInfo);
2203
2241
  return undefined;
2204
2242
  };
2205
- function decodeArc4Impl(sourceTypeInfoString, bytes, prefix = 'none') {
2243
+ function decodeArc4Impl(sourceTypeInfoString, targetTypeInfoString, bytes, prefix = 'none') {
2206
2244
  const sourceTypeInfo = JSON.parse(sourceTypeInfoString);
2245
+ const targetTypeInfo = JSON.parse(targetTypeInfoString);
2207
2246
  const encoder = getArc4Encoder(sourceTypeInfo);
2208
2247
  const source = encoder(bytes, sourceTypeInfo, prefix);
2209
- return getNativeValue(source);
2248
+ return getNativeValue(source, targetTypeInfo);
2210
2249
  }
2211
- function encodeArc4Impl(_targetTypeInfoString, source) {
2212
- const arc4Encoded = getArc4Encoded(source);
2250
+ function encodeArc4Impl(sourceTypeInfoString, source) {
2251
+ const arc4Encoded = getArc4Encoded(source, sourceTypeInfoString);
2213
2252
  return arc4Encoded.bytes;
2214
2253
  }
2215
- const getNativeValue = (value) => {
2254
+ const getNativeValue = (value, targetTypeInfo) => {
2255
+ if (value.typeInfo && value.typeInfo.name === targetTypeInfo?.name) {
2256
+ return value;
2257
+ }
2216
2258
  const native = value.native;
2217
2259
  if (Array.isArray(native)) {
2218
- return native.map((item) => getNativeValue(item));
2260
+ return native.map((item) => getNativeValue(item, targetTypeInfo?.genericArgs?.elementType));
2219
2261
  }
2220
2262
  else if (native instanceof AlgoTsPrimitiveCls) {
2221
2263
  return native;
2222
2264
  }
2265
+ else if (native instanceof BytesBackedCls) {
2266
+ return native.bytes;
2267
+ }
2268
+ else if (native instanceof Uint64BackedCls) {
2269
+ return native.uint64;
2270
+ }
2223
2271
  else if (typeof native === 'object') {
2224
- return Object.fromEntries(Object.entries(native).map(([key, value]) => [key, getNativeValue(value)]));
2272
+ return Object.fromEntries(Object.entries(native).map(([key, value], index) => [
2273
+ key,
2274
+ getNativeValue(value, targetTypeInfo?.genericArgs?.[index]),
2275
+ ]));
2225
2276
  }
2226
2277
  return native;
2227
2278
  };
2228
- const getArc4Encoded = (value) => {
2279
+ const getArc4Encoded = (value, sourceTypeInfoString) => {
2229
2280
  if (value instanceof ARC4Encoded) {
2230
2281
  return value;
2231
2282
  }
@@ -2263,9 +2314,16 @@ const getArc4Encoded = (value) => {
2263
2314
  const result = value.reduce((acc, cur) => {
2264
2315
  return acc.concat(getArc4Encoded(cur));
2265
2316
  }, []);
2317
+ const sourceTypeInfo = sourceTypeInfoString ? JSON.parse(sourceTypeInfoString) : undefined;
2266
2318
  const genericArgs = result.map((x) => x.typeInfo);
2267
- const typeInfo = { name: `Tuple<[${genericArgs.map((x) => x.name).join(',')}]>`, genericArgs };
2268
- return new TupleImpl(typeInfo, ...result);
2319
+ if (sourceTypeInfo?.name?.startsWith('Array')) {
2320
+ const typeInfo = { name: `DynamicArray<${genericArgs[0].name}>`, genericArgs: { elementType: genericArgs[0] } };
2321
+ return new DynamicArrayImpl(typeInfo, ...result);
2322
+ }
2323
+ else {
2324
+ const typeInfo = { name: `Tuple<[${genericArgs.map((x) => x.name).join(',')}]>`, genericArgs };
2325
+ return new TupleImpl(typeInfo, ...result);
2326
+ }
2269
2327
  }
2270
2328
  if (typeof value === 'object') {
2271
2329
  const result = Object.values(value).reduce((acc, cur) => {
@@ -2284,6 +2342,18 @@ const arc4EncodedLengthImpl = (typeInfoString) => {
2284
2342
  const typeInfo = JSON.parse(typeInfoString);
2285
2343
  return getMaxLengthOfStaticContentType(typeInfo);
2286
2344
  };
2345
+ const tryArc4EncodedLengthImpl = (typeInfoString) => {
2346
+ const typeInfo = typeof typeInfoString === 'string' ? JSON.parse(typeInfoString) : typeInfoString;
2347
+ try {
2348
+ return getMaxLengthOfStaticContentType(typeInfo);
2349
+ }
2350
+ catch (e) {
2351
+ if (e instanceof CodeError && e.message.startsWith('unsupported type')) {
2352
+ return undefined;
2353
+ }
2354
+ throw e;
2355
+ }
2356
+ };
2287
2357
 
2288
2358
  const sha256 = (a) => {
2289
2359
  const bytesA = BytesCls.fromCompat(a);
@@ -2376,5 +2446,5 @@ const curveMap = {
2376
2446
  [Ecdsa.Secp256r1]: 'p256',
2377
2447
  };
2378
2448
 
2379
- export { AvmError as $, AccountCls as A, BigUintCls as B, BigUint as C, MAX_BYTES_SIZE as D, Bytes as E, Account as F, getRandomBytes as G, AssetCls as H, InternalError as I, MAX_UINT512 as J, AddressImpl as K, MAX_UINT8 as L, MAX_UINT64 as M, UintNImpl as N, MAX_UINT16 as O, MAX_UINT32 as P, MAX_UINT128 as Q, MAX_UINT256 as R, DynamicBytesImpl as S, TRANSACTION_GROUP_MAX_SIZE as T, Uint64Cls as U, BITS_IN_BYTE as V, StrImpl as W, BaseContract as X, ContextManager as Y, DEFAULT_TEMPLATE_VAR_PREFIX as Z, AssertError as _, asNumber as a, UINT64_SIZE as a$, CodeError as a0, NotImplementedError as a1, toExternalValue as a2, assert as a3, BytesBackedCls as a4, Uint64BackedCls as a5, asMaybeBigUintCls as a6, contract as a7, err as a8, sha512_256 as a9, StaticBytesImpl as aA, interpretAsArc4Impl as aB, arc4Encoders as aC, getArc4Encoder as aD, EllipticCurve as aE, ecdsaPkDecompress as aF, ecdsaPkRecover as aG, ecdsaVerify as aH, ed25519verify as aI, ed25519verifyBare as aJ, keccak256 as aK, mimc as aL, sha256 as aM, sha3_256 as aN, vrfVerify as aO, getApplicationAddress as aP, getObjectReference as aQ, MIN_TXN_FEE as aR, DEFAULT_ACCOUNT_MIN_BALANCE as aS, DEFAULT_MAX_TXN_LIFE as aT, ZERO_ADDRESS as aU, DEFAULT_ASSET_CREATE_MIN_BALANCE as aV, DEFAULT_ASSET_OPT_IN_MIN_BALANCE as aW, DEFAULT_GLOBAL_GENESIS_HASH as aX, asBigUint as aY, isUint64 as aZ, binaryStringToBytes as a_, combineIntoMaxBytePages as aa, MAX_ITEMS_IN_LOG as ab, asBytesCls as ac, MAX_BOX_SIZE as ad, conactUint8Arrays as ae, getArc4Encoded as af, BytesMap as ag, ContractOptionsSymbol as ah, encodeArc4Impl as ai, asApplication as aj, asAsset as ak, asAccount as al, getArc4TypeName as am, nameOfType as an, checkBigUint as ao, checkBytes as ap, flattenAsBytes as aq, arc4EncodedLengthImpl as ar, decodeArc4Impl as as, UFixedNxMImpl as at, ByteImpl as au, BoolImpl as av, StaticArrayImpl as aw, DynamicArrayImpl as ax, TupleImpl as ay, StructImpl as az, BytesCls as b, AlgoTsPrimitiveCls as c, Uint64Map as d, AccountMap as e, asBytes as f, Asset as g, asUint64 as h, iterBigInt as i, Application as j, asMaybeUint64Cls as k, asUint64Cls as l, AssetHolding as m, AccountData as n, ApplicationData as o, getDefaultAssetData as p, asBigInt as q, asMaybeBytesCls as r, asUint8Array as s, ApplicationCls as t, ABI_RETURN_VALUE_LOG_PREFIX as u, lazyContext as v, invariant as w, Uint64 as x, getRandomBigInt as y, asBigUintCls as z };
2380
- //# sourceMappingURL=crypto-DumZR3uP.js.map
2449
+ export { AvmError as $, AccountCls as A, BigUintCls as B, BigUint as C, MAX_BYTES_SIZE as D, Bytes as E, Account as F, getRandomBytes as G, AssetCls as H, InternalError as I, MAX_UINT512 as J, AddressImpl as K, MAX_UINT8 as L, MAX_UINT64 as M, UintNImpl as N, MAX_UINT16 as O, MAX_UINT32 as P, MAX_UINT128 as Q, MAX_UINT256 as R, DynamicBytesImpl as S, TRANSACTION_GROUP_MAX_SIZE as T, Uint64Cls as U, BITS_IN_BYTE as V, StrImpl as W, BaseContract as X, ContextManager as Y, DEFAULT_TEMPLATE_VAR_PREFIX as Z, AssertError as _, asNumber as a, isUint64 as a$, CodeError as a0, NotImplementedError as a1, toExternalValue as a2, assert as a3, BytesBackedCls as a4, Uint64BackedCls as a5, asMaybeBigUintCls as a6, contract as a7, err as a8, sha512_256 as a9, TupleImpl as aA, StructImpl as aB, StaticBytesImpl as aC, interpretAsArc4Impl as aD, arc4Encoders as aE, getArc4Encoder as aF, EllipticCurve as aG, ecdsaPkDecompress as aH, ecdsaPkRecover as aI, ecdsaVerify as aJ, ed25519verify as aK, ed25519verifyBare as aL, keccak256 as aM, mimc as aN, sha256 as aO, sha3_256 as aP, vrfVerify as aQ, getApplicationAddress as aR, getObjectReference as aS, MIN_TXN_FEE as aT, DEFAULT_ACCOUNT_MIN_BALANCE as aU, DEFAULT_MAX_TXN_LIFE as aV, ZERO_ADDRESS as aW, DEFAULT_ASSET_CREATE_MIN_BALANCE as aX, DEFAULT_ASSET_OPT_IN_MIN_BALANCE as aY, DEFAULT_GLOBAL_GENESIS_HASH as aZ, asBigUint as a_, combineIntoMaxBytePages as aa, MAX_ITEMS_IN_LOG as ab, tryArc4EncodedLengthImpl as ac, asBytesCls as ad, MAX_BOX_SIZE as ae, conactUint8Arrays as af, getArc4Encoded as ag, BytesMap as ah, ContractOptionsSymbol as ai, encodeArc4Impl as aj, asApplication as ak, asAsset as al, asAccount as am, ConventionalRouting as an, getArc4TypeName as ao, nameOfType as ap, checkBigUint as aq, checkBytes as ar, flattenAsBytes as as, arc4EncodedLengthImpl as at, decodeArc4Impl as au, UFixedNxMImpl as av, ByteImpl as aw, BoolImpl as ax, StaticArrayImpl as ay, DynamicArrayImpl as az, BytesCls as b, binaryStringToBytes as b0, UINT64_SIZE as b1, AlgoTsPrimitiveCls as c, Uint64Map as d, AccountMap as e, asBytes as f, Asset as g, asUint64 as h, iterBigInt as i, Application as j, asMaybeUint64Cls as k, asUint64Cls as l, AssetHolding as m, AccountData as n, ApplicationData as o, getDefaultAssetData as p, asBigInt as q, asMaybeBytesCls as r, asUint8Array as s, ApplicationCls as t, ABI_RETURN_VALUE_LOG_PREFIX as u, lazyContext as v, invariant as w, Uint64 as x, getRandomBigInt as y, asBigUintCls as z };
2450
+ //# sourceMappingURL=crypto-Bl2XtehF.js.map