From ce66f0744976e8f2abfa05055bfa384f3d084321 Mon Sep 17 00:00:00 2001 From: Annelein <48122190+Annelein@users.noreply.github.com> Date: Thu, 10 Feb 2022 10:51:44 +0100 Subject: [PATCH] fix: check for "REQNACK" response from indy ledger (#626) Signed-off-by: annelein --- packages/core/src/modules/ledger/IndyPool.ts | 4 ++-- packages/core/src/modules/ledger/ledgerUtil.ts | 4 ++++ yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/core/src/modules/ledger/IndyPool.ts b/packages/core/src/modules/ledger/IndyPool.ts index f270a6b628..9c48df7808 100644 --- a/packages/core/src/modules/ledger/IndyPool.ts +++ b/packages/core/src/modules/ledger/IndyPool.ts @@ -7,7 +7,7 @@ import { AriesFrameworkError, IndySdkError } from '../../error' import { isIndyError } from '../../utils/indyError' import { LedgerError } from './error/LedgerError' -import { isLedgerRejectResponse } from './ledgerUtil' +import { isLedgerRejectResponse, isLedgerReqnackResponse } from './ledgerUtil' export interface IndyPoolConfig { genesisPath?: string @@ -122,7 +122,7 @@ export class IndyPool { public async submitReadRequest(request: Indy.LedgerRequest) { const response = await this.submitRequest(request) - if (isLedgerRejectResponse(response)) { + if (isLedgerRejectResponse(response) || isLedgerReqnackResponse(response)) { throw new LedgerError(`Ledger '${this.id}' rejected read transaction request: ${response.reason}`) } diff --git a/packages/core/src/modules/ledger/ledgerUtil.ts b/packages/core/src/modules/ledger/ledgerUtil.ts index a8063974b2..62e75f1e72 100644 --- a/packages/core/src/modules/ledger/ledgerUtil.ts +++ b/packages/core/src/modules/ledger/ledgerUtil.ts @@ -3,3 +3,7 @@ import type * as Indy from 'indy-sdk' export function isLedgerRejectResponse(response: Indy.LedgerResponse): response is Indy.LedgerRejectResponse { return response.op === 'REJECT' } + +export function isLedgerReqnackResponse(response: Indy.LedgerResponse): response is Indy.LedgerReqnackResponse { + return response.op === 'REQNACK' +} diff --git a/yarn.lock b/yarn.lock index 8c017a7033..1d19c53c1c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2237,10 +2237,10 @@ dependencies: "@types/node" "*" -"@types/indy-sdk-react-native@npm:@types/indy-sdk@^1.16.10", "@types/indy-sdk@^1.16.10": - version "1.16.10" - resolved "https://registry.yarnpkg.com/@types/indy-sdk/-/indy-sdk-1.16.10.tgz#cb13c0c639ce63758eecf534dc01111dc1c42633" - integrity sha512-zcSBMiDyareFHgDF/RpeWvboFTBTnHLi/+SK8pb7UL+o9WIHW6W8ZuLkinOiu58MvPlKceSjEx8dAl/+yoW2JA== +"@types/indy-sdk-react-native@npm:@types/indy-sdk@^1.16.12", "@types/indy-sdk@^1.16.12": + version "1.16.12" + resolved "https://registry.npmjs.org/@types/indy-sdk/-/indy-sdk-1.16.12.tgz#7b6ad4e4ebf11125bd77f0ef98cf727d0262c4b7" + integrity sha512-6uyHSSAoM+eKQD4XF+KohAjbkDN6D9DnriYWlGi/pLCWkd74kCcEMlm7/REqfMkAgxL52wh7Cyzir+cnIi342g== dependencies: buffer "^6.0.0"