Repository navigation
feat: implement multi-wallet support, transaction simulation, automatic nonce management, and split ratio preflight fix - #1144
Open
willi-d7 wants to merge 1 commit into
Conversation
…anagement, and split ratio preflight fix - Implement MultiWalletManager with MetaMask, WalletConnect, and Ledger connectors and safe fallback handling (Stellar-split#1027) - Add TransactionSimulator for pre-execution transaction simulation, resource estimation, and error detection (Stellar-split#1028) - Implement NonceManager for automatic transaction nonce tracking, auto-increment, resets, and replay validation (Stellar-split#1029) - Reject invalid and non-finite recipient ratio legs in validateSplitRatioSum (Stellar-split#1012)
|
@willi-d7 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 branch has not been deployed
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.
What this fixes
validateSplitRatioSum()previously accepted individual out-of-range ratios (such as[-1, 2]) if their arithmetic sum was 1, and allowedNaNor opposite infinities to pass through, allowingsplitExecutor()to proceed to capacity operations with corrupt shares.What changed
Automatic Nonce Management (
src/nonceManager.ts):NonceManagerwith per-account state tracking (currentNonce,lastUpdated,inFlightNonces).acquireNextNonce()/consumeNonce()with peeking (peekNextNonce()) and rollback support (rollbackNonce()).resetNonce()(custom reset values, reason metadata, clearing replay cache) and on-chain sync viasyncNonce().validateBeforeSend(),validate()) detecting replay attack duplicates (DuplicateNonceError), stale nonces (StaleNonceError), nonce gaps (NonceGapError), and invalid values (InvalidNonceError).acquired,committed,rolled_back,reset,validation_failed).Transaction Simulation (
src/transactionSimulator.ts):TransactionSimulatorwith structured requests (SimulationRequest) and reports (SimulationReport).AUTH_FAILED,INSUFFICIENT_FUNDS,RESOURCE_EXHAUSTED,SEQUENCE_ERROR,STORAGE_ERROR,DEADLINE_EXPIRED, andCONTRACT_ERRORwith actionable remediation suggestions.cpuInstructions,memoryBytes,minResourceFee) with automatic warnings when thresholds are exceeded.Multi-Wallet Support (
src/multiWallet.ts,src/wallets/adapters/MetaMaskAdapter.ts):WalletAdapterinterface.MetaMaskAdapterandMetaMaskConnectorsupportingwindow.ethereum, account change events,eth_requestAccounts,personal_sign, and typed errors (MetaMaskNotInstalledError,UserRejectedError,MetaMaskConnectionError).WalletSessionManager.detect().WalletConnectConnectorwrappingWalletConnectAdapterwith session management and signing.LedgerConnectorwrappingLedgerAdapterwith hardware WebHID checks and pre-signing firmware verification.MultiWalletManagerwith safe fallback handling (connectWithFallback()) that attempts providers in order, records detailedWalletAttemptLogdiagnostics, and throwsWalletFallbackExhaustedErrorif all fallbacks fail.Split Ratio Validation Fix (
src/payments/splitExecutor.ts):validateSplitRatioSum()to assert that each leg ratio is finite and in[0, 1]before verifying the total aggregate withinSPLIT_RATIO_TOLERANCE.SplitRatioSumErroron invalid legs or non-finite sums (NaN, opposite infinities) prior to any subentry capacity checks or network activity.Root SDK Exports (
src/index.ts):MultiWalletManager, connectors, adapters, and errors for Implement multi-wallet support #1027.TransactionSimulator, simulation structs, and errors for Add transaction simulation before execution #1028.NonceManager, nonce structs, and errors for Implement automatic nonce management #1029.Testing
All relevant unit tests pass with zero failures:
test/splitExecutor.invalid-ratios.test.ts(10/10 passed)test/nonceManager.test.ts(25/25 passed)test/transactionSimulator.test.ts(19/19 passed)test/multiWallet.test.ts(18/18 passed)test/walletSessionManager.test.ts(26/26 passed)test/walletconnect.test.ts(14/14 passed)test/ledgerAdapter.test.ts(6/6 passed)npm test(110/110 passed)Total: 228 passing tests across all related test suites.
Issues
closes #1029
closes #1028
closes #1027
closes #1012