Migrate node when events pending (#5125)
* dont show node migration if there are vesting tokens * catch and set errors
This commit is contained in:
@@ -113,6 +113,7 @@ export const BondedGateway = ({
|
||||
startIcon={<UpgradeRounded />}
|
||||
variant="contained"
|
||||
disableElevation
|
||||
disabled={!!gateway.proxy}
|
||||
onClick={onShowMigrateToNymNodeModal}
|
||||
>
|
||||
Migrate to Nym Node
|
||||
|
||||
@@ -190,15 +190,21 @@ export const BondedMixnode = ({
|
||||
</Button>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
<Button
|
||||
startIcon={<UpgradeRounded />}
|
||||
variant="contained"
|
||||
disableElevation
|
||||
onClick={onShowMigrateToNymNodeModal}
|
||||
disabled={isUnbonding}
|
||||
<Tooltip
|
||||
title={!!mixnode.proxy && 'You must migrate your vested tokens before you can migrate your mixnode'}
|
||||
>
|
||||
Migrate to Nym Node
|
||||
</Button>
|
||||
<Box>
|
||||
<Button
|
||||
startIcon={<UpgradeRounded />}
|
||||
variant="contained"
|
||||
disableElevation
|
||||
onClick={onShowMigrateToNymNodeModal}
|
||||
disabled={isUnbonding || !!mixnode.proxy}
|
||||
>
|
||||
Migrate to Nym Node
|
||||
</Button>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
|
||||
{nextEpoch instanceof Error ? null : (
|
||||
|
||||
@@ -217,24 +217,34 @@ export const BondingContextProvider: FCWithChildren = ({ children }): JSX.Elemen
|
||||
|
||||
const migrateVestedMixnode = async () => {
|
||||
setIsLoading(true);
|
||||
const tx = await tauriMigrateVestedMixnode();
|
||||
setIsLoading(false);
|
||||
return tx;
|
||||
try {
|
||||
const tx = await tauriMigrateVestedMixnode();
|
||||
setIsLoading(false);
|
||||
return tx;
|
||||
} catch (e) {
|
||||
Console.error(e);
|
||||
setError(`an error occurred: ${e}`);
|
||||
}
|
||||
};
|
||||
|
||||
const migrateLegacyNode = async () => {
|
||||
setIsLoading(true);
|
||||
let tx: TransactionExecuteResult | undefined;
|
||||
try {
|
||||
let tx: TransactionExecuteResult | undefined;
|
||||
|
||||
if (bondedNode && isMixnode(bondedNode)) {
|
||||
tx = await migrateLegacyMixnodeReq();
|
||||
}
|
||||
if (bondedNode && isGateway(bondedNode)) {
|
||||
tx = await migrateLegacyGatewayReq();
|
||||
if (bondedNode && isMixnode(bondedNode)) {
|
||||
tx = await migrateLegacyMixnodeReq();
|
||||
}
|
||||
if (bondedNode && isGateway(bondedNode)) {
|
||||
tx = await migrateLegacyGatewayReq();
|
||||
}
|
||||
return tx;
|
||||
} catch (e) {
|
||||
Console.error(e);
|
||||
setError(`an error occurred: ${e}`);
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
return tx;
|
||||
};
|
||||
|
||||
const memoizedValue = useMemo(
|
||||
|
||||
@@ -53,7 +53,7 @@ export const Bonding = () => {
|
||||
if (!bondedNode) {
|
||||
return false;
|
||||
}
|
||||
if (isMixnode(bondedNode) && !bondedNode.isUnbonding) {
|
||||
if (isMixnode(bondedNode) && !bondedNode.isUnbonding && !bondedNode.proxy) {
|
||||
return true;
|
||||
}
|
||||
if (isGateway(bondedNode)) {
|
||||
@@ -197,7 +197,14 @@ export const Bonding = () => {
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return <ErrorModal open message="An error occured, please check logs for details" onClose={() => refresh()} />;
|
||||
return (
|
||||
<ErrorModal
|
||||
open
|
||||
title="An error occured, please check logs for details"
|
||||
message={error}
|
||||
onClose={() => refresh()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user