refactor: update ApiClient to use a single registry URL and improve caching - #43
Conversation
…aching - Changed DecoderConfig to accept a single registryUrl instead of an array. - Refactored ApiClient methods to utilize a new _fetchWithCache method for improved data fetching and caching. - Updated schema imports to use a unified schema object. - Adjusted methods to ensure proper handling of registry updates and resource fetching. - Enhanced error handling and logging for better debugging.
WalkthroughThe changes refactor the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ApiClient
participant Cache
participant Axios
participant SchemaParser
Client->>ApiClient: call data-fetching method
ApiClient->>Cache: check for cached data
alt Cache hit and valid
Cache-->>ApiClient: return cached data
ApiClient-->>Client: return parsed data
else Cache miss or invalid
ApiClient->>Axios: fetch data from URL
Axios-->>ApiClient: return raw data
ApiClient->>SchemaParser: parse data
SchemaParser-->>ApiClient: return parsed data
ApiClient->>Cache: store parsed data
ApiClient-->>Client: return parsed data
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🧰 Additional context used🧠 Learnings (8)📚 Learning: in `src/client/rest/api/ibcapi.spec.ts`, the rest endpoint `https://rest.devnet.initia.xyz/` is acce...Applied to files:
📚 Learning: the typescript types and zod schemas in `@initia/initia-registry-types` package are auto-generated f...Applied to files:
📚 Learning: in `frontend/helpers/address.ts`, the `bech32addresstohex` function is intentionally designed to thr...Applied to files:
📚 Learning: in `src/core/msg.ts`, within the `fromamino` function, the type identifiers for `msgupdateibcpermadm...Applied to files:
📚 Learning: the typescript types and zod schemas in `_packages/types/src/types/` and `_packages/types/src/zods/`...Applied to files:
📚 Learning: in the tx-decoder project, zod is used for data validation at the input layer, which means direct pr...Applied to files:
📚 Learning: in src/object.ts, the getmetadata function's handling of the "move/" prefix does not require validat...Applied to files:
📚 Learning: in chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not a...Applied to files:
🔇 Additional comments (11)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Summary by CodeRabbit
Refactor
Style
Tests