Skip to content

Commit

Permalink
claim all transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Dec 16, 2024
2 parents 4553f5b + 2a20d71 commit b7571a1
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 307 deletions.
8 changes: 4 additions & 4 deletions src/actions/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions src/constants/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ 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`;
export const GENESIS_VALIDATORS_LIST_URL = 'https://namada.info/shielded-expedition.88f17d1d14/output/genesis_tm_address_to_alias.json';
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}`;
46 changes: 17 additions & 29 deletions src/containers/Home/ClaimDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 6 additions & 6 deletions src/containers/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -139,7 +139,7 @@ class Home extends Component {
<Table active={active} home={true}/>
</div>
</div>
{/* <div className="proposals">
<div className="proposals">
{!this.props.open
? <div className="proposals_content padding">
<div className="heading">
Expand All @@ -159,7 +159,7 @@ class Home extends Component {
: <div className="cards_content">{variables[this.props.lang]['no_data_found']}</div>}
</div>
: <ProposalDialog/>}
</div> */}
</div>
<DelegateDialog/>
<SuccessDialog/>
<UnSuccessDialog/>
Expand Down
14 changes: 7 additions & 7 deletions src/containers/NavBar/ConnectDialog/NamadaConnectButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ const KeplrConnectButton = (props) => {
props.setAccountDetails(addressList);
props.hideConnectDialog();
// if (!props.proposalTab && !props.stake) {
// props.getUnBondingDelegations(addressList[0] && addressList[0].address);
// props.fetchRewards(addressList[0] && addressList[0].address);
// props.getUnBondingDelegations(addressList && addressList.address);
// props.fetchRewards(addressList && addressList.address);
// }
if (!props.proposalTab) {
props.getDelegations(addressList[0] && addressList[0].address);
props.getDelegations(addressList && addressList.address);
}
props.getBalance(addressList[0] && addressList[0].address);
// props.fetchVestingBalance(addressList[0] && addressList[0].address);
props.getBalance(addressList && addressList.address);
// props.fetchVestingBalance(addressList && addressList.address);
// if (!props.proposalTab) {
// props.getDelegatedValidatorsDetails(addressList[0] && addressList[0].address);
// props.getDelegatedValidatorsDetails(addressList && addressList.address);
// }
localStorage.setItem('of_co_address', encode(addressList[0] && addressList[0].address));
localStorage.setItem('of_co_address', encode(addressList && addressList.address));
localStorage.setItem('of_co_wallet', 'namada');
});
};
Expand Down
100 changes: 50 additions & 50 deletions src/containers/NavBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,53 +78,53 @@ class NavBar extends Component {
}, 600);
}

// if (this.props.proposals && !this.props.proposals.length &&
// !this.props.proposalsInProgress && !this.props.stake &&
// this.props.router && this.props.router.params && !this.props.router.params.proposalID) {
// this.props.getProposals((result) => {
// if (result && result.length) {
// const array = [];
// result.map((val) => {
// const filter = this.props.proposalDetails && Object.keys(this.props.proposalDetails).length &&
// Object.keys(this.props.proposalDetails).find((key) => key === val.proposal_id);
// if (!filter) {
// if (this.props.home && (val.status !== 'PROPOSAL_STATUS_VOTING_PERIOD')) {
// return null;
// }
//
// array.push(val.proposal_id);
// }
// if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
// this.props.fetchProposalTally(val.id);
// }
//
// return null;
// });
// this.getProposalDetails(array && array.reverse());
// }
// });
// } else if (this.props.proposals && !this.props.proposalsInProgress && !this.props.stake &&
// this.props.proposalDetails && Object.keys(this.props.proposalDetails).length === 1 &&
// this.props.router && this.props.router.params && !this.props.router.params.proposalID) {
// const array = [];
// this.props.proposals.map((val) => {
// const filter = this.props.proposalDetails && Object.keys(this.props.proposalDetails).length &&
// Object.keys(this.props.proposalDetails).find((key) => key === val.proposal_id);
// if (!filter) {
// if (this.props.home && (val.status !== 'PROPOSAL_STATUS_VOTING_PERIOD')) {
// return null;
// }
//
// array.push(val.proposal_id);
// }
// if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
// this.props.fetchProposalTally(val.id);
// }
//
// return null;
// });
// this.getProposalDetails(array && array.reverse());
// }
if (this.props.proposals && !this.props.proposals.length &&
!this.props.proposalsInProgress && !this.props.stake &&
this.props.router && this.props.router.params && !this.props.router.params.proposalID) {
this.props.getProposals((result) => {
if (result && result.length) {
// const array = [];
// result.map((val) => {
// const filter = this.props.proposalDetails && Object.keys(this.props.proposalDetails).length &&
// Object.keys(this.props.proposalDetails).find((key) => key === val.proposal_id);
// if (!filter) {
// if (this.props.home && (val.status !== 'PROPOSAL_STATUS_VOTING_PERIOD')) {
// return null;
// }

// array.push(val.proposal_id);
// }
// if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
// this.props.fetchProposalTally(val.id);
// }

// return null;
// });
// this.getProposalDetails(array && array.reverse());
}
});
} else if (this.props.proposals && !this.props.proposalsInProgress && !this.props.stake &&
this.props.proposalDetails && Object.keys(this.props.proposalDetails).length === 1 &&
this.props.router && this.props.router.params && !this.props.router.params.proposalID) {
const array = [];
this.props.proposals.map((val) => {
const filter = this.props.proposalDetails && Object.keys(this.props.proposalDetails).length &&
Object.keys(this.props.proposalDetails).find((key) => key === val.proposal_id);
if (!filter) {
if (this.props.home && (val.status !== 'PROPOSAL_STATUS_VOTING_PERIOD')) {
return null;
}

array.push(val.proposal_id);
}
if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
this.props.fetchProposalTally(val.id);
}

return null;
});
this.getProposalDetails(array && array.reverse());
}

if (this.props.address) {
this.handleFetch(this.props.address);
Expand Down Expand Up @@ -182,7 +182,7 @@ class NavBar extends Component {
const votedOption = this.props.voteDetails && this.props.voteDetails.length && val && val.proposal_id &&
this.props.voteDetails.filter((vote) => vote.proposal_id === val.proposal_id)[0];

if ((val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') &&
if ((val.status === 2 || val.status === 'voting') &&
!votedOption && this.props.address) {
this.props.fetchVoteDetails(val.id, this.props.address);
}
Expand All @@ -206,14 +206,14 @@ class NavBar extends Component {

array.push(val.proposal_id);
}
if (val.status === 2 || val.status === 'PROPOSAL_STATUS_VOTING_PERIOD') {
if (val.status === 2 || val.status === 'voting') {
this.props.fetchProposalTally(val.id);
this.props.fetchVoteDetails(val.id, this.props.address);
}

return null;
});
this.getProposalDetails(array && array.reverse());
// this.getProposalDetails(array && array.reverse());
}
});
}
Expand Down
Loading

0 comments on commit b7571a1

Please sign in to comment.