diff --git a/src/actions/proposals.js b/src/actions/proposals.js index 852865c..9d59feb 100644 --- a/src/actions/proposals.js +++ b/src/actions/proposals.js @@ -55,8 +55,8 @@ export const getProposals = (cb) => (dispatch) => { }, }) .then((res) => { - dispatch(fetchProposalsSuccess(res.data && res.data.proposals)); - cb(res.data && res.data.proposals); + dispatch(fetchProposalsSuccess(res.data)); + cb(res.data); }) .catch((error) => { dispatch(fetchProposalsError( @@ -156,7 +156,7 @@ export const fetchVoteDetails = (id, address) => (dispatch) => { }, }) .then((res) => { - dispatch(fetchVoteDetailsSuccess(res.data && res.data.vote)); + dispatch(fetchVoteDetailsSuccess(res.data)); }) .catch((error) => { dispatch(fetchVoteDetailsError( @@ -244,7 +244,7 @@ export const fetchProposalDetails = (id, cb) => (dispatch) => { }, }) .then((res) => { - dispatch(fetchProposalDetailsSuccess(res.data && res.data.txs, id)); + dispatch(fetchProposalDetailsSuccess(res.data, id)); if (cb) { cb(res); } diff --git a/src/constants/url.js b/src/constants/url.js index 50f47c8..120f1c3 100644 --- a/src/constants/url.js +++ b/src/constants/url.js @@ -9,7 +9,8 @@ export const urlFetchVestingBalance = (address) => `${REST_URL}/cosmos/auth/v1be export const urlFetchUnBondingDelegations = (address) => `${REST_URL}/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`; export const urlFetchRewards = (address) => `${REST_URL}/api/v1/pos/reward/${address}`; -export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${proposalId}/votes/${address}`; +// export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/api/v1/gov/voter/${proposalId}/votes/${address}` +export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/api/v1/gov/voter/${address}/votes`; export const urlFetchRevealedPubkey = (address) => `${REST_URL}/api/v1/revealed-public-key/${address}`; export const VALIDATORS_LIST_URL = () => `${REST_URL}/api/v1/pos/validator/all?state=consensus`; @@ -17,10 +18,10 @@ export const GENESIS_VALIDATORS_LIST_URL = 'https://namada.info/shielded-expedit export const INACTIVE_VALIDATORS_URL = `${REST_URL}/api/v1/pos/validator/all?state=belowCapacity&state=belowThreshold&state=inactive&state=jailed&state=unknown`; export const INACTIVE_VALIDATORS_UNBONDING_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000&status=BOND_STATUS_UNBONDING`; export const getValidatorURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/validators/${address}`; -export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1/proposals?pagination.limit=1000`; +export const PROPOSALS_LIST_URL = `${REST_URL}/api/v1/gov/proposal/all`; export const getDelegatedValidatorsURL = (address) => `${REST_URL}/api/v1/pos/bond/${address}`; 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/gov/v1/proposals/${id}`; +export const urlFetchProposalDetails = (id) => `${REST_URL}/api/v1/gov/proposal/${id}`; export const validatorImageURL = (id) => `https://keybase.io/_/api/1.0/user/lookup.json?fields=pictures&key_suffix=${id}`; diff --git a/src/containers/Home/ClaimDialog/index.js b/src/containers/Home/ClaimDialog/index.js index 3569bff..72c928d 100644 --- a/src/containers/Home/ClaimDialog/index.js +++ b/src/containers/Home/ClaimDialog/index.js @@ -25,44 +25,32 @@ const ClaimDialog = (props) => { const handleClaimAll = () => { setInProgress(true); - let gasValue = gas.claim_reward; - if (props.rewards && props.rewards.rewards && props.rewards.rewards.length > 1) { - gasValue = props.rewards.rewards.length * gas.claim_reward / 1.1 + gas.claim_reward; + let gasValue = 1; + if (props.rewards && props.rewards.length) { + gasValue = props.rewards.length; } - const updatedTx = { - msgs: [], - fee: { - amount: [{ - amount: String(gasValue * config.GAS_PRICE_STEP_AVERAGE), - denom: config.COIN_MINIMAL_DENOM, - }], - gas: String(gasValue), - }, - memo: '', + const txs = { + token: config.TOKEN_ADDRESS, + feeAmount: new BigNumber(0.000010 * gasValue), + gasLimit: new BigNumber(50000 * gasValue), + chainId: config.CHAIN_ID, + publicKey: props.details && props.details.publicKey, }; - - if (props.rewards && props.rewards.rewards && - props.rewards.rewards.length) { - props.rewards.rewards.map((item) => { - updatedTx.msgs.push({ - typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', - value: { - delegatorAddress: props.address, - validatorAddress: item.validator_address, - }, + + const msg = []; + if (props.rewards && props.rewards.length) { + props.rewards.map((item) => { + msg.push({ + source: props.address, + validator: item.validator && item.validator.address, }); return null; }); } - if (localStorage.getItem('of_co_wallet') === 'cosmostation') { - cosmoStationSign(updatedTx, props.address, handleFetch); - return; - } - - signTxAndBroadcast(updatedTx, props.address, handleFetch); + claimTransaction(msg, txs, props.details && props.details.type, handleFetch); }; const handleFetch = (error, result) => { diff --git a/src/containers/Home/index.js b/src/containers/Home/index.js index 0ec0092..f11c594 100644 --- a/src/containers/Home/index.js +++ b/src/containers/Home/index.js @@ -11,8 +11,8 @@ import ClaimDialog from './ClaimDialog'; import ClaimDelegateDialog from './ClaimDialog/ClaimDelegateDialog'; import Table from '../Stake/Table'; import { Button } from '@material-ui/core'; -// import Cards from '../Proposals/Cards'; -// import ProposalDialog from '../Proposals/ProposalDialog'; +import Cards from '../Proposals/Cards'; +import ProposalDialog from '../Proposals/ProposalDialog'; import { connect } from 'react-redux'; import PendingDialog from '../Stake/DelegateDialog/PendingDialog'; // import MultiDelegateButton from '../Stake/MultiDelegateButton'; @@ -75,8 +75,8 @@ class Home extends Component { render () { const { active } = this.state; - // const filteredProposals = this.props.proposals && this.props.proposals.filter((item) => item.status === 2 || - // item.status === 'PROPOSAL_STATUS_VOTING_PERIOD'); + const filteredProposals = this.props.proposals && this.props.proposals.filter((item) => item.status === 2 || + item.status === 'voting'); return ( <> @@ -139,7 +139,7 @@ class Home extends Component {