Skip to content

Commit

Permalink
Add status to relay-specific errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Mar 11, 2024
1 parent 0d021af commit 372bf03
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/domain/relay/errors/invalid-multisend.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export class InvalidMultiSendError extends Error {
import { HttpException, HttpStatus } from '@nestjs/common';

export class InvalidMultiSendError extends HttpException {
constructor() {
super(
'Invalid multiSend call. The batch is not all execTransaction calls to same address.',
HttpStatus.UNPROCESSABLE_ENTITY,
);
}
}
5 changes: 4 additions & 1 deletion src/domain/relay/errors/invalid-transfer.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export class InvalidTransferError extends Error {
import { HttpException, HttpStatus } from '@nestjs/common';

export class InvalidTransferError extends HttpException {
constructor() {
super(
'Invalid transfer. The proposed transfer is not an execTransaction/multiSend to another party or createProxyWithNonce call.',
HttpStatus.UNPROCESSABLE_ENTITY,
);
}
}
4 changes: 3 additions & 1 deletion src/domain/relay/errors/relay-limit-reached.error.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { HttpException, HttpStatus } from '@nestjs/common';
import { Hex } from 'viem';

export class RelayLimitReachedError extends Error {
export class RelayLimitReachedError extends HttpException {
constructor(
readonly address: Hex,
readonly current: number,
readonly limit: number,
) {
super(
`Relay limit reached for ${address} | current: ${current} | limit: ${limit}`,
HttpStatus.TOO_MANY_REQUESTS,
);
}
}
5 changes: 4 additions & 1 deletion src/domain/relay/errors/unofficial-master-copy.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export class UnofficialMasterCopyError extends Error {
import { HttpException, HttpStatus } from '@nestjs/common';

export class UnofficialMasterCopyError extends HttpException {
constructor() {
super(
'Safe attempting to relay is not official. Only official Safe singletons are supported.',
HttpStatus.UNPROCESSABLE_ENTITY,
);
}
}
5 changes: 4 additions & 1 deletion src/domain/relay/errors/unofficial-multisend.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export class UnofficialMultiSendError extends Error {
import { HttpException, HttpStatus } from '@nestjs/common';

export class UnofficialMultiSendError extends HttpException {
constructor() {
super(
'MultiSend contract is not official. Only official MultiSend contracts are supported.',
HttpStatus.UNPROCESSABLE_ENTITY,
);
}
}
5 changes: 4 additions & 1 deletion src/domain/relay/errors/unofficial-proxy-factory.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export class UnofficialProxyFactoryError extends Error {
import { HttpException, HttpStatus } from '@nestjs/common';

export class UnofficialProxyFactoryError extends HttpException {
constructor() {
super(
'ProxyFactory contract is not official. Only official ProxyFactory contracts are supported.',
HttpStatus.UNPROCESSABLE_ENTITY,
);
}
}

0 comments on commit 372bf03

Please sign in to comment.