diff --git a/commercial-paper/organization/digibank/contract/ledger-api/statelist.js b/commercial-paper/organization/digibank/contract/ledger-api/statelist.js index 3c39671a83..cfd8964786 100644 --- a/commercial-paper/organization/digibank/contract/ledger-api/statelist.js +++ b/commercial-paper/organization/digibank/contract/ledger-api/statelist.js @@ -42,8 +42,12 @@ class StateList { async getState(key) { let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key)); let data = await this.ctx.stub.getState(ledgerKey); - let state = State.deserialize(data, this.supportedClasses); - return state; + if (data && data.toString('utf8')) { + let state = State.deserialize(data, this.supportedClasses); + return state; + } else { + return null; + } } /** diff --git a/commercial-paper/organization/magnetocorp/contract/ledger-api/statelist.js b/commercial-paper/organization/magnetocorp/contract/ledger-api/statelist.js index 3c39671a83..cfd8964786 100644 --- a/commercial-paper/organization/magnetocorp/contract/ledger-api/statelist.js +++ b/commercial-paper/organization/magnetocorp/contract/ledger-api/statelist.js @@ -42,8 +42,12 @@ class StateList { async getState(key) { let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key)); let data = await this.ctx.stub.getState(ledgerKey); - let state = State.deserialize(data, this.supportedClasses); - return state; + if (data && data.toString('utf8')) { + let state = State.deserialize(data, this.supportedClasses); + return state; + } else { + return null; + } } /**