Skip to content

Conversation

shunkakinoki
Copy link
Contributor

@shunkakinoki shunkakinoki commented Oct 18, 2025

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 - needed Relayer namespace for types
  • @0xsequence/dapp-client - used RpcRelayer.RpcRelayer class
  • Compiled external packages expecting direct exports

External packages affected:

  • 0xtrails package failed to build with import errors
  • Old compiled packages (e.g., @0xsequence/[email protected]) expecting proto, isRelayer, RpcRelayer exports

Error examples:

error TS2724: '@0xsequence/relayer' has no exported member 'Relayer'
error: "ETHTxnStatus" is not exported by "relayer/dist/index.js"
error: "proto" is not exported by "relayer/dist/index.js"

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:

  • isRelayer function
  • RpcRelayer class
  • ETHTxnStatus, FeeTokenType enums
  • Type exports: RelayerInterface, FeeOption, FeeQuote, OperationStatus, etc.

Namespace exports:

  • proto - for old compiled packages using proto.FeeTokenType
  • Relayer - for wallet-core type usage (Relayer.OperationStatus)
  • Preconditions, StandardRelayer, RelayerGen - for organization

This allows multiple import styles:

// Direct imports (backward compatible)
import { RpcRelayer, isRelayer, ETHTxnStatus } from '@0xsequence/relayer'
const relayer = new RpcRelayer(url, chainId, rpcUrl)

// Namespace imports (new structure)
import { Relayer, proto } from '@0xsequence/relayer'
type Status = Relayer.OperationStatus
const feeType = proto.FeeTokenType.ERC20_TOKEN

// Mixed approach
import { RpcRelayer, type RelayerInterface } from '@0xsequence/relayer'

2. Updated dapp-client to use direct imports

Files modified:

  • packages/wallet/dapp-client/src/ChainSessionManager.ts
  • packages/wallet/dapp-client/src/DappClient.ts

Changed from RpcRelayer.RpcRelayer to direct RpcRelayer class usage.

Test Plan

  • All internal packages build successfully
  • Relayer package exports correctly
  • Wallet-core builds without errors
  • Dapp-client builds without errors
  • External package (0xtrails) builds successfully with symlinked local relayer
  • Both namespace and direct import styles work

Breaking Change Mitigation

This PR ensures no breaking changes for:

  1. ✅ Internal packages using namespace imports
  2. ✅ Old compiled packages expecting direct exports
  3. ✅ External packages using either import style
  4. ✅ Packages compiled against older relayer versions

Fixes issues caused by #891

🤖 Generated with Claude Code

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 <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings October 18, 2025 08:42
@shunkakinoki shunkakinoki requested review from a team as code owners October 18, 2025 08:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 8 to 20
// Direct exports for backward compatibility
export type {
Relayer as RelayerInterface,
FeeOption,
FeeQuote,
OperationStatus,
OperationUnknownStatus,
OperationQueuedStatus,
OperationPendingStatus,
OperationPendingPreconditionStatus,
OperationConfirmedStatus,
OperationFailedStatus,
} from './relayer.js'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines 1 to 5
// 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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants