From 8c6ab1da9d415b436d055c5a78a33acbc6ca5650 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Sat, 12 Jan 2019 10:48:12 -0400 Subject: [PATCH 1/9] Whitespace clean up. --- deamon/action_deamon.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/deamon/action_deamon.js b/deamon/action_deamon.js index 48f093b..d354e94 100644 --- a/deamon/action_deamon.js +++ b/deamon/action_deamon.js @@ -25,8 +25,8 @@ class WatchActions { this.eos = eosjs({ - chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', // 32 byte (64 char) hex string - httpEndpoint: 'http://ex1.eosdac.io:8080', + chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', // 32 byte (64 char) hex string + httpEndpoint: 'http://ex1.eosdac.io:8080', }); console.log(colors.green('Connected to EOS network!') ); @@ -89,7 +89,7 @@ class WatchActions { } switch (data.actiontype) { - case 'transfer': + case 'transfer': data._from = x.action_trace.act.data.from; data._to = x.action_trace.act.data.to; let temp = x.action_trace.act.data.quantity.split(' '); @@ -110,8 +110,8 @@ class WatchActions { break; - default: - console.log(colors.red('Unknown Action!') ); + default: + console.log(colors.red('Unknown Action!') ); }; }); @@ -122,7 +122,7 @@ class WatchActions { } _sleep(t) { - return new Promise(resolve => setTimeout(resolve, t)); + return new Promise(resolve => setTimeout(resolve, t)); } From d746546a8c0465eefe4493dc09e4fe9c71f95e52 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Sat, 12 Jan 2019 10:48:51 -0400 Subject: [PATCH 2/9] Adding is_member and has_voted (with a future possibility for is_exchange). --- api/explorer_base_api.php | 2 +- deamon/action_deamon.js | 38 +++++++++++++++++++++++++++++++++- deamon/sql.txt | 4 +++- frontend/src/pages/hodlers.vue | 4 +++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/api/explorer_base_api.php b/api/explorer_base_api.php index e840364..dc222de 100644 --- a/api/explorer_base_api.php +++ b/api/explorer_base_api.php @@ -35,7 +35,7 @@ switch ($_GET['chart']) { case 'topholders': - $stmt = $conn->prepare('SELECT account,balance FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); + $stmt = $conn->prepare('SELECT account,balance,is_member,has_voted FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); break; case 'tokenactivity': $where = isset($_GET['account']) ? 'AND _from ="'.$_GET['account'].'" OR _to ="'.$_GET['account'].'"' : ''; diff --git a/deamon/action_deamon.js b/deamon/action_deamon.js index d354e94..5948683 100644 --- a/deamon/action_deamon.js +++ b/deamon/action_deamon.js @@ -88,6 +88,13 @@ class WatchActions { data.confirmed = true; } + let new_balance_entry = {}; + new_balance_entry.account = ''; + new_balance_entry.balance = 0; + new_balance_entry.is_member = 0; + new_balance_entry.has_voted = 0; + new_balance_entry.is_exchange = 0; + switch (data.actiontype) { case 'transfer': data._from = x.action_trace.act.data.from; @@ -108,7 +115,36 @@ class WatchActions { } } - break; + break; + case 'memberunreg': + new_balance_entry.account = x.action_trace.act.data.sender; + let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE is_member = 0`; + try{ + var [rows, fields] = await self.db.query(sql, new_balance_entry); + }catch(e){ + console.log('error'); + } + case 'memberreg': + new_balance_entry.account = x.action_trace.act.data.sender; + let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE is_member = 1`; + try{ + var [rows, fields] = await self.db.query(sql, new_balance_entry); + }catch(e){ + console.log('error'); + } + case 'votecust': + new_balance_entry.account = x.action_trace.act.data.voter; + if (x.action_trace.act.data.newvotes.count > 0) { + new_balance_entry.has_voted = 1; + } else { + new_balance_entry.has_voted = 0; + } + let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE has_voted = ${new_balance_entry.has_voted}`; + try{ + var [rows, fields] = await self.db.query(sql, new_balance_entry); + }catch(e){ + console.log('error'); + } default: console.log(colors.red('Unknown Action!') ); diff --git a/deamon/sql.txt b/deamon/sql.txt index 95ae6a7..8146160 100644 --- a/deamon/sql.txt +++ b/deamon/sql.txt @@ -16,10 +16,12 @@ CREATE TABLE `transfers` ( CREATE TABLE `balances` ( `account` varchar(256) NOT NULL, `balance` decimal(13,4) DEFAULT NULL, + `is_member` tinyint(1) DEFAULT NULL, + `has_voted` tinyint(1) DEFAULT NULL, + `is_exchange` tinyint(1) DEFAULT NULL, PRIMARY KEY (`account`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 - delimiter $$ $$ CREATE TRIGGER update_balance_table AFTER INSERT ON eosdac_explorer.transfers diff --git a/frontend/src/pages/hodlers.vue b/frontend/src/pages/hodlers.vue index 907582c..37fb720 100644 --- a/frontend/src/pages/hodlers.vue +++ b/frontend/src/pages/hodlers.vue @@ -77,7 +77,9 @@ export default { columns: [ { name: 'rank', label: '', field: 'rank', align: 'center', ignoreapi:true}, { name: 'account', label: this.$t('account'), field: 'account', align: 'center', searchable:true}, - { name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'} + { name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'}, + { name: 'is_member', label: 'Is Member?', field: 'is_member' , align: 'center'}, + { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'} ] } }, From 8d3d6c0b7bd4fb1601d91a6aed99e9d52469fe46 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Sat, 12 Jan 2019 10:49:14 -0400 Subject: [PATCH 3/9] Bug fix for determining if an account is a member. --- frontend/src/pages/account.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/account.vue b/frontend/src/pages/account.vue index 1772179..f940f57 100644 --- a/frontend/src/pages/account.vue +++ b/frontend/src/pages/account.vue @@ -253,7 +253,7 @@ export default { return false; } else{ - if (res.rows[0].sender === this.title && res.rows[0].agreedterms == 2){ + if (res.rows[0].sender === this.title && res.rows[0].agreedtermsversion > 0){ this.ismember = true; } else{ From bfcdf1bf3ced7cec2b3f4f74b45650dc21f00b97 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Sat, 12 Jan 2019 10:49:32 -0400 Subject: [PATCH 4/9] Adding getVotes method. --- frontend/src/pages/account.vue | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/account.vue b/frontend/src/pages/account.vue index f940f57..d4396c3 100644 --- a/frontend/src/pages/account.vue +++ b/frontend/src/pages/account.vue @@ -48,14 +48,9 @@
-

0

+

{{votes}}

{{ $t('VOTES') }}
-
- -

Coming Soon

-
- @@ -193,6 +188,7 @@ export default { ismember: false, eosdacbalance:0, eosbalance:0, + votes:0, filter: '', loading: false, serverPagination: { @@ -223,6 +219,25 @@ export default { }, + getVotes(){ + this.$eos.getTableRows({json: "true", scope: "daccustodian", code: "daccustodian", table: "votes", lower_bound: this.title, limit:1}).then(res =>{ + + if(!res.rows.length){ + this.votes = 0; + return false; + } + else{ + if (res.rows[0].sender === this.title){ + this.votes = res.rows[0].candidates.length; + } + else{ + this.votes = 0; + } + } + }).catch(e => { + this.$q.notify({message:this.$t('error_node_member'), color:'negative'}); + }) + }, getBalances(){ this.$eos.getCurrencyBalance({account: this.title, code: "eosdactokens", symbol: "EOSDAC"}).then(x=>{ if(x.length !=0){ @@ -302,6 +317,7 @@ export default { }); this.getBalances(); this.getMemberStatus(); + this.getVotes(); }, watch: { @@ -313,6 +329,7 @@ watch: { }); this.getBalances(); this.getMemberStatus(); + this.getVotes(); } }, From 77915ac7ac0d006effa0353f4417a7d7be8127f7 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Tue, 15 Jan 2019 16:49:59 -0400 Subject: [PATCH 5/9] Updating based on discussions with pieces --- api/explorer_base_api.php | 2 +- api/explorer_table_api.php | 14 ++++++------- deamon/action_deamon.js | 38 ---------------------------------- deamon/sql.txt | 6 +++--- frontend/src/pages/hodlers.vue | 1 + 5 files changed, 12 insertions(+), 49 deletions(-) diff --git a/api/explorer_base_api.php b/api/explorer_base_api.php index 01dff5c..ae3d614 100644 --- a/api/explorer_base_api.php +++ b/api/explorer_base_api.php @@ -35,7 +35,7 @@ switch ($_GET['chart']) { case 'topholders': - $stmt = $conn->prepare('SELECT account,balance,is_member,has_voted FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); + $stmt = $conn->prepare('SELECT account,balance,is_member,has_voted,is_exchange FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); break; case 'tokenactivity': $where = isset($_GET['account']) ? 'AND _from ="'.$_GET['account'].'" OR _to ="'.$_GET['account'].'"' : ''; diff --git a/api/explorer_table_api.php b/api/explorer_table_api.php index bc11362..578d7de 100644 --- a/api/explorer_table_api.php +++ b/api/explorer_table_api.php @@ -27,18 +27,18 @@ break; case 'hodlers': - $dt->query('SELECT account,balance, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC'); + $dt->query('SELECT account,balance,is_member,has_voted,is_exchange, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC'); // $dt->query('SELECT account, balance FROM balances WHERE balance > 0'); break; case 'transfers': - $dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers ORDER BY account_action_seq DESC'); + $dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers ORDER BY account_action_seq DESC'); break; case 'accounttransfers': - if (isset($_GET['account'])) { - $account = $_GET['account']; - // echo $account; - $dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers WHERE _from="'.$account.'" OR _to="'.$account.'" '); - } + if (isset($_GET['account'])) { + $account = $_GET['account']; + // echo $account; + $dt->query('SELECT `account_action_seq`,`_from`,`_to`,`_quantity`,`_symbol`,`_memo`,`txid`,`block_num`,`block_time` FROM transfers WHERE _from="'.$account.'" OR _to="'.$account.'" '); + } break; } } diff --git a/deamon/action_deamon.js b/deamon/action_deamon.js index 27a5363..92609c6 100644 --- a/deamon/action_deamon.js +++ b/deamon/action_deamon.js @@ -93,13 +93,6 @@ class WatchActions { data.confirmed = true; } - let new_balance_entry = {}; - new_balance_entry.account = ''; - new_balance_entry.balance = 0; - new_balance_entry.is_member = 0; - new_balance_entry.has_voted = 0; - new_balance_entry.is_exchange = 0; - switch (data.actiontype) { case 'transfer': data._from = x.action_trace.act.data.from; @@ -121,37 +114,6 @@ class WatchActions { } break; - - case 'memberunreg': - new_balance_entry.account = x.action_trace.act.data.sender; - let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE is_member = 0`; - try{ - var [rows, fields] = await self.db.query(sql, new_balance_entry); - }catch(e){ - console.log('error'); - } - case 'memberreg': - new_balance_entry.account = x.action_trace.act.data.sender; - let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE is_member = 1`; - try{ - var [rows, fields] = await self.db.query(sql, new_balance_entry); - }catch(e){ - console.log('error'); - } - case 'votecust': - new_balance_entry.account = x.action_trace.act.data.voter; - if (x.action_trace.act.data.newvotes.count > 0) { - new_balance_entry.has_voted = 1; - } else { - new_balance_entry.has_voted = 0; - } - let sql = `INSERT INTO balances SET ? ON DUPLICATE KEY UPDATE has_voted = ${new_balance_entry.has_voted}`; - try{ - var [rows, fields] = await self.db.query(sql, new_balance_entry); - }catch(e){ - console.log('error'); - } - default: console.log(colors.red('Unknown Action!') ); }; diff --git a/deamon/sql.txt b/deamon/sql.txt index 8146160..81d65a7 100644 --- a/deamon/sql.txt +++ b/deamon/sql.txt @@ -16,9 +16,9 @@ CREATE TABLE `transfers` ( CREATE TABLE `balances` ( `account` varchar(256) NOT NULL, `balance` decimal(13,4) DEFAULT NULL, - `is_member` tinyint(1) DEFAULT NULL, - `has_voted` tinyint(1) DEFAULT NULL, - `is_exchange` tinyint(1) DEFAULT NULL, + `is_member` tinyint(1) DEFAULT 0 NOT NULL, + `has_voted` tinyint(1) DEFAULT 0 NOT NULL, + `is_exchange` tinyint(1) DEFAULT 0 NOT NULL, PRIMARY KEY (`account`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 diff --git a/frontend/src/pages/hodlers.vue b/frontend/src/pages/hodlers.vue index 37fb720..c4f1300 100644 --- a/frontend/src/pages/hodlers.vue +++ b/frontend/src/pages/hodlers.vue @@ -80,6 +80,7 @@ export default { { name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'}, { name: 'is_member', label: 'Is Member?', field: 'is_member' , align: 'center'}, { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'} + { name: 'is_exchange', label: 'Is an Exchange?', field: 'is_exchange' , align: 'center'} ] } }, From 33c5cc542c765ce1ebebafa17b07ba056f1fe8ac Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Tue, 15 Jan 2019 19:08:56 -0400 Subject: [PATCH 6/9] Fixing missing comma --- frontend/src/pages/hodlers.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/hodlers.vue b/frontend/src/pages/hodlers.vue index c4f1300..a4a167d 100644 --- a/frontend/src/pages/hodlers.vue +++ b/frontend/src/pages/hodlers.vue @@ -79,7 +79,7 @@ export default { { name: 'account', label: this.$t('account'), field: 'account', align: 'center', searchable:true}, { name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'}, { name: 'is_member', label: 'Is Member?', field: 'is_member' , align: 'center'}, - { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'} + { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'}, { name: 'is_exchange', label: 'Is an Exchange?', field: 'is_exchange' , align: 'center'} ] } From 8b5fad90f9ed531a7d31ff9c3295a32766d17e8f Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Tue, 15 Jan 2019 23:17:19 -0400 Subject: [PATCH 7/9] Removing is_exchange for now --- api/explorer_base_api.php | 2 +- api/explorer_table_api.php | 2 +- deamon/action_deamon.js | 1 + frontend/src/pages/hodlers.vue | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/explorer_base_api.php b/api/explorer_base_api.php index ae3d614..01dff5c 100644 --- a/api/explorer_base_api.php +++ b/api/explorer_base_api.php @@ -35,7 +35,7 @@ switch ($_GET['chart']) { case 'topholders': - $stmt = $conn->prepare('SELECT account,balance,is_member,has_voted,is_exchange FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); + $stmt = $conn->prepare('SELECT account,balance,is_member,has_voted FROM balances WHERE balance > 0 ORDER BY balance DESC LIMIT 500'); break; case 'tokenactivity': $where = isset($_GET['account']) ? 'AND _from ="'.$_GET['account'].'" OR _to ="'.$_GET['account'].'"' : ''; diff --git a/api/explorer_table_api.php b/api/explorer_table_api.php index 6998d31..1cd9f5c 100644 --- a/api/explorer_table_api.php +++ b/api/explorer_table_api.php @@ -27,7 +27,7 @@ break; case 'hodlers': - $dt->query('SELECT account,balance,is_member,has_voted,is_exchange, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC'); + $dt->query('SELECT account,balance,is_member,has_voted, @curRank := @curRank + 1 AS rank FROM balances p, (SELECT @curRank := 0) r WHERE balance > 0 ORDER BY balance DESC'); // $dt->query('SELECT account, balance FROM balances WHERE balance > 0'); break; case 'transfers': diff --git a/deamon/action_deamon.js b/deamon/action_deamon.js index 92609c6..77380a1 100644 --- a/deamon/action_deamon.js +++ b/deamon/action_deamon.js @@ -114,6 +114,7 @@ class WatchActions { } break; + default: console.log(colors.red('Unknown Action!') ); }; diff --git a/frontend/src/pages/hodlers.vue b/frontend/src/pages/hodlers.vue index a4a167d..37fb720 100644 --- a/frontend/src/pages/hodlers.vue +++ b/frontend/src/pages/hodlers.vue @@ -79,8 +79,7 @@ export default { { name: 'account', label: this.$t('account'), field: 'account', align: 'center', searchable:true}, { name: 'balance', label: 'EOSDAC', field: 'balance' , align: 'left'}, { name: 'is_member', label: 'Is Member?', field: 'is_member' , align: 'center'}, - { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'}, - { name: 'is_exchange', label: 'Is an Exchange?', field: 'is_exchange' , align: 'center'} + { name: 'has_voted', label: 'Has Voted?', field: 'has_voted' , align: 'center'} ] } }, From d64a84145b96a63ad433edf64994f66707c0749c Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Tue, 15 Jan 2019 23:24:40 -0400 Subject: [PATCH 8/9] Fix for votes count on the account page. --- frontend/src/pages/account.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/pages/account.vue b/frontend/src/pages/account.vue index b61e0ce..720cf0b 100644 --- a/frontend/src/pages/account.vue +++ b/frontend/src/pages/account.vue @@ -221,13 +221,12 @@ export default { getVotes(){ this.$eos.getTableRows({json: "true", scope: "daccustodian", code: "daccustodian", table: "votes", lower_bound: this.title, limit:1}).then(res =>{ - if(!res.rows.length){ this.votes = 0; return false; } else{ - if (res.rows[0].sender === this.title){ + if (res.rows[0].voter === this.title){ this.votes = res.rows[0].candidates.length; } else{ From b8df3a988522cef536c8721a840592da97c7a145 Mon Sep 17 00:00:00 2001 From: Luke Stokes Date: Tue, 15 Jan 2019 23:42:55 -0400 Subject: [PATCH 9/9] Add Yes/No display --- frontend/src/pages/hodlers.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/hodlers.vue b/frontend/src/pages/hodlers.vue index 37fb720..bbe43f7 100644 --- a/frontend/src/pages/hodlers.vue +++ b/frontend/src/pages/hodlers.vue @@ -21,10 +21,20 @@ {{ props.value }} - + {{ props.value }} + + Yes + No + + + + Yes + No + +