staking enable/diable fixup
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 33s
Details
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 33s
Details
This commit is contained in:
parent
e709a1bc67
commit
5aee8c9314
|
@ -13,4 +13,6 @@ BOT_CRYPTO_STORAGE_PATH="./data/bot-crypto"
|
|||
BOT_INSTANCE_ID=
|
||||
ENABLE_API=
|
||||
ENABLE_MATRIX=
|
||||
ENABLE_STAKING=
|
||||
ENABLE_STAKING=
|
||||
START_PROPOSAL_ID=
|
||||
STOP_PROPOSAL_ID=
|
|
@ -12,6 +12,7 @@ let enableStaking = true;
|
|||
// Subscribe to proposal events
|
||||
const start = async () => {
|
||||
if (ENABLE_STAKING === 'false') {
|
||||
console.log('STAKING DISABLED');
|
||||
enableStaking = false;
|
||||
} else {
|
||||
if (STOP_PROPOSAL_ID) {
|
||||
|
@ -21,16 +22,16 @@ const start = async () => {
|
|||
if (proposal.stage === BigInt(5)) {
|
||||
// Proposal is accepted
|
||||
enableStaking = false;
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is accepted. Not starting.`);
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is accepted. Diabling staking.`);
|
||||
} else if (proposal.stage === BigInt(4)) {
|
||||
// Proposal is failed
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is failed. No effect.`);
|
||||
} else {
|
||||
// Register a ProposalAccepted event handler.
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is stage ${proposal.stage.toString()}. Registering listener.`);
|
||||
const proposalAcceptedHandler = (event) => {
|
||||
if (event.returnValues.proposalIndex === STOP_PROPOSAL_ID) {
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is accepted. Stopping.`);
|
||||
const proposalAcceptedHandler = (proposalIndex) => {
|
||||
if (proposalIndex === STOP_PROPOSAL_ID) {
|
||||
console.log(`STOP_PROPOSAL_ID ${STOP_PROPOSAL_ID} proposal is accepted. Disabling staking.`);
|
||||
enableStaking = false;
|
||||
proposals.off('ProposalAccepted', proposalAcceptedHandler);
|
||||
}
|
||||
|
@ -45,15 +46,16 @@ const start = async () => {
|
|||
if (proposal.stage === BigInt(5)) {
|
||||
// Proposal is accepted
|
||||
enableStaking = true;
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is accepted. Enabling staking.`);
|
||||
} else if (proposal.stage === BigInt(4)) {
|
||||
// Proposal is failed
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is failed. Not starting.`);
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is failed. Disabling staking.`);
|
||||
} else {
|
||||
// Register a ProposalAccepted event handler.
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is stage ${proposal.stage.toString()}. Registering listener.`);
|
||||
const proposalAcceptedHandler = (event) => {
|
||||
if (event.returnValues.proposalIndex === START_PROPOSAL_ID) {
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is accepted. Starting.`);
|
||||
const proposalAcceptedHandler = (proposalIndex) => {
|
||||
if (proposalIndex === START_PROPOSAL_ID) {
|
||||
console.log(`START_PROPOSAL_ID ${START_PROPOSAL_ID} proposal is accepted. Enabling staking.`);
|
||||
enableStaking = true;
|
||||
proposals.off('ProposalAccepted', proposalAcceptedHandler);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue