Skip to content

Commit

Permalink
Fix potential unhandled promise when getting node state
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Apr 6, 2023
1 parent d2f255a commit fba1872
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion dist/nkn.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,14 @@ class Client {

if (nodeInfo.rpcAddr) {
let addr = (tls ? 'https' : 'http') + '://' + nodeInfo.rpcAddr;
common.rpc.getNodeState.call(this, {
common.rpc.getNodeState({
rpcServerAddr: addr
}).then(nodeState => {
if (nodeState.syncState === 'PERSIST_FINISHED') {
this.wallet.options.rpcServerAddr = addr;
}
}).catch(e => {
console.log(e);
});
}

Expand Down
2 changes: 1 addition & 1 deletion dist/nkn.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset='utf-8'>
<title>nkn-sdk 1.3.0 | Documentation</title>
<title>nkn-sdk 1.3.1 | Documentation</title>
<meta name='description' content='NKN client and wallet SDK'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
Expand All @@ -15,7 +15,7 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>nkn-sdk</h3>
<div class='mb1'><code>1.3.0</code></div>
<div class='mb1'><code>1.3.1</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down
4 changes: 3 additions & 1 deletion lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,14 @@ class Client {

if (nodeInfo.rpcAddr) {
let addr = (tls ? 'https' : 'http') + '://' + nodeInfo.rpcAddr;
common.rpc.getNodeState.call(this, {
common.rpc.getNodeState({
rpcServerAddr: addr
}).then(nodeState => {
if (nodeState.syncState === 'PERSIST_FINISHED') {
this.wallet.options.rpcServerAddr = addr;
}
}).catch(e => {
console.log(e);
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nkn-sdk",
"version": "1.3.0",
"version": "1.3.1",
"description": "NKN client and wallet SDK",
"main": "lib/index.js",
"exports": {
Expand Down
6 changes: 4 additions & 2 deletions src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,13 @@ export default class Client {
this.wallet.options.rpcServerAddr = '';
if (nodeInfo.rpcAddr) {
let addr = (tls ? 'https' : 'http') + '://' + nodeInfo.rpcAddr;
common.rpc.getNodeState.call(this, {rpcServerAddr:addr}).then(nodeState => {
common.rpc.getNodeState({ rpcServerAddr:addr }).then(nodeState => {
if (nodeState.syncState === 'PERSIST_FINISHED') {
this.wallet.options.rpcServerAddr = addr;
}
})
}).catch((e) => {
console.log(e);
});
}

let challengeDone: Function;
Expand Down

0 comments on commit fba1872

Please sign in to comment.