Skip to content

Commit

Permalink
ledger transactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Dec 6, 2024
1 parent 8c6aaff commit eec42b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
30 changes: 23 additions & 7 deletions src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<SelectField
id="validator_select_field"
items={props.validatorList}
items={validatorList}
name="validators"
value={props.value}
onChange={handleChange}>
{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 && <MenuItem
key={item.key || item.value || item.name || item.address || item.type ||
Expand Down
4 changes: 3 additions & 1 deletion src/containers/Stake/DelegateDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const DelegateDialog = (props) => {
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);
}
};

Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand All @@ -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 {
Expand Down

0 comments on commit eec42b6

Please sign in to comment.