diff --git a/src/frontend/src/icp/utils/icp-transactions.utils.ts b/src/frontend/src/icp/utils/icp-transactions.utils.ts index bef32fe2e5..63dad2bf1d 100644 --- a/src/frontend/src/icp/utils/icp-transactions.utils.ts +++ b/src/frontend/src/icp/utils/icp-transactions.utils.ts @@ -7,7 +7,7 @@ import type { import { getAccountIdentifier } from '$icp/utils/icp-account.utils'; import type { OptionIdentity } from '$lib/types/identity'; import type { Tokens, Transaction, TransactionWithId } from '@dfinity/ledger-icp'; -import { fromNullable, nonNullish } from '@dfinity/utils'; +import { fromNullable, jsonReplacer, nonNullish } from '@dfinity/utils'; export const mapTransactionIcpToSelf = ( tx: TransactionWithId @@ -137,5 +137,5 @@ export const mapIcpTransaction = ({ }; } - throw new Error(`Unknown transaction type ${JSON.stringify(transaction)}`); + throw new Error(`Unknown transaction type ${JSON.stringify(transaction, jsonReplacer)}`); }; diff --git a/src/frontend/src/icp/utils/icrc-transactions.utils.ts b/src/frontend/src/icp/utils/icrc-transactions.utils.ts index bd5fe1885d..2c784785af 100644 --- a/src/frontend/src/icp/utils/icrc-transactions.utils.ts +++ b/src/frontend/src/icp/utils/icrc-transactions.utils.ts @@ -6,7 +6,7 @@ import type { import { getIcrcAccount } from '$icp/utils/icrc-account.utils'; import type { OptionIdentity } from '$lib/types/identity'; import { encodeIcrcAccount, type IcrcTransactionWithId } from '@dfinity/ledger-icrc'; -import { fromNullable, isNullish, nonNullish } from '@dfinity/utils'; +import { fromNullable, isNullish, jsonReplacer, nonNullish } from '@dfinity/utils'; export const mapTransactionIcrcToSelf = (tx: IcrcTransactionWithId): IcrcTransaction[] => { const { transaction, id } = tx; @@ -70,7 +70,7 @@ export const mapIcrcTransaction = ({ fromNullable(approve) ?? fromNullable(burn) ?? fromNullable(mint) ?? fromNullable(transfer); if (isNullish(data)) { - throw new Error(`Unknown transaction type ${JSON.stringify(transaction)}`); + throw new Error(`Unknown transaction type ${JSON.stringify(transaction, jsonReplacer)}`); } const accountIdentifier = nonNullish(identity) diff --git a/src/frontend/src/lib/canisters/signer.errors.ts b/src/frontend/src/lib/canisters/signer.errors.ts index 18e85725dc..912043330b 100644 --- a/src/frontend/src/lib/canisters/signer.errors.ts +++ b/src/frontend/src/lib/canisters/signer.errors.ts @@ -5,17 +5,18 @@ import type { SendBtcError as SignerCanisterSendBtcError } from '$declarations/signer/signer.did'; import { CanisterInternalError } from '$lib/canisters/errors'; +import { jsonReplacer } from '@dfinity/utils'; export class SignerCanisterPaymentError extends CanisterInternalError { constructor(err: PaymentError) { if ('UnsupportedPaymentType' in err) { super('Unsupported payment type'); } else if ('LedgerWithdrawFromError' in err) { - super(`Ledger error: ${JSON.stringify(err.LedgerWithdrawFromError.error)}`); + super(`Ledger error: ${JSON.stringify(err.LedgerWithdrawFromError.error, jsonReplacer)}`); } else if ('LedgerUnreachable' in err) { - super(`Ledger unreachable: ${JSON.stringify(err.LedgerUnreachable)}`); + super(`Ledger unreachable: ${JSON.stringify(err.LedgerUnreachable, jsonReplacer)}`); } else if ('LedgerTransferFromError' in err) { - super(`Ledger error: ${JSON.stringify(err.LedgerTransferFromError)}`); + super(`Ledger error: ${JSON.stringify(err.LedgerTransferFromError, jsonReplacer)}`); } else if ('InsufficientFunds' in err) { super( `Insufficient funds needed ${err.InsufficientFunds.needed} but available ${err.InsufficientFunds.available}` @@ -46,7 +47,7 @@ export const mapSignerCanisterSendBtcError = ( return new SignerCanisterPaymentError(err.PaymentError); } if ('BuildP2wpkhError' in err) { - return new CanisterInternalError(JSON.stringify(err.BuildP2wpkhError)); + return new CanisterInternalError(JSON.stringify(err.BuildP2wpkhError, jsonReplacer)); } return new CanisterInternalError('Unknown SignerCanisterSendBtcError'); }; @@ -56,7 +57,9 @@ export const mapSignerCanisterGetEthAddressError = ( ): CanisterInternalError => { if ('SigningError' in err) { const [code, addOns] = err.SigningError; - return new CanisterInternalError(`Signing error: ${JSON.stringify(code)} ${addOns}`); + return new CanisterInternalError( + `Signing error: ${JSON.stringify(code, jsonReplacer)} ${addOns}` + ); } if ('PaymentError' in err) {