Skip to content

Commit

Permalink
fix: correctly reference ABCIErrorKey (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl authored Sep 22, 2023
1 parent 579b69d commit 194034b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/provider/jsonrpc/jsonrpc.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ABCIAccount,
ABCIErrorKey,
ABCIResponse,
BlockInfo,
BlockResult,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/provider/jsonrpc/jsonrpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Provider } from '../provider';
import {
ABCIErrorKey,
ABCIResponse,
BlockInfo,
BlockResult,
Expand Down Expand Up @@ -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);
Expand All @@ -196,15 +197,15 @@ 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);
}

// 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);
Expand Down
3 changes: 2 additions & 1 deletion src/provider/websocket/ws.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ABCIAccount,
ABCIErrorKey,
ABCIResponse,
ABCIResponseBase,
BeginBlock,
Expand Down Expand Up @@ -264,7 +265,7 @@ describe('WS Provider', () => {
const mockLog = 'random error message';
const invalidResult: BroadcastTxSyncResult = {
error: {
ABCIErrorKey: mockError,
[ABCIErrorKey]: mockError,
},
data: null,
Log: mockLog,
Expand Down
7 changes: 4 additions & 3 deletions src/provider/websocket/ws.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Provider } from '../provider';
import {
ABCIErrorKey,
ABCIResponse,
BlockInfo,
BlockResult,
Expand Down Expand Up @@ -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);
Expand All @@ -309,15 +310,15 @@ 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);
}

// 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);
Expand Down

0 comments on commit 194034b

Please sign in to comment.