diff --git a/package-lock.json b/package-lock.json index 2b10da0b3..557a99cc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13544,7 +13544,7 @@ }, "packages/algo-ts/dist": { "name": "@algorandfoundation/algorand-typescript", - "version": "1.0.0-beta.9", + "version": "1.0.0-beta.10", "dev": true, "peerDependencies": { "tslib": "^2.6.2" diff --git a/packages/algo-ts/package.json b/packages/algo-ts/package.json index fc178117c..2209a96fc 100644 --- a/packages/algo-ts/package.json +++ b/packages/algo-ts/package.json @@ -1,6 +1,6 @@ { "name": "@algorandfoundation/algorand-typescript", - "version": "1.0.0-beta.9", + "version": "1.0.0-beta.10", "description": "This package contains definitions for the types which comprise Algorand TypeScript which can be compiled to run on the Algorand Virtual Machine using the Puya compiler.", "private": false, "main": "index.js", diff --git a/packages/algo-ts/src/execution-context.ts b/packages/algo-ts/src/execution-context.ts index c862d7215..35621fce4 100644 --- a/packages/algo-ts/src/execution-context.ts +++ b/packages/algo-ts/src/execution-context.ts @@ -1,14 +1,8 @@ import { Box, BoxMap, BoxRef, Contract, GlobalState, gtxn, itxn, LocalState } from '.' import { AbiMethodConfig, BareMethodConfig } from './arc4' import { OpsNamespace } from './op-types' -import { bytes, uint64 } from './primitives' -import { Account, Application, Asset } from './reference' export type ExecutionContext = { - log(value: bytes): void - application(id?: uint64): Application - asset(id?: uint64): Asset - account(address?: bytes): Account op: Partial abiMetadata: { captureMethodConfig(contract: T, methodName: string, config?: AbiMethodConfig | BareMethodConfig): void diff --git a/packages/algo-ts/src/reference.ts b/packages/algo-ts/src/reference.ts index 0c430c174..b9da288bf 100644 --- a/packages/algo-ts/src/reference.ts +++ b/packages/algo-ts/src/reference.ts @@ -1,4 +1,4 @@ -import { ctxMgr } from './execution-context' +import { NoImplementation } from './impl/errors' import { bytes, uint64 } from './primitives' export type Account = { @@ -100,13 +100,13 @@ export type Account = { export function Account(): Account export function Account(address: bytes): Account export function Account(address?: bytes): Account { - return ctxMgr.instance.account(address) + throw new NoImplementation() } export function Asset(): Asset export function Asset(assetId: uint64): Asset export function Asset(assetId?: uint64): Asset { - return ctxMgr.instance.asset(assetId) + throw new NoImplementation() } /** * An Asset on the Algorand network. @@ -199,7 +199,7 @@ export type Asset = { export function Application(): Application export function Application(applicationId: uint64): Application export function Application(applicationId?: uint64): Application { - return ctxMgr.instance.application(applicationId) + throw new NoImplementation() } /** diff --git a/packages/algo-ts/src/util.ts b/packages/algo-ts/src/util.ts index 4488219be..c3ab975e2 100644 --- a/packages/algo-ts/src/util.ts +++ b/packages/algo-ts/src/util.ts @@ -1,28 +1,8 @@ -import { ARC4Encoded } from './arc4' -import { ctxMgr } from './execution-context' -import { AssertError, AvmError, internalError } from './impl/errors' -import { nameOfType } from './impl/name-of-type' -import { AlgoTsPrimitiveCls, BigUintCls, BytesCls, Uint64Cls } from './impl/primitives' -import { biguint, BigUintCompat, bytes, BytesBacked, BytesCompat, StringCompat, uint64, Uint64Compat } from './primitives' - -export const toBytes = (val: unknown): bytes => { - if (val instanceof AlgoTsPrimitiveCls) return val.toBytes().asAlgoTs() - if (val instanceof ARC4Encoded) return val.bytes - - switch (typeof val) { - case 'string': - return BytesCls.fromCompat(val).asAlgoTs() - case 'bigint': - return BigUintCls.fromCompat(val).toBytes().asAlgoTs() - case 'number': - return Uint64Cls.fromCompat(val).toBytes().asAlgoTs() - default: - internalError(`Unsupported arg type ${nameOfType(val)}`) - } -} +import { AssertError, AvmError, NoImplementation } from './impl/errors' +import { biguint, BigUintCompat, BytesBacked, BytesCompat, StringCompat, uint64, Uint64Compat } from './primitives' export function log(...args: Array): void { - ctxMgr.instance.log(args.map(toBytes).reduce((left, right) => left.concat(right))) + throw new NoImplementation() } export function assert(condition: unknown, message?: string): asserts condition {