Skip to content

Commit 99e165f

Browse files
committed
refactor: use import replacement to swap in stub implementations
1 parent 2040373 commit 99e165f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+656
-510
lines changed

.tstoolkitrc.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const config: TsToolkitConfig = {
1010
exports: {
1111
'.': 'index.ts',
1212
'./runtime-helpers': 'runtime-helpers.ts',
13+
'./internal': 'internal.ts',
14+
'./internal/arc4': 'internal-arc4.ts',
15+
'./internal/op': 'internal-op.ts',
1316
'./test-transformer': 'test-transformer/index.ts',
1417
},
1518
},

rollup.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const config: RollupOptions = {
88
input: {
99
index: 'src/index.ts',
1010
'runtime-helpers': 'src/runtime-helpers.ts',
11+
'internal': 'src/internal.ts',
12+
'internal/arc4': 'src/internal-arc4.ts',
13+
'internal/op': 'src/internal-op.ts',
1114
'test-transformer/index': 'src/test-transformer/index.ts',
1215
},
1316
output: [

src/collections/custom-key-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Account, internal } from '@algorandfoundation/algorand-typescript'
1+
import { type Account, internal } from '@algorandfoundation/algorand-typescript'
22
import { DeliberateAny } from '../typescript-helpers'
33
import { asBytesCls, asUint64Cls } from '../util'
44

src/context-helpers/internal-context.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { Account, BaseContract, internal } from '@algorandfoundation/algorand-typescript'
2-
import { AccountData } from '../impl/account'
3-
import { ApplicationData } from '../impl/application'
4-
import { AssetData } from '../impl/asset'
1+
import { type Account, BaseContract, internal } from '@algorandfoundation/algorand-typescript'
2+
import { AccountData, ApplicationData, AssetData } from '../impl/reference'
53
import { VoterData } from '../impl/voter-params'
64
import { TransactionGroup } from '../subcontexts/transaction-context'
75
import { TestExecutionContext } from '../test-execution-context'

src/encoders.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { biguint, BigUint, bytes, internal, TransactionType, uint64, Uint64 } from '@algorandfoundation/algorand-typescript'
22
import { ARC4Encoded, OnCompleteAction } from '@algorandfoundation/algorand-typescript/arc4'
3-
import { AccountCls } from './impl/account'
4-
import { ApplicationCls } from './impl/application'
5-
import { AssetCls } from './impl/asset'
63
import { BytesBackedCls, Uint64BackedCls } from './impl/base'
74
import { arc4Encoders, encodeArc4Impl, getArc4Encoder } from './impl/encoded-types'
5+
import { AccountCls, ApplicationCls, AssetCls } from './impl/reference'
86
import { DeliberateAny } from './typescript-helpers'
97
import { asBytes, asMaybeBigUintCls, asMaybeBytesCls, asMaybeUint64Cls, asUint64Cls, asUint8Array, nameOfType } from './util'
108

src/impl/account.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/impl/acct-params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Account, Application, gtxn, internal, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import { type Account, type Application, gtxn, internal, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { lazyContext } from '../context-helpers/internal-context'
33
import { asMaybeUint64Cls } from '../util'
44
import { getApp } from './app-params'

src/impl/app-local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Account, Application, Bytes, bytes, internal, Uint64, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import { type Account, type Application, Bytes, bytes, internal, Uint64, uint64 } from '@algorandfoundation/algorand-typescript'
22
import { lazyContext } from '../context-helpers/internal-context'
33
import { toBytes } from '../encoders'
44
import { asBytes } from '../util'

src/impl/app-params.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import { Account, Application, Bytes, bytes, gtxn, internal, Uint64, uint64 } from '@algorandfoundation/algorand-typescript'
1+
import {
2+
type Account as AccountType,
3+
type Application as ApplicationType,
4+
Bytes,
5+
bytes,
6+
gtxn,
7+
internal,
8+
Uint64,
9+
uint64,
10+
} from '@algorandfoundation/algorand-typescript'
211
import { lazyContext } from '../context-helpers/internal-context'
312
import { asMaybeUint64Cls, asUint64 } from '../util'
13+
import { Account } from './reference'
414

515
const resolveAppIndex = (appIdOrIndex: internal.primitives.StubUint64Compat): uint64 => {
616
const input = asUint64(appIdOrIndex)
@@ -11,52 +21,52 @@ const resolveAppIndex = (appIdOrIndex: internal.primitives.StubUint64Compat): ui
1121
return txn.apps(input).id
1222
}
1323

14-
export const getApp = (app: Application | internal.primitives.StubUint64Compat): Application | undefined => {
24+
export const getApp = (app: ApplicationType | internal.primitives.StubUint64Compat): ApplicationType | undefined => {
1525
try {
1626
const appId = asMaybeUint64Cls(app)
1727
if (appId !== undefined) {
1828
return lazyContext.ledger.getApplication(resolveAppIndex(appId))
1929
}
20-
return app as Application
30+
return app as ApplicationType
2131
} catch {
2232
return undefined
2333
}
2434
}
2535

2636
export const AppParams: internal.opTypes.AppParamsType = {
27-
appApprovalProgram(a: Application | internal.primitives.StubUint64Compat): readonly [bytes, boolean] {
37+
appApprovalProgram(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [bytes, boolean] {
2838
const app = getApp(a)
2939
return app === undefined ? [Bytes(), false] : [app.approvalProgram, true]
3040
},
31-
appClearStateProgram(a: Application | internal.primitives.StubUint64Compat): readonly [bytes, boolean] {
41+
appClearStateProgram(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [bytes, boolean] {
3242
const app = getApp(a)
3343
return app === undefined ? [Bytes(), false] : [app.clearStateProgram, true]
3444
},
35-
appGlobalNumUint(a: Application | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
45+
appGlobalNumUint(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
3646
const app = getApp(a)
3747
return app === undefined ? [Uint64(0), false] : [app.globalNumUint, true]
3848
},
39-
appGlobalNumByteSlice(a: Application | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
49+
appGlobalNumByteSlice(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
4050
const app = getApp(a)
4151
return app === undefined ? [Uint64(0), false] : [app.globalNumBytes, true]
4252
},
43-
appLocalNumUint(a: Application | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
53+
appLocalNumUint(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
4454
const app = getApp(a)
4555
return app === undefined ? [Uint64(0), false] : [app.localNumUint, true]
4656
},
47-
appLocalNumByteSlice(a: Application | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
57+
appLocalNumByteSlice(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
4858
const app = getApp(a)
4959
return app === undefined ? [Uint64(0), false] : [app.localNumBytes, true]
5060
},
51-
appExtraProgramPages(a: Application | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
61+
appExtraProgramPages(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [uint64, boolean] {
5262
const app = getApp(a)
5363
return app === undefined ? [Uint64(0), false] : [app.extraProgramPages, true]
5464
},
55-
appCreator(a: Application | internal.primitives.StubUint64Compat): readonly [Account, boolean] {
65+
appCreator(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [AccountType, boolean] {
5666
const app = getApp(a)
5767
return app === undefined ? [Account(), false] : [app.creator, true]
5868
},
59-
appAddress(a: Application | internal.primitives.StubUint64Compat): readonly [Account, boolean] {
69+
appAddress(a: ApplicationType | internal.primitives.StubUint64Compat): readonly [AccountType, boolean] {
6070
const app = getApp(a)
6171
return app === undefined ? [Account(), false] : [app.address, true]
6272
},

src/impl/application.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)