From 01749d9ed349175a7646ab1d7d5f69dd5b822544 Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Fri, 22 Sep 2023 11:46:12 +0200 Subject: [PATCH] fix: correctly reference ABCIErrorKey --- src/provider/jsonrpc/jsonrpc.test.ts | 3 ++- src/provider/jsonrpc/jsonrpc.ts | 7 ++++--- src/provider/websocket/ws.test.ts | 3 ++- src/provider/websocket/ws.ts | 7 ++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/provider/jsonrpc/jsonrpc.test.ts b/src/provider/jsonrpc/jsonrpc.test.ts index c8b9607..37f5ff5 100644 --- a/src/provider/jsonrpc/jsonrpc.test.ts +++ b/src/provider/jsonrpc/jsonrpc.test.ts @@ -1,5 +1,6 @@ import { ABCIAccount, + ABCIErrorKey, ABCIResponse, BlockInfo, BlockResult, @@ -83,7 +84,7 @@ describe('JSON-RPC Provider', () => { const mockLog = 'random error message'; const invalidResult: BroadcastTxSyncResult = { error: { - ABCIErrorKey: mockError, + [ABCIErrorKey]: mockError, }, data: null, Log: mockLog, diff --git a/src/provider/jsonrpc/jsonrpc.ts b/src/provider/jsonrpc/jsonrpc.ts index aa77d7c..53c1227 100644 --- a/src/provider/jsonrpc/jsonrpc.ts +++ b/src/provider/jsonrpc/jsonrpc.ts @@ -1,5 +1,6 @@ import { Provider } from '../provider'; import { + ABCIErrorKey, ABCIResponse, BlockInfo, BlockResult, @@ -175,7 +176,7 @@ export class JSONRPCProvider implements Provider { // Check if there is an immediate tx-broadcast error // (originating from basic transaction checks like CheckTx) if (response.error) { - const errType: string = response.error.ABCIErrorKey; + const errType: string = response.error[ABCIErrorKey]; const log: string = response.Log; throw constructRequestError(errType, log); @@ -196,7 +197,7 @@ export class JSONRPCProvider implements Provider { // Check if there is an immediate tx-broadcast error (in CheckTx) if (check_tx.ResponseBase.Error) { - const errType: string = check_tx.ResponseBase.Error.ABCIErrorKey; + const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey]; const log: string = check_tx.ResponseBase.Log; throw constructRequestError(errType, log); @@ -204,7 +205,7 @@ export class JSONRPCProvider implements Provider { // Check if there is a parsing error with the transaction (in DeliverTx) if (deliver_tx.ResponseBase.Error) { - const errType: string = deliver_tx.ResponseBase.Error.ABCIErrorKey; + const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey]; const log: string = deliver_tx.ResponseBase.Log; throw constructRequestError(errType, log); diff --git a/src/provider/websocket/ws.test.ts b/src/provider/websocket/ws.test.ts index b6ab047..7ad89e0 100644 --- a/src/provider/websocket/ws.test.ts +++ b/src/provider/websocket/ws.test.ts @@ -1,5 +1,6 @@ import { ABCIAccount, + ABCIErrorKey, ABCIResponse, ABCIResponseBase, BeginBlock, @@ -264,7 +265,7 @@ describe('WS Provider', () => { const mockLog = 'random error message'; const invalidResult: BroadcastTxSyncResult = { error: { - ABCIErrorKey: mockError, + [ABCIErrorKey]: mockError, }, data: null, Log: mockLog, diff --git a/src/provider/websocket/ws.ts b/src/provider/websocket/ws.ts index eb18c38..0ef3502 100644 --- a/src/provider/websocket/ws.ts +++ b/src/provider/websocket/ws.ts @@ -1,5 +1,6 @@ import { Provider } from '../provider'; import { + ABCIErrorKey, ABCIResponse, BlockInfo, BlockResult, @@ -287,7 +288,7 @@ export class WSProvider implements Provider { // Check if there is an immediate tx-broadcast error // (originating from basic transaction checks like CheckTx) if (broadcastResponse.error) { - const errType: string = broadcastResponse.error.ABCIErrorKey; + const errType: string = broadcastResponse.error[ABCIErrorKey]; const log: string = broadcastResponse.Log; throw constructRequestError(errType, log); @@ -309,7 +310,7 @@ export class WSProvider implements Provider { // Check if there is an immediate tx-broadcast error (in CheckTx) if (check_tx.ResponseBase.Error) { - const errType: string = check_tx.ResponseBase.Error.ABCIErrorKey; + const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey]; const log: string = check_tx.ResponseBase.Log; throw constructRequestError(errType, log); @@ -317,7 +318,7 @@ export class WSProvider implements Provider { // Check if there is a parsing error with the transaction (in DeliverTx) if (deliver_tx.ResponseBase.Error) { - const errType: string = deliver_tx.ResponseBase.Error.ABCIErrorKey; + const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey]; const log: string = deliver_tx.ResponseBase.Log; throw constructRequestError(errType, log);