Skip to content

Conversation

shunkakinoki
Copy link
Contributor

Summary

Improves the @0xsequence/relayer package exports to provide a cleaner, more intuitive API without requiring downstream packages to create type aliases.

Changes

  • Added Relayer namespace with cleaner type names:
    • Relayer.Status instead of RelayerOperationStatus
    • Relayer.FailedStatus instead of RelayerOperationFailedStatus
    • Relayer.PendingStatus instead of RelayerOperationPendingStatus
    • Relayer.ConfirmedStatus instead of RelayerOperationConfirmedStatus
    • Relayer.UnknownStatus instead of RelayerOperationUnknownStatus
    • Relayer.QueuedStatus instead of RelayerOperationQueuedStatus
    • Relayer.PendingPreconditionStatus instead of RelayerOperationPendingPreconditionStatus
  • Re-exported RpcRelayer as Relayer.RpcRelayer for better organization (instead of RpcRelayer.RpcRelayer)
  • Maintained backward compatibility - all existing exports still work

DevX Improvements

Before:

import type { RpcRelayer } from "@0xsequence/relayer"

const relayer: RpcRelayer.RpcRelayer = new RpcRelayer.RpcRelayer(...)

After:

import { Relayer } from "@0xsequence/relayer"

const relayer: Relayer.RpcRelayer = new Relayer.RpcRelayer(...)
const status: Relayer.Status = await relayer.status(...)

Benefits

  • Nicer API: Relayer.Status is much cleaner than RelayerOperationStatus
  • Better organization: Relayer.RpcRelayer instead of the awkward RpcRelayer.RpcRelayer
  • No workarounds needed: Downstream packages like trails can directly use these exports without creating type aliases
  • Backward compatible: Old code continues to work

Context

Addresses DevX concerns from https://sequence-xyz.slack.com/archives/C082M02T2UH/p1760904476464359

🤖 Generated with Claude Code

- Add Relayer namespace with cleaner type names (Status vs OperationStatus)
- Re-export RpcRelayer as Relayer.RpcRelayer for better organization
- Maintain backward compatibility with existing exports
- DevX improvement: Relayer.Status vs RelayerOperationStatus

🤖 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 20, 2025 07:26
@shunkakinoki shunkakinoki requested review from a team as code owners October 20, 2025 07:26
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 improves the @0xsequence/relayer package API by introducing a cleaner Relayer namespace that provides more intuitive type names while maintaining backward compatibility.

  • Adds a Relayer namespace with cleaner type names (Relayer.Status vs RelayerOperationStatus)
  • Reorganizes exports to provide both direct exports and namespaced exports for better API ergonomics
  • Re-exports RpcRelayer class within the Relayer namespace for consistent organization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/services/relayer/src/relayer.ts Adds Relayer namespace with cleaner type aliases and re-exported RpcRelayer class
packages/services/relayer/src/index.ts Restructures exports to provide both direct and namespaced exports while maintaining backward compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +101 to +107
export type Status = OperationStatus
export type FailedStatus = OperationFailedStatus
export type PendingStatus = OperationPendingStatus
export type ConfirmedStatus = OperationConfirmedStatus
export type UnknownStatus = OperationUnknownStatus
export type QueuedStatus = OperationQueuedStatus
export type PendingPreconditionStatus = OperationPendingPreconditionStatus
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The type aliases reference types that are not imported or defined in this file. These references should be qualified with their module imports or the types should be imported explicitly to ensure the namespace exports work correctly.

Copilot uses AI. Check for mistakes.

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 +1 to +4
// Direct exports for convenience
export { RpcRelayer } from './rpc-relayer/index.js'
export { isRelayer } from './relayer.js'
export { ETHTxnStatus, FeeTokenType } 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 Removing RpcRelayer namespace breaks existing imports

The top-level export now re-exports RpcRelayer as the class itself instead of the previous namespace object (export * as RpcRelayer). Any consumer that does import { RpcRelayer } from "@0xsequence/relayer" and then references RpcRelayer.RpcRelayer, RpcRelayer.getChain, or RpcRelayer.Fetch will now receive undefined because those properties no longer exist on the exported value. The commit message claims backward compatibility, but downstream packages compiled against the namespace form will fail at compile time (property does not exist) or at runtime. Consider preserving the namespace export (or adding aliases) so old imports still resolve.

Useful? React with 👍 / 👎.

Comment on lines +91 to +107
// Import RpcRelayer for re-export in namespace
import { RpcRelayer as RpcRelayerClass } from './rpc-relayer/index.js'

// Namespace export with cleaner API
export namespace Relayer {
// Re-export RpcRelayer class
export const RpcRelayer = RpcRelayerClass
export type RpcRelayer = InstanceType<typeof RpcRelayerClass>

// Re-export types with cleaner names
export type Status = OperationStatus
export type FailedStatus = OperationFailedStatus
export type PendingStatus = OperationPendingStatus
export type ConfirmedStatus = OperationConfirmedStatus
export type UnknownStatus = OperationUnknownStatus
export type QueuedStatus = OperationQueuedStatus
export type PendingPreconditionStatus = OperationPendingPreconditionStatus

Choose a reason for hiding this comment

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

P1 Badge Relayer namespace drops previous members

The new Relayer namespace only exposes aliases like Relayer.Status and Relayer.RpcRelayer. Previously, export * as Relayer made every export from relayer.ts (e.g. isRelayer, OperationStatus, FeeOption) available under Relayer.*. Code that still calls Relayer.isRelayer or references Relayer.OperationStatus will now break because those members are no longer attached to the namespace; they are only exported at the top level. If backward compatibility is required as stated, the namespace needs to keep the legacy properties or provide aliases to them.

Useful? React with 👍 / 👎.

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.

1 participant