Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('continue retirement and shows continue dialog for ATLAS with bundles', async () => {
onboardMock.rolesWrapper.onboardedRole.resolves(constants.ATLAS),
onboardMock.atlasStakeWrapper.isShelteringAny.resolves(true),
atlasModeModelMock.getMode.resolves({mode:'retire'}),
continueAtlasRetirementDialogStub.resolves({continueConfirmation: true});
expect(await retireActionCall()).to.be.true;
expect(retirementContinueDialogStub).to.be.calledOnce;
});
it('immediately returns false if confirmation was negative for ATLAS without bundles', async () => {
onboardMock.rolesWrapper.onboardedRole.resolves(constants.ATLAS),
confirmRetirementDialogStub.resolves({retirementConfirmation: false});
expect(await retireActionCall()).to.be.false;
expect(onboardMock.retire).to.be.not.called;
});
beforeEach(() => {
confirmRetirementDialogStub = sinon.stub().resolves({retirementConfirmation: true});
retirementSuccessfulDialogStub = sinon.stub().resolves();
continueAtlasRetirementDialogStub = sinon.stub().resolves({atlasRetirementConfirmation: true});
retirementStartSuccessfulDialogStub = sinon.stub().resolves();
retirementContinueDialogStub = sinon.stub().resolves();
retirementStopDialogStub = sinon.stub().resolves();
genericErrorDialogStub = sinon.stub().resolves();
atlasModeModelMock = {
getMode: sinon.stub().resolves({mode:'normal'}),
setMode: sinon.stub().resolves(true)
};
onboardMock = {
rolesWrapper: {
onboardedRole: sinon.stub().resolves(constants.APOLLO),
defaultAddress: '0x1234'
},
atlasStakeWrapper: {
isShelteringAny: sinon.stub().resolves(false),
defaultAddress: '0x1234'
},
retire: sinon.stub().resolves()
};
retireActionCall = retireAction(
atlasModeModelMock,
onboardMock,
confirmRetirementDialogStub,
retirementSuccessfulDialogStub,
continueAtlasRetirementDialogStub,
retirementStartSuccessfulDialogStub,
retirementContinueDialogStub,
objects.actions = {
[messages.actions.changeUrl]: prepareAction(changeUrlAction(
objects.stateModel,
objects.rolesWrapper,
objects.nectarWarningDialog,
objects.askForNodeUrlDialog,
objects.changeUrlConfirmationDialog,
objects.changeUrlSuccessfulDialog),
[constants.ATLAS, constants.HERMES]
),
[messages.actions.payouts]: prepareAction(payoutAction(
objects.payoutsActions,
objects.availablePayoutDialog,
objects.confirmPayoutWithdrawalDialog,
objects.withdrawalSuccessfulDialog),
[constants.ATLAS]
),
[messages.actions.retire]: prepareAction(retireAction(
objects.atlasModeModel,
objects.onboardActions,
objects.confirmRetirementDialog,
objects.retirementSuccessfulDialog,
objects.continueAtlasRetirementDialog,
objects.retirementStartSuccessfulDialog,
objects.retirementContinueDialog,
objects.retirementStopDialog,
objects.genericErrorDialog
)),
[messages.actions.quit]: prepareAction(quitAction())
};
objects.selectActionPhase = selectActionPhase(
const isAtlasWithBundles = async (onboardActions) => {
const role = await onboardActions.rolesWrapper.onboardedRole(onboardActions.rolesWrapper.defaultAddress);
if (role === constants.ATLAS) {
return await onboardActions.atlasStakeWrapper.isShelteringAny(onboardActions.atlasStakeWrapper.defaultAddress);
}
return false;
};
/*
Copyright: Ambrosus Inc.
Email: tech@ambrosus.com
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
*/
import {constants} from 'ambrosus-node-contracts';
export const APOLLO_CODE = constants.APOLLO;
export const HERMES_CODE = constants.HERMES;
export const ATLAS_CODE = constants.ATLAS;
export const NO_ROLE_CODE = constants.NONE;
export const ATLAS_1_STAKE = constants.ATLAS1_STAKE;
export const ATLAS_2_STAKE = constants.ATLAS2_STAKE;
export const ATLAS_3_STAKE = constants.ATLAS3_STAKE;
export const APOLLO = 'Apollo';
export const HERMES = 'Hermes';
export const ATLAS_1 = 'Atlas Zeta';
export const ATLAS_2 = 'Atlas Sigma';
export const ATLAS_3 = 'Atlas Omega';
/*
Copyright: Ambrosus Inc.
Email: tech@ambrosus.com
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
*/
import {constants} from 'ambrosus-node-contracts';
export const APOLLO_CODE = constants.APOLLO;
export const HERMES_CODE = constants.HERMES;
export const ATLAS_CODE = constants.ATLAS;
export const NO_ROLE_CODE = constants.NONE;
export const ATLAS_1_STAKE = constants.ATLAS1_STAKE;
export const ATLAS_2_STAKE = constants.ATLAS2_STAKE;
export const ATLAS_3_STAKE = constants.ATLAS3_STAKE;
export const APOLLO = 'Apollo';
export const HERMES = 'Hermes';
export const ATLAS_1 = 'Atlas Zeta';
export const ATLAS_2 = 'Atlas Sigma';
export const ATLAS_3 = 'Atlas Omega';
/*
Copyright: Ambrosus Inc.
Email: tech@ambrosus.com
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
*/
import {constants} from 'ambrosus-node-contracts';
export const APOLLO_CODE = constants.APOLLO;
export const HERMES_CODE = constants.HERMES;
export const ATLAS_CODE = constants.ATLAS;
export const NO_ROLE_CODE = constants.NONE;
export const ATLAS_1_STAKE = constants.ATLAS1_STAKE;
export const ATLAS_2_STAKE = constants.ATLAS2_STAKE;
export const ATLAS_3_STAKE = constants.ATLAS3_STAKE;
export const APOLLO = 'Apollo';
export const HERMES = 'Hermes';
export const ATLAS_1 = 'Atlas Zeta';
export const ATLAS_2 = 'Atlas Sigma';
export const ATLAS_3 = 'Atlas Omega';
objects.checkAddressWhitelistingStatusPhase = checkAddressWhitelistingStatusPhase(objects.smartContractsModel, objects.stateModel, objects.addressIsNotWhitelistedDialog, objects.addressIsWhitelistedDialog);
objects.performOnboardingPhase = performOnboardingPhase(objects.stateModel, objects.smartContractsModel,
objects.notEnoughBalanceDialog, objects.alreadyOnboardedDialog, objects.askForApolloDepositDialog, objects.onboardingConfirmationDialog,
objects.onboardingSuccessfulDialog, objects.insufficientFundsDialog, objects.genericErrorDialog);
objects.prepareDockerPhase = prepareDockerPhase(objects.stateModel, objects.healthCheckUrlDialog, objects.dockerComposeCommandDialog);
objects.acceptTosPhase = acceptTosPhase(objects.stateModel, objects.smartContractsModel, objects.acceptTosDialog);
objects.actions = {
[messages.actions.changeUrl]: prepareAction(changeUrlAction(
objects.stateModel,
objects.rolesWrapper,
objects.nectarWarningDialog,
objects.askForNodeUrlDialog,
objects.changeUrlConfirmationDialog,
objects.changeUrlSuccessfulDialog),
[constants.ATLAS, constants.HERMES]
),
[messages.actions.payouts]: prepareAction(payoutAction(
objects.payoutsActions,
objects.availablePayoutDialog,
objects.confirmPayoutWithdrawalDialog,
objects.withdrawalSuccessfulDialog),
[constants.ATLAS]
),
[messages.actions.retire]: prepareAction(retireAction(
objects.atlasModeModel,
objects.onboardActions,
objects.confirmRetirementDialog,
objects.retirementSuccessfulDialog,
objects.continueAtlasRetirementDialog,
objects.retirementStartSuccessfulDialog,
objects.retirementContinueDialog,
static buildStage2(stage1Objects, network, privateKey) {
const objects = {...stage1Objects};
objects.web3 = new Web3(network.rpc);
const account = objects.web3.eth.accounts.privateKeyToAccount(privateKey);
objects.web3.eth.accounts.wallet.add(account);
const {address} = account;
objects.web3.eth.defaultAccount = address;
objects.headWrapper = new HeadWrapper(network.headContractAddress, objects.web3, address);
objects.kycWhitelistWrapper = new KycWhitelistWrapper(objects.headWrapper, objects.web3, address);
objects.rolesWrapper = new RolesWrapper(objects.headWrapper, objects.web3, address);
objects.timeWrapper = new TimeWrapper(objects.headWrapper, objects.web3, address);
objects.payoutsWrapper = new PayoutsWrapper(objects.headWrapper, objects.web3, address);
objects.atlasStakeWrapper = new AtlasStakeStoreWrapper(objects.headWrapper, objects.web3, address);
objects.payoutsActions = new PayoutsActions(objects.timeWrapper, objects.payoutsWrapper);
objects.onboardActions = new OnboardActions(objects.kycWhitelistWrapper, objects.rolesWrapper, objects.atlasStakeWrapper);
objects.crypto = new Crypto(objects.web3);
objects.stateModel = new StateModel(objects.store, objects.crypto, objects.setupCreator);
objects.smartContractsModel = new SmartContractsModel(objects.crypto, objects.kycWhitelistWrapper, objects.rolesWrapper);
objects.atlasModeModel = new AtlasModeModel(objects.httpUtils, account, objects.stateModel);
objects.selectNodeTypePhase = selectNodeTypePhase(objects.stateModel, objects.askForNodeTypeDialog, objects.askForApolloMinimalDepositDialog, objects.roleSelectedDialog);
objects.getNodeUrlPhase = getNodeUrlPhase(objects.stateModel, objects.nodeUrlDetectedDialog, objects.askForNodeUrlDialog);
objects.getNodeIPPhase = getNodeIPPhase(objects.stateModel, objects.nodeIPDetectedDialog, objects.askForNodeIPDialog);
objects.getUserEmailPhase = getUserEmailPhase(objects.stateModel, objects.userEmailDetectedDialog, objects.askForUserEmailDialog);
objects.manualSubmissionPhase = manualSubmissionPhase(objects.stateModel, objects.displaySubmissionDialog);
objects.checkAddressWhitelistingStatusPhase = checkAddressWhitelistingStatusPhase(objects.smartContractsModel, objects.stateModel, objects.addressIsNotWhitelistedDialog, objects.addressIsWhitelistedDialog);
objects.performOnboardingPhase = performOnboardingPhase(objects.stateModel, objects.smartContractsModel,