• R/O
  • HTTP
  • SSH
  • HTTPS

Bytom-JS-SDK: Commit

It is a project for Bytom Chrome extension JS SDK https://bytom.github.io/Bytom-JS-SDK


Commit MetaInfo

Revision3b77f6f7434aa7cec1af8f415bfa845a60b74daa (tree)
Time2020-10-22 12:05:18
AuthorZhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Log Message

update list account for v2 structure and before.

Change Summary

Incremental Difference

--- a/src/sdk/accounts.js
+++ b/src/sdk/accounts.js
@@ -1,9 +1,44 @@
1+import {getDB} from '../db/db';
2+
13 function accountsSDK(bytom){
24 this.http = bytom.serverHttp;
35 this.bytom = bytom;
46 }
57
8+/**
9+ * List of the account.
10+ *
11+ * @returns {Promise} List of Accounts
12+ */
13+accountsSDK.prototype.listAccountUseServer = function() {
14+ let net = 'mainnet';
15+ // let net = 'testnet';
16+ let retPromise = new Promise((resolve, reject) => {
17+ getDB().then(db => {
18+ let transaction = db.transaction(['accounts-server'], 'readonly');
19+ let objectStore = transaction.objectStore('accounts-server').index('net');
20+ let keyRange = IDBKeyRange.only(net);
21+ let oc = objectStore.openCursor(keyRange);
22+ let ret = [];
623
24+ oc.onsuccess = function (event) {
25+ var cursor = event.target.result;
26+ if (cursor) {
27+ ret.push(cursor.value);
28+ cursor.continue();
29+ } else {
30+ resolve(ret);
31+ }
32+ };
33+ oc.onerror = function(e){
34+ reject(e);
35+ };
36+ }).catch(error => {
37+ reject(error);
38+ });
39+ });
40+ return retPromise;
41+};
742
843 /**
944 * List all addresses and the corresponding balances of a wallet.
Show on old repository browser