diff --git a/server/package.json b/server/package.json index db6d8a9..d780b93 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "explorer_server", - "version": "0.0.1", + "version": "0.0.2", "description": "explorer server", "main": "index.js", "scripts": { diff --git a/server/src/block/handler.js b/server/src/block/handler.js index 5301c4e..7252cc3 100644 --- a/server/src/block/handler.js +++ b/server/src/block/handler.js @@ -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, @@ -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); diff --git a/server/src/converter.js b/server/src/converter.js index 4d369c2..76da14c 100644 --- a/server/src/converter.js +++ b/server/src/converter.js @@ -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; } diff --git a/server/src/utils/requester.js b/server/src/utils/requester.js index ab8633b..71a324e 100644 --- a/server/src/utils/requester.js +++ b/server/src/utils/requester.js @@ -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', @@ -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',