Skip to content
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

feat: surfacing error message returned from relayer #861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/passport/sdk/src/zkEvm/sendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ describe('sendTransaction', () => {
);
});

it('returns an error if the relayer does not return a successful status', async () => {
it('returns and surfaces an error if the relayer does not return a successful status', async () => {
(retryWithDelay as jest.Mock).mockResolvedValue({
status: RelayerTransactionStatus.FAILED,
statusMessage: 'Unable to complete transaction',
} as RelayerTransaction);

await expect(
Expand All @@ -150,7 +151,7 @@ describe('sendTransaction', () => {
).rejects.toThrow(
new JsonRpcError(
RpcErrorCode.INTERNAL_ERROR,
'Transaction failed to submit with status FAILED',
'Transaction failed to submit with status FAILED. Error message: Unable to complete transaction',
),
);
});
Expand Down
6 changes: 5 additions & 1 deletion packages/passport/sdk/src/zkEvm/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ export const sendTransaction = ({
RelayerTransactionStatus.SUBMITTED,
RelayerTransactionStatus.SUCCESSFUL,
].includes(relayerTransaction.status)) {
let errorMessage = `Transaction failed to submit with status ${relayerTransaction.status}.`;
if (relayerTransaction.statusMessage) {
errorMessage += ` Error message: ${relayerTransaction.statusMessage}`;
}
throw new JsonRpcError(
RpcErrorCode.RPC_SERVER_ERROR,
`Transaction failed to submit with status ${relayerTransaction.status}`,
errorMessage,
);
}

Expand Down
1 change: 1 addition & 0 deletions packages/passport/sdk/src/zkEvm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface RelayerTransaction {
chainId: string;
relayerId: string;
hash: string;
statusMessage?: string;
}

export interface FeeOption {
Expand Down