Skip to content

Commit

Permalink
Merge pull request #101 from algorandfoundation/refactor/bigIntToUint8
Browse files Browse the repository at this point in the history
refactor: tweak bigInt to Uint8Array function to match AVM
  • Loading branch information
boblat authored Feb 7, 2025
2 parents bddea61 + 5a58464 commit c09f427
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export const uint8ArrayToUtf8 = (value: Uint8Array): string => {
}

export const bigIntToUint8Array = (val: bigint, fixedSize: number | 'dynamic' = 'dynamic'): Uint8Array => {
const maxBytes = fixedSize === 'dynamic' ? 64 : fixedSize
if (val === 0n && fixedSize === 'dynamic') {
return new Uint8Array(0)
}
const maxBytes = fixedSize === 'dynamic' ? 4096 : fixedSize

let hex = val.toString(16)

Expand Down

0 comments on commit c09f427

Please sign in to comment.