Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARD-1135: Fix State Status in case of active node #41

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 50 additions & 8 deletions src/node-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,24 @@ export function registerNodeCommands(program: Command) {
reason: 'Could not fetch data',
remainingTime: -1,
};
if (accountInfo.nominator) {
const eoaData = await fetchEOADetails(config, accountInfo.nominator);

if (eoaData) {
const unstakableData = await fetchUnstakeableDetails(
if (descriptions.length === 0) {
if (accountInfo.nominator) {
const eoaData = await fetchEOADetails(
config,
publicKey,
accountInfo.nominator
);
unstakable = unstakableData ?? unstakable;

if (eoaData) {
const unstakableData = await fetchUnstakeableDetails(
config,
publicKey,
accountInfo.nominator
);
unstakable = unstakableData ?? unstakable;
}
}
}
if (descriptions.length === 0) {

// Node process not started
console.log(
yaml.dump({
Expand Down Expand Up @@ -379,6 +384,30 @@ export function registerNodeCommands(program: Command) {
nodeStatus =
lockedStakeStr === '0.0' ? 'need-stake' : 'waiting-for-network';

if (nodeStatus === 'active') {
unstakable = {
unlocked: false,
reason: 'Node is active',
remainingTime: -1,
};
} else {
if (accountInfo.nominator) {
const eoaData = await fetchEOADetails(
config,
accountInfo.nominator
);

if (eoaData) {
const unstakableData = await fetchUnstakeableDetails(
config,
publicKey,
accountInfo.nominator
);
unstakable = unstakableData ?? unstakable;
}
}
}

console.log(
yaml.dump({
state: nodeStatus,
Expand Down Expand Up @@ -412,6 +441,19 @@ export function registerNodeCommands(program: Command) {
}

// Node was started but is currently inactive
if (accountInfo.nominator) {
const eoaData = await fetchEOADetails(config, accountInfo.nominator);

if (eoaData) {
const unstakableData = await fetchUnstakeableDetails(
config,
publicKey,
accountInfo.nominator
);
unstakable = unstakableData ?? unstakable;
}
}

console.log(
yaml.dump({
state: 'stopped',
Expand Down
Loading