Skip to content

Box getters return wrong types for uint8 / uiont16 / uint32 (typed number, returned bigint) #420

@tasosbit

Description

@tasosbit

Subject of the issue

Box getters return wrong types for uint8 / uiont16 / uint32 struct values (typed number, returned bigint)

Repro repo here

For this puya TS code:

class User extends arc4.Struct<{ userId: UintN16; name: Str }> {}

export class Repro extends Contract {
  user = BoxMap<Account, User>({ keyPrefix: 'r' })

  public hello(name: string): User {
    const u = new User({
      name: new arc4.Str(name),
      userId: new arc4.UintN16(1),
    })

    this.user(Txn.sender).value = u.copy()

    return u
  }
}

User.userId is typed as number in the generated clients, but the box getters return this as bigint instead:

  // user.userId is typed as number, but is returned as bigint here
  const user = await appClient.state.box.user.value(deployer.toString())

  console.log('From box fetcher', user, typeof user!.userId)
  // From box fetcher { userId: 1n, name: 'world' } bigint

Interestingly the client return/returns values are typed correctly:

  const response = await appClient.send.hello({
    args: { name: 'world' },
  })

  console.log('type', typeof response.return!.userId) // type number

Your environment

timestamp: 2025-07-16T17:03:50+00:00
AlgoKit: 2.7.1
AlgoKit Python: 3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] (location: /home/bit/.local/pipx/venvs/algokit)
OS: Linux-6.0.8-x86_64-with-glibc2.35
docker: 27.0.3
docker compose: 2.28.1
git: 2.34.1
python: 2.7.18 (location: /usr/local/bin/python)
python3: 3.10.12 (location: /usr/bin/python3)
pipx: 1.7.1
poetry: 1.8.3
node: 22.17.0
npm: 10.9.2

@algorandfoundation/puya-ts@1.0.0-beta.71

Steps to reproduce

  1. See attached code or repro code (in deploy-config.ts)

Expected behaviour

uint16 struct value is returned as typed (number)

Actual behaviour

uint16 struct value is returned as bigint

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions