-
Notifications
You must be signed in to change notification settings - Fork 63
Improve relayer exports with cleaner API (Relayer.Status vs RelayerOperationStatus) #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
export * as RpcRelayer from './rpc-relayer/index.js' | ||
export * as Relayer from './relayer.js' | ||
// 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' | ||
|
||
// Type exports | ||
export type { | ||
Relayer as RelayerInterface, | ||
FeeOption, | ||
FeeQuote, | ||
OperationStatus, | ||
OperationUnknownStatus, | ||
OperationQueuedStatus, | ||
OperationPendingStatus, | ||
OperationPendingPreconditionStatus, | ||
OperationConfirmedStatus, | ||
OperationFailedStatus, | ||
} from './relayer.js' | ||
|
||
export type { | ||
Relayer as Service, | ||
FeeToken, | ||
IntentPrecondition, | ||
MetaTxn, | ||
SendMetaTxnReturn, | ||
GetMetaTxnReceiptReturn, | ||
} from './rpc-relayer/relayer.gen.js' | ||
|
||
// Namespace exports for better organization | ||
export * as proto from './rpc-relayer/relayer.gen.js' | ||
export * as StandardRelayer from './standard/index.js' | ||
export * as RelayerGen from './rpc-relayer/relayer.gen.js' | ||
export * as Preconditions from './preconditions/index.js' | ||
|
||
// Re-export Relayer namespace with cleaner API from relayer.js | ||
export { Relayer } from './relayer.js' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,22 @@ export function isRelayer(relayer: any): relayer is Relayer { | |
'checkPrecondition' in relayer | ||
) | ||
} | ||
|
||
// 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 | ||
Comment on lines
+101
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Positive FeedbackNegative Feedback
Comment on lines
+91
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The top-level export now re-exports
RpcRelayer
as the class itself instead of the previous namespace object (export * as RpcRelayer
). Any consumer that doesimport { RpcRelayer } from "@0xsequence/relayer"
and then referencesRpcRelayer.RpcRelayer
,RpcRelayer.getChain
, orRpcRelayer.Fetch
will now receiveundefined
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 👍 / 👎.