Skip to content

Commit cf536a5

Browse files
committed
Fix a minor subscription API issue
1 parent 93bc39c commit cf536a5

11 files changed

Lines changed: 41 additions & 11 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ tpCH, errCH := api.SubscribeTrieProof(ctx, cli, id, triePf.GetId())
118118
for tp := range tpCH {
119119
log.Printf("Anchoring proof: %s\n", tp.GetStatus())
120120
triePf = tp
121+
122+
if tp.GetStatus() == anchorPB.Batch_ERROR {
123+
return errors.New(tp.GetError())
124+
}
121125
}
122126

123127
// always check error from the error channel

cmd/proofable-cli/cmd/cmd_create_proof.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
* @Author: guiguan
2020
* @Date: 2019-09-16T16:21:53+10:00
2121
* @Last modified by: guiguan
22-
* @Last modified time: 2020-07-07T10:40:57+10:00
22+
* @Last modified time: 2020-07-10T15:08:44+10:00
2323
*/
2424

2525
package cmd
2626

2727
import (
2828
"bytes"
2929
"context"
30+
"errors"
3031
"fmt"
3132
"time"
3233

@@ -167,6 +168,10 @@ By default, if the path is a directory, the proof will be created under the dire
167168
for tp := range tpCH {
168169
colorcli.Printf("Anchoring proof: %s\n", tp.GetStatus())
169170
triePf = tp
171+
172+
if tp.GetStatus() == anchorPB.Batch_ERROR {
173+
return errors.New(tp.GetError())
174+
}
170175
}
171176

172177
err = <-errCH

docs/example.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
* @Author: guiguan
2020
* @Date: 2020-03-31T12:29:46+11:00
2121
* @Last modified by: guiguan
22-
* @Last modified time: 2020-07-09T13:48:44+10:00
22+
* @Last modified time: 2020-07-10T15:31:33+10:00
2323
*/
2424

2525
package main
2626

2727
import (
2828
"context"
2929
"encoding/hex"
30+
"errors"
3031
"fmt"
3132
"log"
3233
"time"
@@ -84,6 +85,10 @@ func main() {
8485
for tp := range tpCH {
8586
log.Printf("Anchoring proof: %s\n", tp.GetStatus())
8687
triePf = tp
88+
89+
if tp.GetStatus() == anchorPB.Batch_ERROR {
90+
return errors.New(tp.GetError())
91+
}
8792
}
8893

8994
// always check error from the error channel

node_sdk/docs/example.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ for await (const tp of client.subscribeTrieProof(
8686
)) {
8787
console.log("Anchoring proof: %s", Batch.StatusName[tp.getStatus()]);
8888
trieProof = tp;
89+
90+
if (tp.getStatus() === Batch.Status.ERROR) {
91+
throw new Error(tp.getError());
92+
}
8993
}
9094
```
9195

node_sdk/docs/reference/interfaces/_index_.proofverificationresult.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h3>key<wbr>Values</h3>
9595
<div class="tsd-signature tsd-kind-icon">key<wbr>Values<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>changed<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>missing<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">; </span>passed<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>total<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>untracked<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> }</span></div>
9696
<aside class="tsd-sources">
9797
<ul>
98-
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L126">src/api/helpers.ts:126</a></li>
98+
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L130">src/api/helpers.ts:130</a></li>
9999
</ul>
100100
</aside>
101101
<div class="tsd-type-declaration">
@@ -125,7 +125,7 @@ <h3>proof</h3>
125125
<div class="tsd-signature tsd-kind-icon">proof<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>anchorType<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>blockNumber<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>blockTime<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>blockTimeNano<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span>blockTimeString<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>error<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>id<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>root<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>txnId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>txnUri<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>verified<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> }</span></div>
126126
<aside class="tsd-sources">
127127
<ul>
128-
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L113">src/api/helpers.ts:113</a></li>
128+
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L117">src/api/helpers.ts:117</a></li>
129129
</ul>
130130
</aside>
131131
<div class="tsd-type-declaration">
@@ -173,7 +173,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> trie</h3>
173173
<div class="tsd-signature tsd-kind-icon">trie<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-symbol">{ </span>id<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span>root<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></div>
174174
<aside class="tsd-sources">
175175
<ul>
176-
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L109">src/api/helpers.ts:109</a></li>
176+
<li>Defined in <a href="https://github.com/SouthbankSoftware/proofable/blob/master/node_sdk/src/api/helpers.ts#L113">src/api/helpers.ts:113</a></li>
177177
</ul>
178178
</aside>
179179
</section>

node_sdk/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "proofable",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "Proofable Node SDK",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

node_sdk/src/api/helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @Author: guiguan
2020
* @Date: 2020-07-02T11:42:17+10:00
2121
* @Last modified by: guiguan
22-
* @Last modified time: 2020-07-07T11:09:21+10:00
22+
* @Last modified time: 2020-07-10T15:22:06+10:00
2323
*/
2424

2525
import util from "util";
@@ -100,6 +100,10 @@ export async function anchorTrie(
100100
outputProgress &&
101101
console.log("Anchoring proof: %s", Batch.StatusName[tp.getStatus()]);
102102
trieProof = tp;
103+
104+
if (tp.getStatus() === Batch.Status.ERROR) {
105+
throw new Error(tp.getError());
106+
}
103107
}
104108

105109
return trieProof;

node_sdk/src/examples/javascript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @Author: Koustubh Gaikwad
2121
* @Date: 2020-06-19T09:26:20+10:00
2222
* @Last modified by: guiguan
23-
* @Last modified time: 2020-07-08T10:51:08+10:00
23+
* @Last modified time: 2020-07-10T15:28:33+10:00
2424
*/
2525

2626
const {
@@ -89,6 +89,10 @@ const client = newAPIClient(API_PROOFABLE_ENDPOINT);
8989
)) {
9090
console.log("Anchoring proof: %s", Batch.StatusName[tp.getStatus()]);
9191
trieProof = tp;
92+
93+
if (tp.getStatus() === Batch.Status.ERROR) {
94+
throw new Error(tp.getError());
95+
}
9296
}
9397

9498
// verify the proof

node_sdk/src/examples/typescript.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @Author: Koustubh Gaikwad
2020
* @Date: 2020-06-19T09:26:20+10:00
2121
* @Last modified by: guiguan
22-
* @Last modified time: 2020-07-08T10:51:08+10:00
22+
* @Last modified time: 2020-07-10T15:27:56+10:00
2323
*/
2424

2525
import {
@@ -89,6 +89,10 @@ const client = newAPIClient(API_PROOFABLE_ENDPOINT);
8989
)) {
9090
console.log("Anchoring proof: %s", Batch.StatusName[tp.getStatus()]);
9191
trieProof = tp;
92+
93+
if (tp.getStatus() === Batch.Status.ERROR) {
94+
throw new Error(tp.getError());
95+
}
9296
}
9397

9498
// verify the proof

0 commit comments

Comments
 (0)