Fix relayer package exports for backward compatibility#898
Fix relayer package exports for backward compatibility#898shunkakinoki wants to merge 2 commits intomasterfrom
Conversation
Add direct exports alongside namespace exports to maintain backward compatibility after the relayer package refactoring in PR #891. This fixes breaking changes in downstream packages that depend on direct imports from @0xsequence/relayer, including: - wallet-core - wallet-wdk - dapp-client - External packages like 0xtrails The namespace exports are preserved while adding commonly used types and enums as direct exports for easier consumption. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR restores backward compatibility for the @0xsequence/relayer package by adding direct exports alongside the namespace exports introduced in PR #891. The changes prevent breaking downstream packages that rely on direct imports of types and enums.
Key Changes:
- Added direct exports for commonly used enums (
ETHTxnStatus,FeeTokenType) - Added direct type exports for relayer interfaces and status types
- Preserved existing namespace exports to support both import styles
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Direct exports for backward compatibility | ||
| export type { | ||
| Relayer as RelayerInterface, | ||
| FeeOption, | ||
| FeeQuote, | ||
| OperationStatus, | ||
| OperationUnknownStatus, | ||
| OperationQueuedStatus, | ||
| OperationPendingStatus, | ||
| OperationPendingPreconditionStatus, | ||
| OperationConfirmedStatus, | ||
| OperationFailedStatus, | ||
| } from './relayer.js' |
There was a problem hiding this comment.
Keep
Relayer type available under its original name
The fix adds type re‑exports but renames the main Relayer interface to RelayerInterface. Prior to #891, downstream code could import type { Relayer } from '@0xsequence/relayer' and compile. After the refactor those imports failed, and this change still requires a rename to RelayerInterface, so existing consumers remain broken. Exporting the type under the original Relayer name (even in addition to the alias) is necessary to actually restore backward compatibility.
Useful? React with 👍 / 👎.
| // Namespace exports | ||
| export * as RpcRelayer from './rpc-relayer/index.js' | ||
| export * as Relayer from './relayer.js' | ||
| export * as StandardRelayer from './standard/index.js' | ||
| export * as RelayerGen from './rpc-relayer/relayer.gen.js' |
There was a problem hiding this comment.
Missing direct export for
RpcRelayer constructor
Before #891 the module re‑exported everything from rpc-relayer/index, so code could instantiate the client with new RpcRelayer(...). After the refactor export * as RpcRelayer from './rpc-relayer/index.js' exports a namespace object instead of the constructor, and callers must now use new RpcRelayer.RpcRelayer(...). This change adds direct type exports but still omits a value re‑export for the constructor, so existing runtime imports continue to break. Consider adding export { RpcRelayer } from './rpc-relayer/index.js' (and similar for other top‑level classes) alongside the namespace export.
Useful? React with 👍 / 👎.
Update the instantiation of the relayer in both DappClient and ChainSessionManager to use the simplified export from the relayer package. This change enhances code clarity and maintains backward compatibility with existing functionality. No breaking changes introduced.
Summary
Fixes breaking changes from PR #891 by adding backward-compatible exports to the relayer package and updating internal packages to use the new export structure.
Problem
PR #891 refactored the relayer package to use namespace exports only, which broke both internal and external downstream packages:
Internal packages affected:
@0xsequence/wallet-core- neededRelayernamespace for types@0xsequence/dapp-client- usedRpcRelayer.RpcRelayerclassExternal packages affected:
0xtrailspackage failed to build with import errors@0xsequence/account@2.3.30) expectingproto,isRelayer,RpcRelayerexportsError examples:
Solution
1. Enhanced relayer package exports (
packages/services/relayer/src/index.ts)Added comprehensive backward-compatible exports while preserving namespace structure:
Direct exports for backward compatibility:
isRelayerfunctionRpcRelayerclassETHTxnStatus,FeeTokenTypeenumsRelayerInterface,FeeOption,FeeQuote,OperationStatus, etc.Namespace exports:
proto- for old compiled packages usingproto.FeeTokenTypeRelayer- for wallet-core type usage (Relayer.OperationStatus)Preconditions,StandardRelayer,RelayerGen- for organizationThis allows multiple import styles:
2. Updated dapp-client to use direct imports
Files modified:
packages/wallet/dapp-client/src/ChainSessionManager.tspackages/wallet/dapp-client/src/DappClient.tsChanged from
RpcRelayer.RpcRelayerto directRpcRelayerclass usage.Test Plan
Breaking Change Mitigation
This PR ensures no breaking changes for:
Fixes issues caused by #891
🤖 Generated with Claude Code