Skip to content

Commit

Permalink
cosmos sdk v46 rest api updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Jan 30, 2023
1 parent 33298fb commit b0c6d1c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 43 deletions.
8 changes: 4 additions & 4 deletions src/actions/accounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const getDelegations = (address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchDelegationsSuccess(res.data && res.data.result));
dispatch(fetchDelegationsSuccess(res.data && res.data.delegation_responses));
})
.catch((error) => {
dispatch(fetchDelegationsError(
Expand Down Expand Up @@ -107,7 +107,7 @@ export const getBalance = (address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchBalanceSuccess(res.data && res.data.result));
dispatch(fetchBalanceSuccess(res.data && res.data.balances));
})
.catch((error) => {
dispatch(fetchBalanceError(
Expand Down Expand Up @@ -203,7 +203,7 @@ export const getUnBondingDelegations = (address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchUnBondingDelegationsSuccess(res.data && res.data.result));
dispatch(fetchUnBondingDelegationsSuccess(res.data && res.data.unbonding_responses));
})
.catch((error) => {
dispatch(fetchUnBondingDelegationsError(
Expand Down Expand Up @@ -252,7 +252,7 @@ export const fetchRewards = (address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchRewardsSuccess(res.data && res.data.result));
dispatch(fetchRewardsSuccess(res.data));
})
.catch((error) => {
dispatch(fetchRewardsError(
Expand Down
6 changes: 3 additions & 3 deletions src/actions/stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getValidators = (cb) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchValidatorsSuccess(res.data && res.data.result));
dispatch(fetchValidatorsSuccess(res.data && res.data.validators));
cb(res.data && res.data.result);
})
.catch((error) => {
Expand Down Expand Up @@ -182,7 +182,7 @@ export const getValidatorDetails = (address, cb) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchValidatorSuccess(res.data && res.data.result));
dispatch(fetchValidatorSuccess(res.data && res.data.validators));
cb(res.data && res.data.result);
})
.catch((error) => {
Expand Down Expand Up @@ -226,7 +226,7 @@ export const getDelegatedValidatorsDetails = (address) => (dispatch) => {
},
})
.then((res) => {
dispatch(fetchDelegatedValidatorsSuccess(res.data && res.data.result));
dispatch(fetchDelegatedValidatorsSuccess(res.data && res.data.validators));
})
.catch((error) => {
dispatch(fetchDelegatedValidatorsError(
Expand Down
24 changes: 12 additions & 12 deletions src/constants/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { config } from '../config';
export const REST_URL = config.REST_URL;
export const RPC_URL = config.RPC_URL;

export const urlFetchDelegations = (address) => `${REST_URL}/staking/delegators/${address}/delegations`;
export const urlFetchBalance = (address) => `${REST_URL}/bank/balances/${address}`;
export const urlFetchVestingBalance = (address) => `${REST_URL}/auth/accounts/${address}`;
export const urlFetchUnBondingDelegations = (address) => `${REST_URL}/staking/delegators/${address}/unbonding_delegations`;
export const urlFetchDelegations = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegations/${address}`;
export const urlFetchBalance = (address) => `${REST_URL}/cosmos/bank/v1beta1/balances/${address}`;
export const urlFetchVestingBalance = (address) => `${REST_URL}/cosmos/auth/v1beta1/accounts/${address}`;
export const urlFetchUnBondingDelegations = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`;

export const urlFetchRewards = (address) => `${REST_URL}/distribution/delegators/${address}/rewards`;
export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/gov/proposals/${proposalId}/votes/${address}`;
export const urlFetchRewards = (address) => `${REST_URL}/cosmos/distribution/v1beta1/delegators/${address}/rewards`;
export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${proposalId}/votes/${address}`;

export const VALIDATORS_LIST_URL = `${REST_URL}/staking/validators`;
export const getValidatorURL = (address) => `${REST_URL}/staking/validators/${address}`;
export const VALIDATORS_LIST_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000`;
export const getValidatorURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/validators/${address}`;
export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1beta1/proposals?pagination.limit=1000`;
export const getDelegatedValidatorsURL = (address) => `${REST_URL}/staking/delegators/${address}/validators`;
export const urlFetchProposalVotes = (id) => `${REST_URL}/gov/proposals/${id}/votes`;
export const urlFetchTallyDetails = (id) => `${REST_URL}/gov/proposals/${id}/tally`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/txs?message.module=governance&submit_proposal.proposal_id=${id}`;
export const getDelegatedValidatorsURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/validators`;
export const urlFetchProposalVotes = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/votes`;
export const urlFetchTallyDetails = (id) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${id}/tally`;
export const urlFetchProposalDetails = (id) => `${REST_URL}/cosmos/tx/v1beta1/txs?events=submit_proposal.proposal_id=${id}`;

export const validatorImageURL = (id) => `https://keybase.io/_/api/1.0/user/lookup.json?fields=pictures&key_suffix=${id}`;
11 changes: 5 additions & 6 deletions src/containers/Proposals/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ const Cards = (props) => {
if (key === proposal.proposal_id) {
if (props.proposalDetails[key] &&
props.proposalDetails[key][0] &&
props.proposalDetails[key][0].tx &&
props.proposalDetails[key][0].tx.value &&
props.proposalDetails[key][0].tx.value.msg[0] &&
props.proposalDetails[key][0].tx.value.msg[0].value &&
props.proposalDetails[key][0].tx.value.msg[0].value.proposer) {
proposer = props.proposalDetails[key][0].tx.value.msg[0].value.proposer;
props.proposalDetails[key][0].body &&
props.proposalDetails[key][0].body.messages &&
props.proposalDetails[key][0].body.messages.length &&
props.proposalDetails[key][0].body.messages[0].proposer) {
proposer = props.proposalDetails[key][0].body.messages[0].proposer;
}
}

Expand Down
19 changes: 11 additions & 8 deletions src/containers/Proposals/ProposalDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ class ProposalDialog extends Component {
if (this.props.proposal && key === this.props.proposal.proposal_id) {
if (this.props.proposalDetails[key] &&
this.props.proposalDetails[key][0] &&
this.props.proposalDetails[key][0].tx &&
this.props.proposalDetails[key][0].tx.value &&
this.props.proposalDetails[key][0].tx.value.msg[0] &&
this.props.proposalDetails[key][0].tx.value.msg[0].value &&
this.props.proposalDetails[key][0].tx.value.msg[0].value.proposer) {
proposer = this.props.proposalDetails[key][0].tx.value.msg[0].value.proposer;
this.props.proposalDetails[key][0].body &&
this.props.proposalDetails[key][0].body.messages &&
this.props.proposalDetails[key][0].body.messages.length &&
this.props.proposalDetails[key][0].body.messages[0] &&
this.props.proposalDetails[key][0].body.messages[0].proposer) {
proposer = this.props.proposalDetails[key][0].body.messages[0].proposer;
}
}

Expand Down Expand Up @@ -205,7 +205,7 @@ class ProposalDialog extends Component {
<p className="pds3l_c1">Voting Status</p>
<div className={ClassNames('pds3l_c2 vote_details',
this.props.proposal && (this.props.proposal.status === 2 ||
this.props.proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') ? 'vote_in_progress' : '')}>
this.props.proposal.status === 'PROPOSAL_STATUS_VOTING_PERIOD') ? 'vote_in_progress' : '')}>
<div className="yes">
<span/>
<p>YES ({this.VoteCalculation('yes')})</p>
Expand All @@ -227,7 +227,10 @@ class ProposalDialog extends Component {
<div className="pds3l_c">
<p className="pds3l_c1">Type</p>
<p className="pds3l_c2 type">{this.props.proposal && this.props.proposal.content &&
this.props.proposal.content.type}</p>
this.props.proposal.content.type
? this.props.proposal.content.type
: this.props.proposal && this.props.proposal.content && this.props.proposal.content['@type']
? this.props.proposal.content['@type'] : null}</p>
</div>
</div>
{this.props.proposal && (this.props.proposal.status === 2 ||
Expand Down
6 changes: 3 additions & 3 deletions src/containers/Proposals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const Proposals = (props) => {

setActive(value);
setFilter(value === null ? 2
: value === 2 ? 3
: value === 3 ? 2
: value === 4 ? 4 : null);
: value === 2 ? 'PROPOSAL_STATUS_PASSED'
: value === 3 ? 'PROPOSAL_STATUS_VOTING_PERIOD'
: value === 4 ? 'PROPOSAL_STATUS_REJECTED' : null);
};
const filteredProposals = filter ? props.proposals.filter((item) => item.status === filter) : props.proposals;

Expand Down
16 changes: 10 additions & 6 deletions src/containers/Stake/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ class Table extends Component {
customBodyRender: (value) => (
<div
className={classNames('status', value.jailed ? 'red_status' : '')}
title={value.status === 1 ? 'unbonded'
: value.status === 2 ? 'unbonding'
: value.status === 3 ? 'active' : ''}>
{value.status === 1 ? 'unbonded'
: value.status === 2 ? 'unbonding'
: value.status === 3 ? 'active' : ''}
title={value.status === 'BOND_STATUS_UNBONDED' ? 'unbonded'
: value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
: value.status === 'BOND_STATUS_BONDED' ? 'active'
: value.status === 'BOND_STATUS_UNSPECIFIED' ? 'invalid'
: ''}>
{value.status === 'BOND_STATUS_UNBONDED' ? 'unbonded'
: value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
: value.status === 'BOND_STATUS_BONDED' ? 'active'
: value.status === 'BOND_STATUS_UNSPECIFIED' ? 'invalid'
: ''}
</div>
),
},
Expand Down
2 changes: 1 addition & 1 deletion src/defaultGasValues.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const gas = {
send: 80000,
vote: 80000,
delegate: 180000,
delegate: 200000,
un_delegate: 200000,
re_delegate: 300000,
claim_reward: 140000,
Expand Down

0 comments on commit b0c6d1c

Please sign in to comment.