Repository navigation
Conversation
…gation markers to reserve flow
- Fetch wallet-filtered Microbridge history in sequential chunks of at most 500 blocks. - Cache successful history progress and retain partial results when requests fail. - Support read-only SDK providers without getSigner. - Add a reusable Reserve limit modal with chain-specific DEX links and optional alternative-chain messaging. - Add history and provider regression tests.
There was a problem hiding this comment.
🟡 Changes recommended
Provider compatibility, CommonJS loading, history correctness, and TypeScript issues remain unresolved.
7 open findings
Strict test compilation reports latest as used before assignment · New CommonJS build imports incompatible usedapp ESM internals · New Transaction status state omits declared chain and transaction fields · New Provider type excludes supported FallbackProvider configuration · New Sync cursor fails to remove orphaned logs after chain reorganizations · New FallbackProvider incorrectly accessed through unsupported send method · New JSON-RPC batch arrays are not traversed for known errors · New
What changed in this PR
Improves Reserve swap reliability, Microbridge history synchronization, read-only provider support, and reusable error UI.
Changes:
- Adds Reserve error detection, signer-based transactions, and alternative-chain checks.
- Reworks Microbridge history into chunked, account-scoped cached reads.
- Extends provider compatibility, tests, type-checking, and modal customization.
| File | Description |
|---|---|
.eslintrc.cjs |
Adds SDK test lint configuration. |
packages/sdk-v2/tsconfig.tests.json |
Adds test-specific TypeScript configuration. |
packages/sdk-v2/lint-staged.config.js |
Type-checks production and test sources. |
packages/sdk-v2/src/sdk/base/sdk.ts |
Guards signer access for read-only providers. |
packages/sdk-v2/src/sdk/base/sdk.test.ts |
Tests provider and signer compatibility. |
packages/sdk-v2/src/sdk/base/react.readProviders.test.tsx |
Tests fallback-provider hook integration. |
packages/sdk-v2/src/sdk/reserve/react.tsx |
Adds direct wallet submission and alternative checks. |
packages/sdk-v2/src/sdk/reserve/errors.ts |
Classifies nested Reserve-limit errors. |
packages/sdk-v2/src/sdk/reserve/alternative.ts |
Validates alternative-chain quotes and limits. |
packages/sdk-v2/src/sdk/reserve/index.ts |
Exports new Reserve APIs. |
packages/sdk-v2/src/sdk/microbridge/history.helpers.ts |
Implements chunked, cached history synchronization. |
packages/sdk-v2/src/sdk/microbridge/history.helpers.test.ts |
Tests chunking, retries, caching, and decoding. |
packages/sdk-v2/src/sdk/microbridge/useMicroBridgeHistory.ts |
Adds the history synchronization hook. |
packages/sdk-v2/src/sdk/microbridge/useMicroBridgeHistory.test.tsx |
Tests hook refresh and account isolation. |
packages/sdk-v2/src/sdk/microbridge/react.ts |
Uses the new history hook. |
packages/sdk-v2/src/sdk/microbridge/index.ts |
Exports history APIs. |
packages/good-design/src/core/web3/modals/ReserveLimitModal.tsx |
Adds Reserve-limit guidance UI. |
packages/good-design/src/core/web3/modals/ErrorModal.tsx |
Supports custom titles and footers. |
packages/good-design/src/core/web3/modals/index.ts |
Exports the Reserve modal. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| jest.mock("../../hooks/useRefreshOrNever", () => ({ __esModule: true, default: () => 5 })); | ||
| jest.mock("../storage", () => ({ AsyncStorage: { getItem: jest.fn(), setItem: jest.fn() } })); | ||
|
|
||
| let latest: ReturnType<typeof useMicroBridgeHistory>; |
| @@ -0,0 +1,86 @@ | |||
| import { useBlockNumbers, useEthers } from "@usedapp/core"; | |||
| import { useReadonlyNetworks } from "@usedapp/core/dist/esm/src/providers/network/readonlyNetworks"; | |||
Comment on lines
+13
to
+17
| export interface ReserveTransactionStatus extends TransactionStatus { | ||
| errorType?: typeof RESERVE_LIMIT_ERROR; | ||
| /** The unmodified provider/ethers error, for debugging rather than display. */ | ||
| originalError?: unknown; | ||
| } |
Comment on lines
+104
to
+105
| // Read-only BaseProviders (including FallbackProvider) do not expose a signer. | ||
| if (typeof provider.getSigner === "function") { |
| cancelled: () => boolean = () => false | ||
| ) => { | ||
| const windowStart = Math.max(0, latestBlock - HISTORY_LOOKBACK_BLOCKS); | ||
| const fromBlock = Math.max(windowStart, (cache.lastSyncedBlock ?? -1) + 1); |
| ): Promise<ReserveAlternative | undefined> => { | ||
| if (!deployment?.MentoBroker || !deployment.MentoExchangeProvider || !deployment.GoodDollar) return undefined; | ||
| if (!!request.exactInput === !!request.exactOutput) return undefined; | ||
| const actualChainId = BigNumber.from(await provider.send("eth_chainId", [])).toNumber(); |
Comment on lines
+78
to
+80
| } else if (value && typeof value === "object" && !seen.has(value)) { | ||
| seen.add(value); | ||
| const record = value as Record<string, unknown>; |
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.


Description
Improves Reserve swap transaction handling and error messaging, and reduces oversized Microbridge history requests.
Reserve fixes
Microbridge and provider fixes
UI
Testing and integration
Summary by Sourcery
Improve Reserve swap reliability and Microbridge history retrieval while exposing reusable limit handling and alternative-chain integration APIs.
New Features:
Bug Fixes:
Enhancements:
Build:
Tests: