Conversation
|
Size Change: +6.13 kB (+0.17%) Total Size: 3.53 MB
|
| throw error; | ||
| } | ||
|
|
||
| // Exceeds uint64 max (2^64 - 1) |
There was a problem hiding this comment.
I confirmed the xdr says uin64
test/unit/memo_test.js
Outdated
| // negative | ||
| expect(() => StellarBase.Memo.id('-1')).to.throw(/Expects a int64/); | ||
| // decimal | ||
| expect(() => StellarBase.Memo.id('1.5')).to.throw(/Expects a int64/); |
There was a problem hiding this comment.
We should correct the error message error to uint64
…nto some-fixes-2
There was a problem hiding this comment.
Pull request overview
This PR tightens correctness and edge-case handling across classic transactions and Soroban utilities in stellar-base, with accompanying regression tests to prevent previously observed rounding/encoding/validation failures.
Changes:
- Fix fee/timebounds rounding behaviors in
TransactionBuilder(Math.floorfor sub-secondDates and non-even fee splits incloneFrom()), and normalizecloneFrom()extraSignersto StrKey strings. - Harden parsing/encoding and validation: signed-payload
SignerKeypayload extraction,Memo.id()uint64 validation,Soroban.parseTokenAmount()decimal-place limits, andKeypair.verify()returningfalseon invalid signatures. - Add regression tests for immutability, nonce generation, signed payload padding, uint sizing, and price fraction handling.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/transaction_test.js | Adds regression test asserting Transaction.networkPassphrase is immutable. |
| test/unit/transaction_builder_test.js | Adds tests for floored Date timebounds and cloneFrom() fee/extraSigners behavior. |
| test/unit/soroban_test.js | Adds test for “too many decimal places” parsing error. |
| test/unit/signerkey_test.js | Adds roundtrip tests for signed-payload signer keys with padding edge cases. |
| test/unit/scint_test.js | Extends coverage for string inputs at uint sizing boundaries (e.g. 2^64). |
| test/unit/operations/classic_ops_test.js | Adds test for price fraction objects with zero numerator. |
| test/unit/memo_test.js | Expands Memo.id() tests for uint64 max, negatives/decimals, and overflow. |
| test/unit/keypair_test.js | Adds tests validating verify() returns false for invalid signatures/lengths. |
| test/unit/auth_test.js | Adds regression tests ensuring nonce generation consumes all 8 bytes. |
| src/transaction_builder.js | Floors unscaled fee in cloneFrom(), encodes extraSigners to StrKey, floors sub-second Date timebounds. |
| src/transaction_base.js | Makes networkPassphrase setter consistent with other immutable setters (throws). |
| src/transaction.js | Updates extraSigners JSDoc to reflect XDR objects. |
| src/soroban.js | Adds explicit decimal-place limit enforcement in parseTokenAmount(). |
| src/signerkey.js | Fixes signed-payload decoding to slice payload by declared length (ignoring XDR padding). |
| src/operation.js | Accepts price fraction objects even when numerator is 0. |
| src/numbers/sc_int.js | Normalizes inputs through BigInt() to improve sizing decisions for string values. |
| src/memo.js | Strengthens Memo.id() validation to enforce uint64, integer-only, and no overflow. |
| src/keypair.js | Wraps verify() in try/catch to return false instead of throwing on invalid signatures. |
| src/auth.js | Fixes nonce derivation to use all 8 bytes and return a signed Int64 BigInt. |
| .gitignore | Ignores common local IDE/tooling dirs and TS build info output. |
Comments suppressed due to low confidence (1)
src/operation.js:540
- The new
price.n !== undefined && price.d !== undefinedcheck allows{ n: 1, d: 0 }(ornullvalues) to be treated as an explicit fraction, producing an XDRPricewith a zero/invalid denominator. Since the subsequent validation only rejects negatives, this would now slip through. Please add validation thatn/dare integers and thatd > 0(while still allowingn = 0).
static _toXDRPrice(price) {
let xdrObject;
if (price.n !== undefined && price.d !== undefined) {
xdrObject = new xdr.Price(price);
} else {
const approx = best_r(price);
xdrObject = new xdr.Price({
n: parseInt(approx[0], 10),
d: parseInt(approx[1], 10)
});
}
if (xdrObject.n() < 0 || xdrObject.d() < 0) {
throw new Error('price must be positive');
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
TransactionBuilderbuild()timebounds — / 1000 →Math.floor(/ 1000)cloneFrom()unscaledFee— integer division →Math.floorextraSigners— XDR objects →StrKeystringsTransaction:extraSignersgetter —JSDoc @type {string[]}→{xdr.SignerKey[]}Keypair:verify()— bare call → try-catch returningfalseMemo:_validateIdValue()— add negative, decimal,uint64overflow guards