Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Follow up the new Cosmos SDK used by Panacea v1.3.3 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youngjoon Lee authored Dec 9, 2020
1 parent e13610b commit 86bb813
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "explorer_server",
"version": "0.0.1",
"version": "0.0.2",
"description": "explorer server",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions server/src/block/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export const handleBlocksResponse = async (blocks, t) => {

// apply genesis coin distribution
const promises = genesis.app_state.accounts.map(
acc => updateGenesisToAccounts(acc.address, acc.coins[0].amount, t),
acc => updateGenesisToAccounts(acc.address, acc.coins.length > 0 ? acc.coins[0].amount : '0', t),
);
await Promise.all(promises);

// apply genesis transactions
const genTxs = genesis.app_state.gentxs
const genTxs = genesis.app_state.genutil.gentxs
.reduce((acc, tx, i) => {
const data = {
tx,
Expand Down Expand Up @@ -129,11 +129,11 @@ export const getBlocks = (currentHeight, lastHeight) => db.transaction((t) => {
heights.push(i);
}

return Promise.all(heights.map(height => {
return Promise.all(heights.map(height => {
if (height === 1) return requestBlockByHeightInTendermint(height);
return requestBlockByHeight(height);
}))
.then(async (blocks) => {
.then(async (blocks) => {
const promises = blocks.map(async (block) => {
if (block.txs && block.txs !== []) {
const txs = await requestTransactionsByHeight(block.height);
Expand Down
8 changes: 8 additions & 0 deletions server/src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export const txConverter = (data) => {
case 'aol/MsgAddRecord':
fromAccount = m.value.owner_address;
break;
case 'did/MsgCreateDID':
case 'did/MsgUpdateDID':
case 'did/MsgDeactivateDID':
fromAccount = m.value.from_address;
break;
case 'token/MsgIssueToken':
fromAccount = m.value.owner_address;
break;
default:
break;
}
Expand Down
10 changes: 5 additions & 5 deletions server/src/utils/requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ const requestTransactionsByHeight = height => axios({
'tx.height': height,
},
url: `${SERVER_URL.http}/txs`,
}).then(({ data }) => data.reduce((acc, tx) => [...acc, ...txConverter(tx)], []));
}).then(({ data }) => data.txs.reduce((acc, tx) => [...acc, ...txConverter(tx)], []));

const requestAccountBalance = address => axios({
method: 'get',
url: `${SERVER_URL.http}/bank/balances/${address}`,
}).then(({ data }) => balanceConverter(data));
}).then(({ data }) => balanceConverter(data.result));

const requestAccountStakingBalance = address => axios({
method: 'get',
url: `${SERVER_URL.http}/staking/delegators/${address}/delegations`,
}).then(({ data }) => stakingConverter(data));
}).then(({ data }) => stakingConverter(data.result));

const requestCandidates = () => axios({
method: 'get',
url: `${SERVER_URL.http}/staking/validators`,
}).then(({ data }) => data);
}).then(({ data }) => data.result);

const requestMedState = () => axios({
method: 'get',
Expand All @@ -53,7 +53,7 @@ const requestMedState = () => axios({
const requestTotalSupply = () => axios({
method: 'get',
url: `${SERVER_URL.http}/staking/pool`,
}).then(res => totalSupplyConverter(res.data));
}).then(res => totalSupplyConverter(res.data.result));

const requestGenesis = () => axios({
method: 'get',
Expand Down

0 comments on commit 86bb813

Please sign in to comment.