Repository navigation
Fix: 4 issues (#1730, #1731, #1732, #1733) - #1842
Merged
yahia008 merged 2 commits intoOct 19, 2026
Merged
Conversation
Co-authored-by: Simple Agent <agent@simple.dev>
|
@code-bandit007 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1730
Closes #1731
Closes #1732
Closes #1733
Issues
#1730 Frontend:
useWalletBalancedoes not handle token decimal places correctly#1731 Enhancement: escrow contract should support a configurable vesting duration per match
#1732 Cleanup:
contracts/escrow/src/lib.rshas duplicateuse types::*import block#1733 Test:
admin_transfertwo-step flow — propose, accept, and cancel pathsSummary
Issue #1730: the hook currently only reads the native XLM balance from Horizon; use 7 decimals for native XLM and
fetchTokenDecimalsfor contract tokens. Keep the existing polling and render-time reset behaviour. Issue #1731: adding a parameter tocreate_matchis an ABI-breaking change — update all internal callers (includingcreate_match_with_conversion/create_match_with_referrerand any tests/fixtures that callcreate_match) and regenerate the ABI snapshot rather than hand-editing it. Issue #1732 is folded into thelib.rsstep since both edits touch the same file; runcargo fmtandcargo clippyafter merging the imports. Issue #1733: reuse the existingMockAuth/MockAuthInvokepatterns inadmin.rs; no new test module is required if tests are added to the existingadminmodule.Changes
useBalance, after loading the account, resolve the token's decimals (usefetchTokenDecimalsfrom../utils/tokenFormat, cached per token contract id; for the native XLM balance use 7 decimals) and convert the raw balance withformatTokenAmount. Return both the formatted display string and the raw value (e.g.{ balance, rawBalance, decimals, loading, error }) so consumers can render a correctly-scaled amount. Keep the existing polling/reset behaviour intact. (frontend/src/hooks/useBalance.ts)tokenFormat.tsexposes everything the hook needs for issue Frontend:useWalletBalancedoes not handle token decimal places correctly #1730:formatTokenAmount(already present) andfetchTokenDecimalswith per-token caching. Add a small helper if needed to format a balance with a fixed number of decimal places (e.g.formatTokenAmountFixed(raw, decimals, displayDecimals)), and make sure the decimals cache can be cleared for tests. Do not change existing exported signatures used by tests. (frontend/src/utils/tokenFormat.ts)formatTokenAmountoutput for typical token decimals (7, 6, 18) and add tests for the new fixed-decimal helper if introduced. Cover edge cases: zero balance, whole amounts, and amounts smaller than one unit. (frontend/src/utils/tokenFormat.test.ts)useBalancetests to cover decimal handling: mockfetchTokenDecimals(or the token decimals lookup) and assert the hook returns a formatted balance (e.g. raw10000000with 7 decimals renders as1), that decimals are fetched once and cached across polls, and that the existing 10-second polling test still passes. Reset the decimals cache between tests. (frontend/src/test/useBalance.test.ts)BalanceDisplayto render the formatted balance returned byuseBalance(the decimal-adjusted value) instead of the raw string, keeping theXLMlabel and existing loading/error states. Ensure it still works when the hook returns null balance. (frontend/src/components/wallet/BalanceDisplay.tsx)BalanceDisplaytests to reflect the new hook return shape (formatted balance plus raw/decimals fields) and add a case asserting that a raw value with token decimals is displayed as the correctly scaled amount (e.g. raw10000000at 7 decimals shows1 XLM). (frontend/src/test/BalanceDisplay.test.tsx)types.rs, addpub vesting_override_seconds: Option<u64>to theMatchstruct. Inlib.rs: (a) merge the two consecutiveuse types::{...}blocks into a single import listing all fields (issue Cleanup:contracts/escrow/src/lib.rshas duplicateuse types::*import block #1732); (b) add an optionalvesting_override_seconds: Option<u64>parameter tocreate_match(and the relatedcreate_match_with_conversion/create_match_with_referrervariants for consistency), store it on the createdMatch, and validate it if a minimum/maximum is enforced; (c) when computing the vesting duration at payout/claim time, resolve it asmatch.vesting_override_seconds.unwrap_or(config.vesting_duration_seconds)instead of always reading the global config. Runcargo fmtandcargo clippyafterwards to confirm no warnings. (contracts/escrow/src/lib.rs)vesting_override_seconds: Option<u64>field to theMatchstruct intypes.rs(with a doc comment explaining it overridesProtocolConfig::vesting_duration_secondswhen set). This is the type change required by the newcreate_matchparameter. (contracts/escrow/src/types.rs)contract-spec.jsonafter thecreate_matchsignature change, following the procedure in CONTRIBUTING.md (stellar contract inspecton the rebuilt wasm). Thecreate_matchentry must reflect the new optionalvesting_override_secondsargument; do not hand-edit other entries. (contracts/escrow/contract-spec.json)vesting_override_seconds: Some(x)usesxrather than the globalvesting_duration_secondswhen computing the vesting timestamp; (2) a match created withNonefalls back to the global config value. Place these alongside the existing lifecycle/vesting tests and register any new module intests/mod.rs. (contracts/escrow/src/tests/mod.rs)PendingAdminis cleared; (2) propose → cancel → pending admin cannot accept afterwards (accept returnsError::Unauthorized); (3) a non-pending-admin cannot callaccept_admin(authorization failure). Use the existingsetup()fixture andMockAuthpatterns already used in this file. (contracts/escrow/src/tests/admin.rs)vesting_override_secondsfield onMatch, note thatcreate_matchaccepts an optional override, and explain the fallback toProtocolConfig::vesting_duration_secondswhen it isNone. Update thecreate_matchrow in the contract function table accordingly. (docs/architecture.md)