Skip to content

fix(sdk): support bigint spending limit amounts - #195

Open
2wheeh wants to merge 1 commit into
Squads-Protocol:mainfrom
ultarixyz:fix/spending-limit-use-bignum
Open

fix(sdk): support bigint spending limit amounts#195
2wheeh wants to merge 1 commit into
Squads-Protocol:mainfrom
ultarixyz:fix/spending-limit-use-bignum

Conversation

@2wheeh

@2wheeh 2wheeh commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Fix the spendingLimitUse public wrappers to accept values across the full u64 range without exposing BN or @metaplex-foundation/beet types in the public wrapper API.

The generated SpendingLimitUseArgs.amount field uses beet.bignum, which is defined as number | BN, while the instruction, transaction, and RPC wrappers previously accepted only number.

JavaScript numbers cannot safely represent the full u64 range. The wrappers now accept number | bigint and convert the value to BN internally at the generated serializer boundary.

Existing callers passing number remain backward-compatible.

Changes

  • Change amount from number to number | bigint in:
    • instructions.spendingLimitUse
    • transactions.spendingLimitUse
    • rpc.spendingLimitUse
  • Convert amount to BN internally before passing it to the generated serializer.
  • Add a compile-time type test verifying that all three public wrappers expose exactly number | bigint.
  • Add a runtime regression test verifying lossless serialization of u64::MAX.
  • Add a standalone test:types command for running the compile-time test.

The type test is intentionally not wired into the existing SDK build or CI pipeline to keep this fix scoped to the public API issue.

Testing

Run the compile-time API test:

yarn workspace @sqds/multisig test:types

Build the SDK:

yarn workspace @sqds/multisig build

Run the runtime serialization test:

yarn mocha -r ts-node/register tests/suites/instructions/spendingLimitUse.ts

The runtime regression test uses u64::MAX:

18446744073709551615

It verifies that a native bigint is serialized and decoded without precision loss.

The compile-time test was also mutation-tested by temporarily changing a wrapper back to amount: number. The test failed as expected, confirming that the original type regression is detected.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@2wheeh is attempting to deploy a commit to the squads Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant