From 3f195f74c9fe93764e82100429a5ba6074a11462 Mon Sep 17 00:00:00 2001 From: Dmytro Iakymenko Date: Mon, 28 Mar 2022 11:29:12 +0300 Subject: [PATCH] fix(core): tx error mapping fix --- packages/core/src/Cardano/types/TxSubmissionErrors.ts | 1 + .../core/test/Cardano/types/TxSubmissionErrors.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/core/src/Cardano/types/TxSubmissionErrors.ts b/packages/core/src/Cardano/types/TxSubmissionErrors.ts index a8582dff74f..c7060c33dda 100644 --- a/packages/core/src/Cardano/types/TxSubmissionErrors.ts +++ b/packages/core/src/Cardano/types/TxSubmissionErrors.ts @@ -22,6 +22,7 @@ export const TxSubmissionErrors = { ExpiredUtxoError: TxSubmission.errors.ExpiredUtxo.Error, ExtraDataMismatchError: TxSubmission.errors.ExtraDataMismatch.Error, ExtraRedeemersError: TxSubmission.errors.ExtraRedeemers.Error, + ExtraScriptWitnessesError: TxSubmission.errors.ExtraScriptWitnesses.Error, FeeTooSmallError: TxSubmission.errors.FeeTooSmall.Error, InsufficientFundsForMirError: TxSubmission.errors.InsufficientFundsForMir.Error, InsufficientGenesisSignaturesError: TxSubmission.errors.InsufficientGenesisSignatures.Error, diff --git a/packages/core/test/Cardano/types/TxSubmissionErrors.test.ts b/packages/core/test/Cardano/types/TxSubmissionErrors.test.ts index ca4289aaa53..1053b3dfa7a 100644 --- a/packages/core/test/Cardano/types/TxSubmissionErrors.test.ts +++ b/packages/core/test/Cardano/types/TxSubmissionErrors.test.ts @@ -1,4 +1,6 @@ import { Cardano } from '../../../src'; +import { TxSubmission } from '@cardano-ogmios/client'; +import { TxSubmissionErrors } from '../../../dist/Cardano'; describe('Cardano/types/TxSuubmissionErrors', () => { test('TxSubmissionError can be narrowed down with "instanceof"', () => { @@ -7,4 +9,12 @@ describe('Cardano/types/TxSuubmissionErrors', () => { }); expect(error).toBeInstanceOf(Cardano.TxSubmissionErrors.FeeTooSmallError); }); + test('maps all errors from Ogmios', () => { + const ogmiosErrors = Object.keys(TxSubmission.errors).sort(); + const sdkErrors = Object.keys(TxSubmissionErrors) + .filter((e) => e !== 'UnknownTxSubmissionError') + .map((e) => e.slice(0, Math.max(0, e.length - 5))) // drop 'Error' suffix + .sort(); + expect(sdkErrors).toEqual(ogmiosErrors); + }); });