Skip to content

Commit

Permalink
Fix getAddress unhandled error in TransactionsService (#1621)
Browse files Browse the repository at this point in the history
Fix viem getAddress unhandled error
  • Loading branch information
hectorgomezv authored Jun 7, 2024
1 parent eada304 commit 213c897
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/routes/transactions/transactions.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Inject, Injectable } from '@nestjs/common';
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
import { MultisigTransaction as DomainMultisigTransaction } from '@/domain/safe/entities/multisig-transaction.entity';
import { SafeRepository } from '@/domain/safe/safe.repository';
import { ISafeRepository } from '@/domain/safe/safe.repository.interface';
Expand Down Expand Up @@ -35,7 +35,7 @@ import { TransactionPreviewMapper } from '@/routes/transactions/mappers/transact
import { TransactionsHistoryMapper } from '@/routes/transactions/mappers/transactions-history.mapper';
import { TransferDetailsMapper } from '@/routes/transactions/mappers/transfers/transfer-details.mapper';
import { TransferMapper } from '@/routes/transactions/mappers/transfers/transfer.mapper';
import { getAddress } from 'viem';
import { getAddress, isAddress } from 'viem';

@Injectable()
export class TransactionsService {
Expand Down Expand Up @@ -70,6 +70,10 @@ export class TransactionsService {
}

case TRANSFER_PREFIX: {
if (!isAddress(safeAddress)) {
throw new BadRequestException('Invalid transaction ID');
}

const [transfer, safe] = await Promise.all([
this.safeRepository.getTransfer({
chainId: args.chainId,
Expand All @@ -89,6 +93,10 @@ export class TransactionsService {
}

case MULTISIG_TRANSACTION_PREFIX: {
if (!isAddress(safeAddress)) {
throw new BadRequestException('Invalid transaction ID');
}

const [tx, safe] = await Promise.all([
this.safeRepository.getMultiSigTransaction({
chainId: args.chainId,
Expand Down

0 comments on commit 213c897

Please sign in to comment.