diff --git a/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js b/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js index ef9dffa..5f8c361 100644 --- a/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js +++ b/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js @@ -17,19 +17,35 @@ const ToValidatorSelectField = (props) => { props.onChange(value); }; + let validatorList = []; + if (props.validatorList && props.validatorList.length) { + props.validatorList.map((val) => { + if (val && val.name && val.name.toLowerCase() === 'cosmic validator') { + validatorList.splice(0, 0, val); + } else if (val && val.name && val.name.toLowerCase() === 'mandragora') { + const find = validatorList.find((val1) => val1 && val1.name && val1.name.toLowerCase() === 'cosmic validator'); + if (!find) { + validatorList.splice(0, 0, val); + } else { + validatorList.splice(1, 0, val); + } + } else { + validatorList.push(val); + } + }); + } else { + validatorList = dataToMap; + } + return ( - {props.validatorList && props.validatorList.length && - props.validatorList.map((item, index) => { - const image = item && item.description && item.description.identity && - props.validatorImages && props.validatorImages.length && - props.validatorImages.filter((value) => value._id === item.description.identity.toString()); - + {validatorList && validatorList.length && + validatorList.map((item, index) => { return ( props.removeValue !== item.operator_address && { txs.gasLimit = new BigNumber(100000); reDelegateTransaction(tx, txs, props.details && props.details.type, handleFetch); } else { - delegateTransaction(tx, txs, props.revealPublicKey, handleFetch); + delegateTransaction(tx, txs, props.revealPublicKey, props.details && props.details.type, handleFetch); } }; @@ -222,6 +222,8 @@ const DelegateDialog = (props) => { }, 4000); // props.fetchVestingBalance(props.address); props.getDelegations(props.address); + props.fetchRewards(props.address); + props.getDelegatedValidatorsDetails(props.address); // props.getUnBondingDelegations(props.address); // props.getDelegatedValidatorsDetails(props.address); // props.fetchRewards(props.address); diff --git a/src/helper.js b/src/helper.js index fb4214c..fb01ca7 100644 --- a/src/helper.js +++ b/src/helper.js @@ -285,7 +285,7 @@ export const initializeNamadaChain = (cb) => { // })(); // }; -export const delegateTransaction = (Tx, txs, revealPublicKey, cb) => { +export const delegateTransaction = (Tx, txs, revealPublicKey, type, cb) => { (async () => { const isExtensionInstalled = typeof window.namada === 'object'; if (!isExtensionInstalled || !window.namada) { @@ -341,7 +341,13 @@ export const delegateTransaction = (Tx, txs, revealPublicKey, cb) => { const encoded = await tx.buildBond(wrapperTxValue, bondMsgValue); newTxs.push(encoded); - const updateDate = tx.buildBatch(newTxs); + // const updateDate = tx.buildBatch(newTxs); + let updateDate; + if (type === 'ledger') { + updateDate = newTxs; + } else { + updateDate = tx.buildBatch(newTxs); + } // const checksums = { // "tx_become_validator.wasm": "c6629064a1c3bde8503212cfa5e9b954169a7f162ad411b63a71db782fe909d7", @@ -361,6 +367,7 @@ export const delegateTransaction = (Tx, txs, revealPublicKey, cb) => { client.sign(updateDate, Tx.source, checksums).then((signedBondTxBytes) => { rpc.broadcastTx(signedBondTxBytes && signedBondTxBytes.length && signedBondTxBytes[0], wrapperProps).then((result) => { + console.log('result', result); if (result && result.code !== undefined && result.code !== 0 && result.code !== '0') { cb(result.info || result.log || result.rawLog); } else {