11import type { biguint , bytes , TransactionType , uint64 } from '@algorandfoundation/algorand-typescript'
2- import { BigUint , internal , Uint64 } from '@algorandfoundation/algorand-typescript'
32import type { OnCompleteAction } from '@algorandfoundation/algorand-typescript/arc4'
43import { ARC4Encoded } from '@algorandfoundation/algorand-typescript/arc4'
4+ import { uint8ArrayToBigInt } from './encoding-util'
5+ import { internalError } from './errors'
56import { BytesBackedCls , Uint64BackedCls } from './impl/base'
67import { arc4Encoders , encodeArc4Impl , getArc4Encoder } from './impl/encoded-types'
8+ import { BigUint , Uint64 , type StubBytesCompat } from './impl/primitives'
79import { AccountCls , ApplicationCls , AssetCls } from './impl/reference'
810import type { DeliberateAny } from './typescript-helpers'
911import { asBytes , asMaybeBigUintCls , asMaybeBytesCls , asMaybeUint64Cls , asUint64Cls , asUint8Array , nameOfType } from './util'
@@ -13,14 +15,14 @@ export type TypeInfo = {
1315 genericArgs ?: TypeInfo [ ] | Record < string , TypeInfo >
1416}
1517
16- export type fromBytes < T > = ( val : Uint8Array | internal . primitives . StubBytesCompat , typeInfo : TypeInfo , prefix ?: 'none' | 'log' ) => T
18+ export type fromBytes < T > = ( val : Uint8Array | StubBytesCompat , typeInfo : TypeInfo , prefix ?: 'none' | 'log' ) => T
1719
1820const booleanFromBytes : fromBytes < boolean > = ( val ) => {
19- return internal . encodingUtil . uint8ArrayToBigInt ( asUint8Array ( val ) ) > 0n
21+ return uint8ArrayToBigInt ( asUint8Array ( val ) ) > 0n
2022}
2123
2224const bigUintFromBytes : fromBytes < biguint > = ( val ) => {
23- return BigUint ( internal . encodingUtil . uint8ArrayToBigInt ( asUint8Array ( val ) ) )
25+ return BigUint ( uint8ArrayToBigInt ( asUint8Array ( val ) ) )
2426}
2527
2628const bytesFromBytes : fromBytes < bytes > = ( val ) => {
@@ -32,15 +34,15 @@ const stringFromBytes: fromBytes<string> = (val) => {
3234}
3335
3436const uint64FromBytes : fromBytes < uint64 > = ( val ) => {
35- return Uint64 ( internal . encodingUtil . uint8ArrayToBigInt ( asUint8Array ( val ) ) )
37+ return Uint64 ( uint8ArrayToBigInt ( asUint8Array ( val ) ) )
3638}
3739
3840const onCompletionFromBytes : fromBytes < OnCompleteAction > = ( val ) => {
39- return Uint64 ( internal . encodingUtil . uint8ArrayToBigInt ( asUint8Array ( val ) ) ) as OnCompleteAction
41+ return Uint64 ( uint8ArrayToBigInt ( asUint8Array ( val ) ) ) as OnCompleteAction
4042}
4143
4244const transactionTypeFromBytes : fromBytes < TransactionType > = ( val ) => {
43- return Uint64 ( internal . encodingUtil . uint8ArrayToBigInt ( asUint8Array ( val ) ) ) as TransactionType
45+ return Uint64 ( uint8ArrayToBigInt ( asUint8Array ( val ) ) ) as TransactionType
4446}
4547
4648export const encoders : Record < string , fromBytes < DeliberateAny > > = {
@@ -86,5 +88,5 @@ export const toBytes = (val: unknown): bytes => {
8688 if ( Array . isArray ( val ) || typeof val === 'object' ) {
8789 return encodeArc4Impl ( '' , val )
8890 }
89- internal . errors . internalError ( `Invalid type for bytes: ${ nameOfType ( val ) } ` )
91+ internalError ( `Invalid type for bytes: ${ nameOfType ( val ) } ` )
9092}
0 commit comments