@@ -14,7 +14,7 @@ import {
1414import { MAX_ITEMS_IN_LOG } from '../constants'
1515import { lazyContext } from '../context-helpers/internal-context'
1616import { Mutable , ObjectKeys } from '../typescript-helpers'
17- import { asBytes , asNumber , getRandomBytes } from '../util'
17+ import { asBytes , asNumber , asUint64Cls , combineIntoMaxBytePages , getRandomBytes } from '../util'
1818
1919const baseDefaultFields = ( ) => ( {
2020 sender : lazyContext . defaultSender ,
@@ -24,7 +24,6 @@ const baseDefaultFields = () => ({
2424 lastValid : Uint64 ( 0 ) ,
2525 note : Bytes ( ) ,
2626 lease : Bytes ( ) ,
27- typeBytes : Bytes ( ) ,
2827 groupIndex : Uint64 ( 0 ) ,
2928 txnId : getRandomBytes ( 32 ) . asAlgoTs ( ) ,
3029 rekeyTo : Account ( ) ,
@@ -42,7 +41,6 @@ abstract class TransactionBase {
4241 this . lastValid = fields . lastValid ?? baseDefaults . lastValid
4342 this . note = fields . note ?? baseDefaults . note
4443 this . lease = fields . lease ?? baseDefaults . lease
45- this . typeBytes = fields . typeBytes ?? baseDefaults . typeBytes
4644 this . groupIndex = fields . groupIndex ?? baseDefaults . groupIndex
4745 this . txnId = fields . txnId ?? baseDefaults . txnId
4846 this . rekeyTo = fields . rekeyTo ?? baseDefaults . rekeyTo
@@ -55,7 +53,6 @@ abstract class TransactionBase {
5553 readonly lastValid : uint64
5654 readonly note : bytes
5755 readonly lease : bytes
58- readonly typeBytes : bytes
5956 readonly groupIndex : uint64
6057 readonly txnId : bytes
6158 readonly rekeyTo : Account
@@ -78,6 +75,7 @@ export class PaymentTransaction extends TransactionBase implements gtxn.PaymentT
7875 readonly amount : uint64
7976 readonly closeRemainderTo : Account
8077 readonly type : TransactionType . Payment = TransactionType . Payment
78+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . Payment ) . toBytes ( ) . asAlgoTs ( )
8179}
8280
8381export class KeyRegistrationTransaction extends TransactionBase implements gtxn . KeyRegistrationTxn {
@@ -105,6 +103,7 @@ export class KeyRegistrationTransaction extends TransactionBase implements gtxn.
105103 readonly nonparticipation : boolean
106104 readonly stateProofKey : bytes
107105 readonly type : TransactionType . KeyRegistration = TransactionType . KeyRegistration
106+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . KeyRegistration ) . toBytes ( ) . asAlgoTs ( )
108107}
109108
110109export class AssetConfigTransaction extends TransactionBase implements gtxn . AssetConfigTxn {
@@ -144,6 +143,7 @@ export class AssetConfigTransaction extends TransactionBase implements gtxn.Asse
144143 readonly clawback : Account
145144 readonly createdAsset : Asset
146145 readonly type : TransactionType . AssetConfig = TransactionType . AssetConfig
146+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . AssetConfig ) . toBytes ( ) . asAlgoTs ( )
147147}
148148
149149export class AssetTransferTransaction extends TransactionBase implements gtxn . AssetTransferTxn {
@@ -168,6 +168,7 @@ export class AssetTransferTransaction extends TransactionBase implements gtxn.As
168168 readonly assetCloseTo : Account
169169
170170 readonly type : TransactionType . AssetTransfer = TransactionType . AssetTransfer
171+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . AssetTransfer ) . toBytes ( ) . asAlgoTs ( )
171172}
172173
173174export class AssetFreezeTransaction extends TransactionBase implements gtxn . AssetFreezeTxn {
@@ -188,6 +189,7 @@ export class AssetFreezeTransaction extends TransactionBase implements gtxn.Asse
188189 readonly frozen : boolean
189190
190191 readonly type : TransactionType . AssetFreeze = TransactionType . AssetFreeze
192+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . AssetFreeze ) . toBytes ( ) . asAlgoTs ( )
191193}
192194
193195export type ApplicationTransactionFields = TxnFields < gtxn . ApplicationTxn > &
@@ -260,10 +262,10 @@ export class ApplicationTransaction extends TransactionBase implements gtxn.Appl
260262 return Uint64 ( this . #apps. length )
261263 }
262264 get numApprovalProgramPages ( ) {
263- return Uint64 ( this . # approvalProgramPages. length )
265+ return Uint64 ( this . approvalProgramPages . length )
264266 }
265267 get numClearStateProgramPages ( ) {
266- return Uint64 ( this . # clearStateProgramPages. length )
268+ return Uint64 ( this . clearStateProgramPages . length )
267269 }
268270 get numLogs ( ) {
269271 return Uint64 ( this . #appLogs. length || lazyContext . getApplicationData ( this . appId . id ) . appLogs . length )
@@ -284,16 +286,17 @@ export class ApplicationTransaction extends TransactionBase implements gtxn.Appl
284286 return this . #apps[ asNumber ( index ) ]
285287 }
286288 approvalProgramPages ( index : internal . primitives . StubUint64Compat ) : bytes {
287- return this . #approvalProgramPages[ asNumber ( index ) ]
289+ return combineIntoMaxBytePages ( this . #approvalProgramPages) [ asNumber ( index ) ]
288290 }
289291 clearStateProgramPages ( index : internal . primitives . StubUint64Compat ) : bytes {
290- return this . #clearStateProgramPages[ asNumber ( index ) ]
292+ return combineIntoMaxBytePages ( this . #clearStateProgramPages) [ asNumber ( index ) ]
291293 }
292294 logs ( index : internal . primitives . StubUint64Compat ) : bytes {
293295 const i = asNumber ( index )
294296 return this . #appLogs[ i ] ?? lazyContext . getApplicationData ( this . appId . id ) . appLogs ?? Bytes ( )
295297 }
296298 readonly type : TransactionType . ApplicationCall = TransactionType . ApplicationCall
299+ readonly typeBytes : bytes = asUint64Cls ( TransactionType . ApplicationCall ) . toBytes ( ) . asAlgoTs ( )
297300
298301 /* @internal */
299302 get appLogs ( ) {
0 commit comments