You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: correct XdrLargeInt range errors, fix a dead test (#1659)
* fix: name the actual constraint in XdrLargeInt range errors
* fix(test): make the muxed key assertion compare bytes again
* refactor: reuse intRange for XdrLargeInt bounds
* Updated docs
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@ A breaking change will get clearly marked in this log.
19
19
+xdr.TransactionMeta.v3(transactionMetaV3);
20
20
```
21
21
22
+
*`XdrLargeInt` encoding errors name the actual constraint. `toI64()`/`toI128()`/`toI256()` reported `value too large for i64: <v>` with no indication of the valid range, and now report `bigint value <v> for i64 out of range [<min>, <max>]`. The width check reported `value too large for 64 bits (i128)` even when the value was `1` — it rejects the declared type, not the value — and now reports `cannot encode i128 as 64 bits`. `toNumber()` printed its safe-integer range with the bounds reversed. For these range violations the error is unchanged apart from its text: the same `RangeError` on the same inputs.
23
+
24
+
*`XdrLargeInt` coerces a `toBigInt()` hook result with `BigInt(...)` instead of requiring an exact `bigint`. A custom object whose `toBigInt()` returns a bigint-convertible value — a `number` such as `5`, or `""` — is now accepted and normalized rather than throwing; a result that cannot be converted (`"abc"`, `NaN`, `null`, `{}`) still throws. This is what keeps `value` a genuine `bigint`: the range check compares with `<` and `>`, which yield `false` for a string or `NaN`, so without the coercion such a value passed every check and `toNumber()` returned `NaN` instead of throwing.
25
+
22
26
*`equals()` on XDR values is now callable from TypeScript on union types like `xdr.ScVal`, `xdr.TransactionEnvelope`, and `xdr.Memo` — which is what the SDK's accessors return ([#1630](https://github.com/stellar/js-stellar-sdk/issues/1630)). The parameter was typed as polymorphic `this`, which reduces to `never` on a union, so every call failed with TS2345 even though the runtime worked. The parameter is now `XdrValue`, so comparing two different XDR types compiles and returns `false`.
23
27
24
28
* `Keypair.verify` and `Keypair.verifyMessage` throw a `TypeError` for arguments whose type they don't accept, instead of returning `false` ([#1649](https://github.com/stellar/js-stellar-sdk/pull/1649)). Both previously swallowed every error and reported `false`, so a caller mistake was indistinguishable from an invalid signature. `verify` requires `data` to be a `Uint8Array` and `signature` to be either a `Uint8Array` or an `xdr.Signature`; `verifyMessage` takes the same `signature` and a `message` that is a string or a `Uint8Array`. Anything else now throws — a hex/base64 signature string, a plain array of byte values, the `xdr.DecoratedSignature` that `tx.signatures[0]` holds, or a `message` that is neither string nor bytes. A well-formed signature that doesn't match still returns `false`. Accepting an `xdr.Signature` — what `DecoratedSignature.signature` holds — means `kp.verify(tx.hash(), tx.signatures[0].signature)` works again. `authorizeEntry` likewise rejects a signer result it would have passed on unchecked — a callback returning none of its three shapes, a non-bytes `signature`, a non-string `publicKey`, or a `signatureScVal` that isn't an `xdr.ScVal`.
0 commit comments