Skip to content

Add FIXED_POINTS error codes#1559

Merged
lorisleiva merged 1 commit into
mainfrom
04-23-add_fixed_points_error_codes
May 5, 2026
Merged

Add FIXED_POINTS error codes#1559
lorisleiva merged 1 commit into
mainfrom
04-23-add_fixed_points_error_codes

Conversation

@lorisleiva
Copy link
Copy Markdown
Member

This PR is part of the stack implementing the fixed-point number types proposed in #1545. It lands every error code, context shape, and message that the new package will throw, so later PRs in the stack can just reference them.

Reserves the range [8090000-8090999] for the FIXED_POINTS domain and allocates 12 codes covering invalid shape parameters (total bits, fractional bits, decimals, and the binary-only "fractional bits exceed total bits" check), out-of-range raw values, malformed raw values, malformed strings, zero-denominator ratios, division by zero, arithmetic overflow (shared by add/subtract/multiply/divide/negate/absolute/rescale/signedness conversion), strict shape mismatches in operations and codecs, and strict-mode precision loss when factories and operations cannot produce an exact result without rounding.

Here is an example message for each new code:

  • SOLANA_ERROR__FIXED_POINTS__INVALID_TOTAL_BITS:
    Invalid `totalBits`. Expected a positive integer, got foo.
    
  • SOLANA_ERROR__FIXED_POINTS__INVALID_FRACTIONAL_BITS:
    Invalid `fractionalBits`. Expected a non-negative integer, got -1.
    
  • SOLANA_ERROR__FIXED_POINTS__INVALID_DECIMALS:
    Invalid `decimals`. Expected a non-negative integer, got 1.5.
    
  • SOLANA_ERROR__FIXED_POINTS__FRACTIONAL_BITS_EXCEED_TOTAL_BITS:
    `fractionalBits` (64) must not exceed `totalBits` (16).
    
  • SOLANA_ERROR__FIXED_POINTS__VALUE_OUT_OF_RANGE:
    Fixed-point value of kind `decimalFixedPoint` is out of range for unsigned 8-bit storage. Expected a raw bigint in [0, 255], got 999.
    
  • SOLANA_ERROR__FIXED_POINTS__INVALID_STRING:
    Invalid string `abc` for fixed-point value of kind `binaryFixedPoint`.
    
  • SOLANA_ERROR__FIXED_POINTS__INVALID_ZERO_DENOMINATOR_RATIO:
    Invalid ratio 3/0 for fixed-point value of kind `decimalFixedPoint`. Denominator must be non-zero.
    
  • SOLANA_ERROR__FIXED_POINTS__ARITHMETIC_OVERFLOW:
    Fixed-point operation `add` of kind `binaryFixedPoint` overflowed. Expected a raw bigint in [-128, 127], got 256.
    
  • SOLANA_ERROR__FIXED_POINTS__SHAPE_MISMATCH:
    Fixed-point `add` operation expected binaryFixedPoint (signed, 16 bits, 8 fractional bits); got decimalFixedPoint (unsigned, 64 bits, 6 decimals).
    
  • SOLANA_ERROR__FIXED_POINTS__DIVISION_BY_ZERO:
    Fixed-point division by zero for value of kind `decimalFixedPoint` (unsigned, 64 bits).
    
  • SOLANA_ERROR__FIXED_POINTS__STRICT_MODE_PRECISION_LOSS:
    Fixed-point operation `fromRatio` of kind `decimalFixedPoint` cannot be performed exactly; pass a rounding mode other than `strict` to allow a rounded result.
    
  • SOLANA_ERROR__FIXED_POINTS__MALFORMED_RAW_VALUE:
    Fixed-point value of kind `binaryFixedPoint` has a malformed `raw` field. Expected a bigint, got `42`.
    

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: 74ef76c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 47 packages
Name Type
@solana/errors Minor
@solana/accounts Minor
@solana/addresses Minor
@solana/assertions Minor
@solana/codecs-core Minor
@solana/codecs-data-structures Minor
@solana/codecs-numbers Minor
@solana/codecs-strings Minor
@solana/compat Minor
@solana/instruction-plans Minor
@solana/instructions Minor
@solana/keys Minor
@solana/kit Minor
@solana/offchain-messages Minor
@solana/options Minor
@solana/program-client-core Minor
@solana/programs Minor
@solana/react Minor
@solana/rpc-api Minor
@solana/rpc-spec Minor
@solana/rpc-subscriptions-channel-websocket Minor
@solana/rpc-subscriptions-spec Minor
@solana/rpc-subscriptions Minor
@solana/rpc-transformers Minor
@solana/rpc-transport-http Minor
@solana/rpc-types Minor
@solana/rpc Minor
@solana/signers Minor
@solana/subscribable Minor
@solana/sysvars Minor
@solana/transaction-confirmation Minor
@solana/transaction-messages Minor
@solana/transactions Minor
@solana/wallet-account-signer Minor
@solana/plugin-interfaces Minor
@solana/rpc-graphql Minor
@solana/rpc-parsed-types Minor
@solana/rpc-subscriptions-api Minor
@solana/codecs Minor
@solana/fast-stable-stringify Minor
@solana/fixed-points Minor
@solana/functional Minor
@solana/nominal-types Minor
@solana/plugin-core Minor
@solana/promises Minor
@solana/rpc-spec-types Minor
@solana/webcrypto-ed25519-polyfill Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Apr 24, 2026

BundleMon

Files updated (7)
Status Path Size Limits
errors/dist/index.browser.mjs
20.42KB (+793B +3.94%) -
errors/dist/index.node.mjs
20.44KB (+793B +3.94%) -
errors/dist/index.native.mjs
20.41KB (+792B +3.94%) -
wallet-account-signer/dist/index.browser.mjs
17.27KB (+640B +3.75%) -
wallet-account-signer/dist/index.node.mjs
17.29KB (+640B +3.75%) -
wallet-account-signer/dist/index.native.mjs
17.27KB (+639B +3.75%) -
@solana/kit production bundle
kit/dist/index.production.min.js
47.72KB (+201B +0.41%) -
Unchanged files (140)
Status Path Size Limits
rpc-graphql/dist/index.browser.mjs
18.82KB -
rpc-graphql/dist/index.native.mjs
18.81KB -
rpc-graphql/dist/index.node.mjs
18.81KB -
transaction-messages/dist/index.browser.mjs
11.32KB -
transaction-messages/dist/index.native.mjs
11.32KB -
transaction-messages/dist/index.node.mjs
11.32KB -
instruction-plans/dist/index.browser.mjs
6.58KB -
instruction-plans/dist/index.native.mjs
6.58KB -
instruction-plans/dist/index.node.mjs
6.58KB -
codecs-data-structures/dist/index.browser.mjs
5.04KB -
codecs-data-structures/dist/index.native.mjs
5.03KB -
codecs-data-structures/dist/index.node.mjs
5.03KB -
offchain-messages/dist/index.browser.mjs
4.89KB -
offchain-messages/dist/index.native.mjs
4.89KB -
offchain-messages/dist/index.node.mjs
4.89KB -
transactions/dist/index.browser.mjs
4.07KB -
transactions/dist/index.native.mjs
4.07KB -
transactions/dist/index.node.mjs
4.07KB -
kit/dist/index.browser.mjs
3.72KB -
kit/dist/index.native.mjs
3.72KB -
kit/dist/index.node.mjs
3.72KB -
codecs-core/dist/index.browser.mjs
3.62KB -
codecs-core/dist/index.native.mjs
3.62KB -
codecs-core/dist/index.node.mjs
3.62KB -
webcrypto-ed25519-polyfill/dist/index.node.mj
s
3.61KB -
webcrypto-ed25519-polyfill/dist/index.browser
.mjs
3.59KB -
webcrypto-ed25519-polyfill/dist/index.native.
mjs
3.57KB -
rpc-subscriptions/dist/index.browser.mjs
3.37KB -
rpc-subscriptions/dist/index.node.mjs
3.34KB -
rpc-subscriptions/dist/index.native.mjs
3.31KB -
signers/dist/index.browser.mjs
3.26KB -
signers/dist/index.native.mjs
3.26KB -
signers/dist/index.node.mjs
3.26KB -
rpc-transformers/dist/index.browser.mjs
3.16KB -
rpc-transformers/dist/index.native.mjs
3.16KB -
rpc-transformers/dist/index.node.mjs
3.16KB -
react/dist/index.browser.mjs
3.09KB -
react/dist/index.native.mjs
3.09KB -
react/dist/index.node.mjs
3.09KB -
keys/dist/index.node.mjs
3.06KB -
addresses/dist/index.browser.mjs
2.93KB -
addresses/dist/index.native.mjs
2.92KB -
addresses/dist/index.node.mjs
2.92KB -
keys/dist/index.browser.mjs
2.85KB -
keys/dist/index.native.mjs
2.85KB -
codecs-strings/dist/index.browser.mjs
2.55KB -
codecs-strings/dist/index.node.mjs
2.51KB -
codecs-strings/dist/index.native.mjs
2.47KB -
transaction-confirmation/dist/index.node.mjs
2.41KB -
sysvars/dist/index.browser.mjs
2.37KB -
sysvars/dist/index.native.mjs
2.37KB -
sysvars/dist/index.node.mjs
2.37KB -
transaction-confirmation/dist/index.native.mj
s
2.36KB -
transaction-confirmation/dist/index.browser.m
js
2.35KB -
rpc-subscriptions-spec/dist/index.node.mjs
2.21KB -
rpc-subscriptions-spec/dist/index.native.mjs
2.17KB -
rpc-subscriptions-spec/dist/index.browser.mjs
2.16KB -
subscribable/dist/index.node.mjs
1.97KB -
rpc/dist/index.node.mjs
1.95KB -
codecs-numbers/dist/index.browser.mjs
1.95KB -
codecs-numbers/dist/index.native.mjs
1.95KB -
codecs-numbers/dist/index.node.mjs
1.94KB -
subscribable/dist/index.native.mjs
1.92KB -
subscribable/dist/index.browser.mjs
1.91KB -
rpc-transport-http/dist/index.browser.mjs
1.91KB -
rpc-transport-http/dist/index.native.mjs
1.9KB -
rpc/dist/index.native.mjs
1.81KB -
rpc/dist/index.browser.mjs
1.8KB -
rpc-transport-http/dist/index.node.mjs
1.72KB -
rpc-types/dist/index.browser.mjs
1.53KB -
rpc-types/dist/index.native.mjs
1.53KB -
rpc-types/dist/index.node.mjs
1.53KB -
rpc-subscriptions-channel-websocket/dist/inde
x.node.mjs
1.33KB -
rpc-subscriptions-channel-websocket/dist/inde
x.native.mjs
1.27KB -
rpc-subscriptions-channel-websocket/dist/inde
x.browser.mjs
1.26KB -
program-client-core/dist/index.browser.mjs
1.21KB -
program-client-core/dist/index.native.mjs
1.21KB -
program-client-core/dist/index.node.mjs
1.21KB -
options/dist/index.browser.mjs
1.18KB -
options/dist/index.native.mjs
1.18KB -
options/dist/index.node.mjs
1.17KB -
accounts/dist/index.browser.mjs
1.17KB -
accounts/dist/index.native.mjs
1.17KB -
accounts/dist/index.node.mjs
1.16KB -
rpc-api/dist/index.browser.mjs
976B -
rpc-api/dist/index.native.mjs
975B -
rpc-api/dist/index.node.mjs
973B -
compat/dist/index.browser.mjs
969B -
compat/dist/index.native.mjs
968B -
compat/dist/index.node.mjs
966B -
rpc-spec-types/dist/index.browser.mjs
962B -
rpc-spec-types/dist/index.native.mjs
961B -
rpc-spec-types/dist/index.node.mjs
959B -
rpc-subscriptions-api/dist/index.native.mjs
870B -
rpc-subscriptions-api/dist/index.node.mjs
869B -
rpc-subscriptions-api/dist/index.browser.mjs
868B -
rpc-spec/dist/index.browser.mjs
852B -
rpc-spec/dist/index.native.mjs
851B -
rpc-spec/dist/index.node.mjs
850B -
promises/dist/index.native.mjs
841B -
promises/dist/index.node.mjs
840B -
promises/dist/index.browser.mjs
839B -
plugin-core/dist/index.browser.mjs
820B -
plugin-core/dist/index.native.mjs
819B -
plugin-core/dist/index.node.mjs
817B -
assertions/dist/index.browser.mjs
783B -
instructions/dist/index.browser.mjs
771B -
instructions/dist/index.native.mjs
770B -
instructions/dist/index.node.mjs
768B -
fast-stable-stringify/dist/index.browser.mjs
726B -
fast-stable-stringify/dist/index.native.mjs
725B -
assertions/dist/index.native.mjs
724B -
fast-stable-stringify/dist/index.node.mjs
724B -
assertions/dist/index.node.mjs
723B -
programs/dist/index.browser.mjs
329B -
programs/dist/index.native.mjs
327B -
programs/dist/index.node.mjs
325B -
fs-impl/dist/index.browser.mjs
245B -
event-target-impl/dist/index.node.mjs
230B -
functional/dist/index.browser.mjs
154B -
functional/dist/index.native.mjs
152B -
text-encoding-impl/dist/index.native.mjs
152B -
functional/dist/index.node.mjs
151B -
codecs/dist/index.browser.mjs
145B -
codecs/dist/index.native.mjs
144B -
fixed-points/dist/index.browser.mjs
144B -
fixed-points/dist/index.native.mjs
143B -
codecs/dist/index.node.mjs
142B -
fixed-points/dist/index.node.mjs
141B -
event-target-impl/dist/index.browser.mjs
133B -
ws-impl/dist/index.node.mjs
131B -
text-encoding-impl/dist/index.browser.mjs
122B -
fs-impl/dist/index.node.mjs
120B -
text-encoding-impl/dist/index.node.mjs
119B -
ws-impl/dist/index.browser.mjs
113B -
crypto-impl/dist/index.node.mjs
111B -
crypto-impl/dist/index.browser.mjs
109B -
rpc-parsed-types/dist/index.browser.mjs
66B -
rpc-parsed-types/dist/index.native.mjs
65B -
rpc-parsed-types/dist/index.node.mjs
63B -

Total files change +4.39KB +0.88%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

Documentation Preview: https://kit-docs-cup4m3c2h-anza-tech.vercel.app

@lorisleiva lorisleiva force-pushed the 04-23-add_fixed_points_error_codes branch from ce87d8d to f73fabb Compare April 24, 2026 16:17
@lorisleiva lorisleiva marked this pull request as ready for review April 24, 2026 16:37
@lorisleiva lorisleiva requested a review from mcintyre94 April 24, 2026 16:37
@lorisleiva lorisleiva force-pushed the 04-23-scaffold_empty_solana_fixed-points_package branch from a949987 to e482616 Compare April 29, 2026 00:30
@lorisleiva lorisleiva force-pushed the 04-23-add_fixed_points_error_codes branch from f73fabb to f35860d Compare April 29, 2026 00:30
@lorisleiva lorisleiva force-pushed the 04-23-scaffold_empty_solana_fixed-points_package branch from e482616 to de697e2 Compare May 4, 2026 03:59
@lorisleiva lorisleiva force-pushed the 04-23-add_fixed_points_error_codes branch from f35860d to ab0548b Compare May 4, 2026 03:59
@lorisleiva lorisleiva force-pushed the 04-23-scaffold_empty_solana_fixed-points_package branch from de697e2 to 9e6104d Compare May 5, 2026 11:17
@lorisleiva lorisleiva force-pushed the 04-23-add_fixed_points_error_codes branch 2 times, most recently from 6817c52 to e7bf82c Compare May 5, 2026 13:51
@lorisleiva lorisleiva force-pushed the 04-23-scaffold_empty_solana_fixed-points_package branch from 9e6104d to 9388f75 Compare May 5, 2026 13:51
Copy link
Copy Markdown
Member Author

lorisleiva commented May 5, 2026

Merge activity

  • May 5, 8:27 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 5, 8:30 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 5, 8:39 PM UTC: @lorisleiva merged this pull request with Graphite.

@lorisleiva lorisleiva changed the base branch from 04-23-scaffold_empty_solana_fixed-points_package to graphite-base/1559 May 5, 2026 20:28
@lorisleiva lorisleiva changed the base branch from graphite-base/1559 to main May 5, 2026 20:28
This PR is part of the stack implementing the fixed-point number types proposed in #1545. It lands every error code, context shape, and message that the new package will throw, so later PRs in the stack can just reference them.

Reserves the range `[8090000-8090999]` for the `FIXED_POINTS` domain and allocates 12 codes covering invalid shape parameters (total bits, fractional bits, decimals, and the binary-only "fractional bits exceed total bits" check), out-of-range raw values, malformed raw values, malformed strings, zero-denominator ratios, division by zero, arithmetic overflow (shared by add/subtract/multiply/divide/negate/absolute/rescale/signedness conversion), strict shape mismatches in operations and codecs, and strict-mode precision loss when factories and operations cannot produce an exact result without rounding.

Here is an example message for each new code:

- `SOLANA_ERROR__FIXED_POINTS__INVALID_TOTAL_BITS`:
  ```
  Invalid `totalBits`. Expected a positive integer, got foo.
  ```
- `SOLANA_ERROR__FIXED_POINTS__INVALID_FRACTIONAL_BITS`:
  ```
  Invalid `fractionalBits`. Expected a non-negative integer, got -1.
  ```
- `SOLANA_ERROR__FIXED_POINTS__INVALID_DECIMALS`:
  ```
  Invalid `decimals`. Expected a non-negative integer, got 1.5.
  ```
- `SOLANA_ERROR__FIXED_POINTS__FRACTIONAL_BITS_EXCEED_TOTAL_BITS`:
  ```
  `fractionalBits` (64) must not exceed `totalBits` (16).
  ```
- `SOLANA_ERROR__FIXED_POINTS__VALUE_OUT_OF_RANGE`:
  ```
  Fixed-point value of kind `decimalFixedPoint` is out of range for unsigned 8-bit storage. Expected a raw bigint in [0, 255], got 999.
  ```
- `SOLANA_ERROR__FIXED_POINTS__INVALID_STRING`:
  ```
  Invalid string `abc` for fixed-point value of kind `binaryFixedPoint`.
  ```
- `SOLANA_ERROR__FIXED_POINTS__INVALID_ZERO_DENOMINATOR_RATIO`:
  ```
  Invalid ratio 3/0 for fixed-point value of kind `decimalFixedPoint`. Denominator must be non-zero.
  ```
- `SOLANA_ERROR__FIXED_POINTS__ARITHMETIC_OVERFLOW`:
  ```
  Fixed-point operation `add` of kind `binaryFixedPoint` overflowed. Expected a raw bigint in [-128, 127], got 256.
  ```
- `SOLANA_ERROR__FIXED_POINTS__SHAPE_MISMATCH`:
  ```
  Fixed-point `add` operation expected binaryFixedPoint (signed, 16 bits, 8 fractional bits); got decimalFixedPoint (unsigned, 64 bits, 6 decimals).
  ```
- `SOLANA_ERROR__FIXED_POINTS__DIVISION_BY_ZERO`:
  ```
  Fixed-point division by zero for value of kind `decimalFixedPoint` (unsigned, 64 bits).
  ```
- `SOLANA_ERROR__FIXED_POINTS__STRICT_MODE_PRECISION_LOSS`:
  ```
  Fixed-point operation `fromRatio` of kind `decimalFixedPoint` cannot be performed exactly; pass a rounding mode other than `strict` to allow a rounded result.
  ```
- `SOLANA_ERROR__FIXED_POINTS__MALFORMED_RAW_VALUE`:
  ```
  Fixed-point value of kind `binaryFixedPoint` has a malformed `raw` field. Expected a bigint, got `42`.
  ```
@lorisleiva lorisleiva force-pushed the 04-23-add_fixed_points_error_codes branch from e7bf82c to 74ef76c Compare May 5, 2026 20:29
@lorisleiva lorisleiva merged commit a5ef97b into main May 5, 2026
14 checks passed
@lorisleiva lorisleiva deleted the 04-23-add_fixed_points_error_codes branch May 5, 2026 20:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔎💬 Inkeep AI search and chat service is syncing content for source 'Solana Kit Docs'

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.

2 participants