Skip to content

Commit 6516c6a

Browse files
committed
refactor: export stub implementation of op codes under internal namespace
1 parent 6f32ea1 commit 6516c6a

23 files changed

+128
-47
lines changed

src/decode-logs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { bytes } from '@algorandfoundation/algorand-typescript'
2-
import { op } from '@algorandfoundation/algorand-typescript'
32
import { ABI_RETURN_VALUE_LOG_PREFIX } from './constants'
3+
import { btoi } from './impl/pure'
44
import { asNumber } from './util'
55

66
export type LogDecoding = 'i' | 's' | 'b'
@@ -18,7 +18,7 @@ export function decodeLogs<const T extends [...LogDecoding[]]>(logs: bytes[], de
1818
: log
1919
switch (decoding[i]) {
2020
case 'i':
21-
return op.btoi(value)
21+
return btoi(value)
2222
case 's':
2323
return value.toString()
2424
default:

src/impl/acct-params.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { gtxn, internal, uint64 } from '@algorandfoundation/algorand-typescript'
2-
import type { Account, Application } from '@algorandfoundation/algorand-typescript'
1+
import type { Account, Application, gtxn, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
32
import { lazyContext } from '../context-helpers/internal-context'
43
import { asMaybeUint64Cls } from '../util'
54
import { getApp } from './app-params'
@@ -37,7 +36,7 @@ export const appOptedIn = (
3736
return account.isOptedIn(app)
3837
}
3938

40-
export const AcctParams: internal.opTypes.AcctParamsType = {
39+
export const AcctParams: typeof op.AcctParams = {
4140
acctBalance(a: Account | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
4241
const acct = getAccount(a)
4342
return [acct.balance, acct.balance !== 0]

src/impl/app-global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Application, bytes, internal, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import type { Application, bytes, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { Bytes, Uint64 } from '@algorandfoundation/algorand-typescript'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { toBytes } from '../encoders'
55
import { asBytes } from '../util'
66
import { getApp } from './app-params'
77

8-
export const AppGlobal: internal.opTypes.AppGlobalType = {
8+
export const AppGlobal: typeof op.AppGlobal = {
99
delete(a: internal.primitives.StubBytesCompat): void {
1010
lazyContext.ledger.setGlobalState(lazyContext.activeApplication, a, undefined)
1111
},

src/impl/app-local.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { bytes, internal, uint64, Account, Application } from '@algorandfoundation/algorand-typescript'
1+
import type { Account, Application, bytes, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { Bytes, Uint64 } from '@algorandfoundation/algorand-typescript'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { toBytes } from '../encoders'
55
import { asBytes } from '../util'
66
import { getAccount } from './acct-params'
77
import { getApp } from './app-params'
88

9-
export const AppLocal: internal.opTypes.AppLocalType = {
9+
export const AppLocal: typeof op.AppLocal = {
1010
delete: function (a: Account | internal.primitives.StubUint64Compat, b: internal.primitives.StubBytesCompat): void {
1111
const app = lazyContext.activeApplication
1212
const account = getAccount(a)

src/impl/app-params.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type {
2+
Account as AccountType,
3+
Application as ApplicationType,
24
bytes,
35
gtxn,
46
internal,
7+
op,
58
uint64,
6-
Account as AccountType,
7-
Application as ApplicationType,
89
} from '@algorandfoundation/algorand-typescript'
910
import { Bytes, Uint64 } from '@algorandfoundation/algorand-typescript'
1011
import { lazyContext } from '../context-helpers/internal-context'
@@ -32,7 +33,7 @@ export const getApp = (app: ApplicationType | internal.primitives.StubUint64Comp
3233
}
3334
}
3435

35-
export const AppParams: internal.opTypes.AppParamsType = {
36+
export const AppParams: typeof op.AppParams = {
3637
appApprovalProgram(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [bytes, boolean] {
3738
const app = getApp(a)
3839
return app === undefined ? [Bytes(), false] : [app.approvalProgram, true]

src/impl/asset-holding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { internal, uint64, Account, Asset } from '@algorandfoundation/algorand-typescript'
1+
import type { Account, Asset, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { Uint64 } from '@algorandfoundation/algorand-typescript'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { getAccount } from './acct-params'
@@ -23,7 +23,7 @@ const getAssetHolding = (
2323
return holding
2424
}
2525

26-
export const AssetHolding: internal.opTypes.AssetHoldingType = {
26+
export const AssetHolding: typeof op.AssetHolding = {
2727
assetBalance(
2828
a: Account | internal.primitives.StubUint64Compat,
2929
b: Asset | internal.primitives.StubUint64Compat,

src/impl/asset-params.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { bytes, gtxn, internal, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import type { bytes, gtxn, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { type Account as AccountType, type Asset as AssetType, Bytes, Uint64 } from '@algorandfoundation/algorand-typescript'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { asMaybeUint64Cls, asUint64 } from '../util'
@@ -25,7 +25,7 @@ export const getAsset = (asset: AssetType | internal.primitives.StubUint64Compat
2525
}
2626
}
2727

28-
export const AssetParams: internal.opTypes.AssetParamsType = {
28+
export const AssetParams: typeof op.AssetParams = {
2929
assetTotal(a: AssetType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
3030
const asset = getAsset(a)
3131
return asset === undefined ? [Uint64(0), false] : [asset.total, true]

src/impl/block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { bytes, internal, uint64, Account as AccountType } from '@algorandfoundation/algorand-typescript'
1+
import type { Account as AccountType, bytes, internal, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { Uint64 } from '@algorandfoundation/algorand-typescript'
33
import { lazyContext } from '../context-helpers/internal-context'
44
import { asUint64, getRandomBytes } from '../util'
@@ -30,7 +30,7 @@ export class BlockData {
3030
}
3131
}
3232

33-
export const Block: internal.opTypes.BlockType = {
33+
export const Block: typeof op.Block = {
3434
blkSeed: function (a: internal.primitives.StubUint64Compat): bytes {
3535
return lazyContext.ledger.getBlockData(a).seed
3636
},

src/impl/box.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { bytes, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import type { bytes, op, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { internal } from '@algorandfoundation/algorand-typescript'
33
import { MAX_BOX_SIZE } from '../constants'
44
import { lazyContext } from '../context-helpers/internal-context'
55
import { toBytes } from '../encoders'
66
import { asBytes, asBytesCls, asNumber, asUint8Array, conactUint8Arrays } from '../util'
77

8-
export const Box: internal.opTypes.BoxType = {
8+
export const Box: typeof op.Box = {
99
create(a: internal.primitives.StubBytesCompat, b: internal.primitives.StubUint64Compat): boolean {
1010
const name = asBytes(a)
1111
const size = asNumber(b)

src/impl/crypto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { bytes, gtxn, MimcConfigurations, VrfVerify } from '@algorandfoundation/algorand-typescript'
1+
import type { bytes, gtxn, MimcConfigurations, op, VrfVerify } from '@algorandfoundation/algorand-typescript'
22
import { arc4, Bytes, Ecdsa, internal } from '@algorandfoundation/algorand-typescript'
33
import elliptic from 'elliptic'
44
import js_sha256 from 'js-sha256'
@@ -138,7 +138,7 @@ export const vrfVerify = (
138138
notImplementedError('vrfVerify')
139139
}
140140

141-
export const EllipticCurve = new Proxy({} as internal.opTypes.EllipticCurveType, {
141+
export const EllipticCurve = new Proxy({} as typeof op.EllipticCurve, {
142142
get: (_target, prop) => {
143143
notImplementedError(`EllipticCurve.${prop.toString()}`)
144144
},

0 commit comments

Comments
 (0)