diff --git a/src/components/Home/utils.js b/src/components/Home/utils.js
index f64360fc1..4bcaeddb3 100644
--- a/src/components/Home/utils.js
+++ b/src/components/Home/utils.js
@@ -9,6 +9,9 @@ export const reloadStorage = async props => {
let { generalStore, contractStore } = props
try {
+ if (!contractStore || !generalStore) {
+ throw new Error('There is no stores to set')
+ }
contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.PENDING)
// General store, check network
@@ -18,9 +21,12 @@ export const reloadStorage = async props => {
// Contract store, get contract and abi
await getCrowdsaleAssets(networkID)
contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.SUCCESS)
+ return true
} catch (e) {
logger.error('Error downloading contracts', e)
- contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.FAILURE)
+ if (contractStore) {
+ contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.FAILURE)
+ }
throw e
}
}
diff --git a/src/components/StepOne/index.js b/src/components/StepOne/index.js
index 73303b72d..720efa7f6 100644
--- a/src/components/StepOne/index.js
+++ b/src/components/StepOne/index.js
@@ -104,15 +104,11 @@ export class StepOne extends Component {
}
goNextStep = () => {
- try {
- navigateTo({
- history: this.props.history,
- location: 'stepTwo',
- fromLocation: 'stepOne'
- })
- } catch (err) {
- logger.log('Error to navigate', err)
- }
+ navigateTo({
+ history: this.props.history,
+ location: 'stepTwo',
+ fromLocation: 'stepOne'
+ })
}
handleChange = e => {
diff --git a/src/components/StepThree/index.js b/src/components/StepThree/index.js
index 594145b31..b634f5a9d 100644
--- a/src/components/StepThree/index.js
+++ b/src/components/StepThree/index.js
@@ -32,7 +32,10 @@ export class StepThree extends Component {
reload: false,
initialTiers: [],
burnExcess: 'no',
- gasTypeSelected: {}
+ gasTypeSelected: {},
+ backButtonTriggered: false, //Testing purposes
+ nextButtonTriggered: false, //Testing purposes
+ goBackEnabledTriggered: false //Testing purposes
}
componentDidMount() {
@@ -99,6 +102,9 @@ export class StepThree extends Component {
goNextStep = () => {
try {
+ this.setState({
+ nextButtonTriggered: true
+ })
navigateTo({
history: this.props.history,
location: 'stepFour',
@@ -111,6 +117,9 @@ export class StepThree extends Component {
goBack = () => {
try {
+ this.setState({
+ backButtonTriggered: true
+ })
goBack({
history: this.props.history,
location: '/stepTwo'
@@ -123,6 +132,9 @@ export class StepThree extends Component {
goBackEnabled = () => {
let goBackEnabled = false
try {
+ this.setState({
+ goBackEnabledTriggered: true
+ })
goBackEnabled = goBackMustBeEnabled({ history: this.props.history })
logger.log(`Go back is enabled ${goBackEnabled}`)
} catch (err) {
diff --git a/src/components/StepTwo/index.js b/src/components/StepTwo/index.js
index 51a251a96..48517c060 100644
--- a/src/components/StepTwo/index.js
+++ b/src/components/StepTwo/index.js
@@ -18,7 +18,10 @@ const logger = logdown('TW:stepTwo:index')
export class StepTwo extends Component {
state = {
tokenValues: {},
- reload: false
+ reload: false,
+ backButtonTriggered: false, //Testing purposes
+ nextButtonTriggered: false, //Testing purposes
+ goBackEnabledTriggered: false //Testing purposes
}
async componentDidMount() {
@@ -51,6 +54,9 @@ export class StepTwo extends Component {
goNextStep = () => {
try {
+ this.setState({
+ nextButtonTriggered: true
+ })
navigateTo({
history: this.props.history,
location: 'stepThree',
@@ -63,6 +69,9 @@ export class StepTwo extends Component {
goBack = () => {
try {
+ this.setState({
+ backButtonTriggered: true
+ })
goBack({
history: this.props.history,
location: '/stepOne'
@@ -75,6 +84,9 @@ export class StepTwo extends Component {
goBackEnabled = () => {
let goBackEnabled = false
try {
+ this.setState({
+ goBackEnabledTriggered: true
+ })
goBackEnabled = goBackMustBeEnabled({ history: this.props.history })
logger.log(`Go back is enabled ${goBackEnabled}`)
} catch (err) {
diff --git a/src/stores/StatsStore.js b/src/stores/StatsStore.js
index 9ec99a848..0aedb5a96 100644
--- a/src/stores/StatsStore.js
+++ b/src/stores/StatsStore.js
@@ -10,6 +10,25 @@ class StatsStore {
@observable totalInvolvedContributorsAmount
@observable maxTiersAmount
@observable maxEthRaised
+ @observable totalContributorsAmount
+ @observable mintedCappedEthRaised
+ @observable dutchAuctionEthRaised
+ @observable mintedCappedCrowdsales
+ @observable dutchAuctionCrowdsales
+ @observable mintedCappedContributorsAmount
+ @observable dutchAuctionContributorsAmount
+ @observable mintedCappedPercentageOfFinalized
+ @observable dutchAuctionPercentageOfFinalized
+ @observable mintedCappedPercentageOfMultiTiers
+ @observable mintedCappedMaxTiersAmount
+ @observable mintedCappedMaxEthRaised
+ @observable dutchAuctionMaxEthRaised
+ @observable mintedCappedOngoingCrowdsales
+ @observable mintedCappedFutureCrowdsales
+ @observable mintedCappedPastCrowdsales
+ @observable dutchAuctionOngoingCrowdsales
+ @observable dutchAuctionFutureCrowdsales
+ @observable dutchAuctionPastCrowdsales
constructor() {
this.totalEthRaised = 0
@@ -21,6 +40,25 @@ class StatsStore {
this.totalInvolvedContributorsAmount = 0
this.maxTiersAmount = 0
this.maxEthRaised = 0
+ this.totalContributorsAmount = 0
+ this.mintedCappedEthRaised = 0
+ this.dutchAuctionEthRaised = 0
+ this.mintedCappedCrowdsales = 0
+ this.dutchAuctionCrowdsales = 0
+ this.mintedCappedContributorsAmount = 0
+ this.dutchAuctionContributorsAmount = 0
+ this.mintedCappedPercentageOfFinalized = 0
+ this.dutchAuctionPercentageOfFinalized = 0
+ this.mintedCappedPercentageOfMultiTiers = 0
+ this.mintedCappedMaxTiersAmount = 0
+ this.mintedCappedMaxEthRaised = 0
+ this.dutchAuctionMaxEthRaised = 0
+ this.mintedCappedOngoingCrowdsales = 0
+ this.mintedCappedFutureCrowdsales = 0
+ this.mintedCappedPastCrowdsales = 0
+ this.dutchAuctionOngoingCrowdsales = 0
+ this.dutchAuctionFutureCrowdsales = 0
+ this.dutchAuctionPastCrowdsales = 0
}
@action
diff --git a/src/stores/utils.js b/src/stores/utils.js
index 71f851388..36cf70ce0 100644
--- a/src/stores/utils.js
+++ b/src/stores/utils.js
@@ -49,15 +49,15 @@ export const getCrowdsaleAssets = async networkID => {
return Promise.all(whenPromises)
}
-async function getCrowdsaleAsset(contractName, stateProp, networkID) {
+const getCrowdsaleAsset = async (contractName, stateProp, networkID) => {
logger.log(contractName, stateProp, networkID)
const whenSrc =
stateProp === 'MintedCappedProxy' || stateProp === 'DutchProxy'
- ? setFlatFileContentToState(`./contracts/${stateProp}.sol`)
+ ? await setFlatFileContentToState(`./contracts/${stateProp}.sol`)
: Promise.resolve()
const whenBin =
stateProp === 'MintedCappedProxy' || stateProp === 'DutchProxy'
- ? setFlatFileContentToState(`./contracts/${stateProp}.bin`)
+ ? await setFlatFileContentToState(`./contracts/${stateProp}.bin`)
: Promise.resolve()
let abi
//todo: get ABI or from file or from here
@@ -2553,7 +2553,7 @@ async function getCrowdsaleAsset(contractName, stateProp, networkID) {
Promise.resolve()
}
-function addContractsToState(src, bin, abi, addr, contract) {
+const addContractsToState = (src, bin, abi, addr, contract) => {
contractStore.setContract(contract, {
src,
bin,
diff --git a/src/utils/__mocks__/alerts.js b/src/utils/__mocks__/alerts.js
new file mode 100644
index 000000000..1667037ac
--- /dev/null
+++ b/src/utils/__mocks__/alerts.js
@@ -0,0 +1,7 @@
+export const cancellingIncompleteDeploy = () => {
+ return new Promise((resolve, reject) => {
+ return resolve({
+ value: true
+ })
+ })
+}
diff --git a/src/utils/alerts.js b/src/utils/alerts.js
index db912bd24..c2f3c8e4f 100644
--- a/src/utils/alerts.js
+++ b/src/utils/alerts.js
@@ -1,7 +1,7 @@
import sweetAlert2 from 'sweetalert2'
import { DEPLOYMENT_VALUES, LIMIT_RESERVED_ADDRESSES, LIMIT_WHITELISTED_ADDRESSES } from './constants'
-export function noMetaMaskAlert(cb) {
+export const noMetaMaskAlert = cb => {
sweetAlert2({
title: 'Warning',
html:
@@ -11,7 +11,7 @@ export function noMetaMaskAlert(cb) {
}).then(cb)
}
-export function MetaMaskIsLockedAlert(cb) {
+export const MetaMaskIsLockedAlert = cb => {
sweetAlert2({
title: 'Warning',
html: 'You signed out from your Wallet. Open your Wallet extension and sign in.',
@@ -19,7 +19,7 @@ export function MetaMaskIsLockedAlert(cb) {
}).then(cb)
}
-export function noContractDataAlert() {
+export const noContractDataAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'The crowdsale data is empty. There is nothing to deploy. Please, start Token Wizard from the beginning.',
@@ -27,7 +27,7 @@ export function noContractDataAlert() {
})
}
-export function noContractAlert() {
+export const noContractAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'There is no contract at this address',
@@ -35,7 +35,7 @@ export function noContractAlert() {
})
}
-export function invalidCrowdsaleExecIDAlert() {
+export const invalidCrowdsaleExecIDAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'Invalid crowdsale exec-id is indicated in config and/or in query string.',
@@ -43,7 +43,7 @@ export function invalidCrowdsaleExecIDAlert() {
})
}
-export function invalidCrowdsaleExecIDProxyAlert() {
+export const invalidCrowdsaleExecIDProxyAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'Invalid crowdsale exec-id or proxy address indicated in config and/or in query string.',
@@ -51,7 +51,7 @@ export function invalidCrowdsaleExecIDProxyAlert() {
})
}
-export function invalidCrowdsaleProxyAlert() {
+export const invalidCrowdsaleProxyAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'Invalid crowdsale proxy address is indicated in config and/or in query string.',
@@ -59,7 +59,7 @@ export function invalidCrowdsaleProxyAlert() {
})
}
-export function invalidCrowdsaleAddrAlert() {
+export const invalidCrowdsaleAddrAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'Invalid crowdsale address is indicated in config and/or in query string.',
@@ -67,7 +67,7 @@ export function invalidCrowdsaleAddrAlert() {
})
}
-export function invalidNetworkIDAlert() {
+export const invalidNetworkIDAlert = () => {
sweetAlert2({
title: 'Warning',
html: 'Invalid network ID is indicated in config and/or in query string.',
@@ -75,7 +75,7 @@ export function invalidNetworkIDAlert() {
})
}
-export function successfulContributionAlert(tokensToContribute, cb) {
+export const successfulContributionAlert = (tokensToContribute, cb) => {
sweetAlert2({
title: 'Success',
html: "Congrats! You've successfully bought " + tokensToContribute + ' tokens!',
@@ -83,7 +83,7 @@ export function successfulContributionAlert(tokensToContribute, cb) {
}).then(cb)
}
-export function contributionDisabledAlertInTime(startTime) {
+export const contributionDisabledAlertInTime = startTime => {
sweetAlert2({
title: 'Warning',
html: "Wait, please. Crowdsale company hasn't started yet. It'll start from " + new Date(startTime) + '.',
@@ -91,7 +91,7 @@ export function contributionDisabledAlertInTime(startTime) {
})
}
-export function incorrectNetworkAlert(correctNetworkName, incorrectNetworkName) {
+export const incorrectNetworkAlert = (correctNetworkName, incorrectNetworkName) => {
sweetAlert2({
title: 'Warning',
html:
@@ -104,7 +104,7 @@ export function incorrectNetworkAlert(correctNetworkName, incorrectNetworkName)
})
}
-export function warningOnMainnetAlert(tiersCount, priceSelected, reservedCount, whitelistCount, cb) {
+export const warningOnMainnetAlert = (tiersCount, priceSelected, reservedCount, whitelistCount, cb) => {
const { GAS_REQUIRED, TX_REQUIRED } = DEPLOYMENT_VALUES
let gasRequired =
@@ -137,7 +137,7 @@ export function warningOnMainnetAlert(tiersCount, priceSelected, reservedCount,
})
}
-export function warningOnFinalizeCrowdsale() {
+export const warningOnFinalizeCrowdsale = () => {
return sweetAlert2({
title: 'Finalize Crowdsale',
html:
@@ -150,7 +150,7 @@ export function warningOnFinalizeCrowdsale() {
})
}
-export function successfulFinalizeAlert() {
+export const successfulFinalizeAlert = () => {
return sweetAlert2({
title: 'Success',
html: "Congrats! You've successfully finalized the Crowdsale!",
@@ -158,7 +158,7 @@ export function successfulFinalizeAlert() {
})
}
-export function successfulDistributeAlert() {
+export const successfulDistributeAlert = () => {
sweetAlert2({
title: 'Success',
html: "Congrats! You've successfully distributed reserved tokens!",
@@ -166,7 +166,7 @@ export function successfulDistributeAlert() {
})
}
-export function noGasPriceAvailable() {
+export const noGasPriceAvailable = () => {
sweetAlert2({
title: 'No Gas Price Available',
html: "Token Wizard wasn't able to request current Gas Prices from the blockchain, custom values will be used",
@@ -174,7 +174,7 @@ export function noGasPriceAvailable() {
})
}
-export function successfulUpdateCrowdsaleAlert() {
+export const successfulUpdateCrowdsaleAlert = () => {
sweetAlert2({
title: 'Success',
html: "Congrats! You've successfully updated the Crowdsale!",
@@ -186,7 +186,7 @@ export function successfulUpdateCrowdsaleAlert() {
})
}
-export function successfulDeployment() {
+export const successfulDeployment = () => {
sweetAlert2({
title: 'Success',
html: 'Transactions signed successfully!',
@@ -194,7 +194,7 @@ export function successfulDeployment() {
})
}
-export function mainnetIsOnMaintenance() {
+export const mainnetIsOnMaintenance = () => {
sweetAlert2({
title: 'Warning',
html:
@@ -203,7 +203,7 @@ export function mainnetIsOnMaintenance() {
})
}
-export function notTheOwner() {
+export const notTheOwner = () => {
sweetAlert2({
title: 'Not The Owner',
html: "Current user is not the owner of the Crowdsale, thus you won't be able to modify it",
@@ -211,7 +211,7 @@ export function notTheOwner() {
})
}
-export function cancellingIncompleteDeploy() {
+export const cancellingIncompleteDeploy = () => {
return sweetAlert2({
title: 'Cancel crowdsale deploy',
html: 'Are you sure you want to cancel the deployment of the crowdsale? This action cannot be undone.',
@@ -223,7 +223,7 @@ export function cancellingIncompleteDeploy() {
})
}
-export function skippingTransaction() {
+export const skippingTransaction = () => {
return sweetAlert2({
title: 'Skip transaction',
html:
@@ -236,7 +236,7 @@ export function skippingTransaction() {
})
}
-export function clearingReservedTokens() {
+export const clearingReservedTokens = () => {
return sweetAlert2({
title: 'Clear all reserved tokens',
html: 'Are you sure you want to remove all reserved tokens?',
@@ -248,7 +248,7 @@ export function clearingReservedTokens() {
})
}
-export function clearingWhitelist() {
+export const clearingWhitelist = () => {
return sweetAlert2({
title: 'Clear all whitelist addresses',
html: 'Are you sure you want to remove all the whitelist addresses for this tier?',
@@ -260,7 +260,7 @@ export function clearingWhitelist() {
})
}
-export function whitelistImported(count) {
+export const whitelistImported = count => {
return sweetAlert2({
title: 'Addresses imported',
html: `${count} addresses were added to the whitelist`,
@@ -268,7 +268,7 @@ export function whitelistImported(count) {
})
}
-export function errorDimCSVAlert(dimensions) {
+export const errorDimCSVAlert = dimensions => {
let message = 'There was an error importing the file.'
if (dimensions && dimensions.length > 0) {
@@ -291,7 +291,7 @@ export function errorDimCSVAlert(dimensions) {
})
}
-export function errorDimValueCSVAlert(dimensionsValues) {
+export const errorDimValueCSVAlert = dimensionsValues => {
let message = 'There was an error importing the file.'
if (dimensionsValues && dimensionsValues.length > 0) {
@@ -314,7 +314,7 @@ export function errorDimValueCSVAlert(dimensionsValues) {
})
}
-export function errorEmptyCSVAlert() {
+export const errorEmptyCSVAlert = () => {
return sweetAlert2({
title: 'Error importing the file',
html: 'Empty CSV file. Nothing was imported',
@@ -322,7 +322,7 @@ export function errorEmptyCSVAlert() {
})
}
-export function errorWhitelistedCSVAlert(errors) {
+export const errorWhitelistedCSVAlert = errors => {
let message = 'There was an error importing the file. The file have an erroneous amount of columns'
if (errors && errors.length > 0) {
@@ -341,7 +341,7 @@ export function errorWhitelistedCSVAlert(errors) {
})
}
-export function errorRowLengthCSVAlert(errors) {
+export const errorRowLengthCSVAlert = errors => {
let message = 'There was an error importing the file. The file have an erroneous amount of columns'
if (errors && errors.length > 0) {
@@ -365,7 +365,7 @@ export function errorRowLengthCSVAlert(errors) {
})
}
-export function errorAddressCSVAlert(address) {
+export const errorAddressCSVAlert = address => {
let message = 'There was an error importing the file.'
if (address && address.length > 0) {
@@ -388,7 +388,7 @@ export function errorAddressCSVAlert(address) {
})
}
-export function reservedTokensImported(count) {
+export const reservedTokensImported = count => {
return sweetAlert2({
title: 'Reserved tokens imported',
html: `Tokens will be reserved for ${count} addresses`,
@@ -396,7 +396,7 @@ export function reservedTokensImported(count) {
})
}
-export function noMoreTokensAvailable() {
+export const noMoreTokensAvailable = () => {
return sweetAlert2({
title: 'No more tokens available',
html: `You're not able to buy more tokens. You have bought your maximum allowed or tier has reached its hard cap`,
@@ -404,7 +404,7 @@ export function noMoreTokensAvailable() {
})
}
-export function notAllowedContributor() {
+export const notAllowedContributor = () => {
return sweetAlert2({
title: 'Not allowed',
html: `You're not allowed to buy tokens during this tier.`,
@@ -412,7 +412,7 @@ export function notAllowedContributor() {
})
}
-export function noMoreReservedSlotAvailable() {
+export const noMoreReservedSlotAvailable = () => {
return sweetAlert2({
title: 'No more reserved tokens available',
html: `You're not able to reserve more tokens. The maximum allowed is ${LIMIT_RESERVED_ADDRESSES}`,
@@ -420,7 +420,7 @@ export function noMoreReservedSlotAvailable() {
})
}
-export function noMoreReservedSlotAvailableCSV(count) {
+export const noMoreReservedSlotAvailableCSV = count => {
return sweetAlert2({
title: 'You reach the limit of reserved tokens',
html: `You're not able to reserve more tokens. Reserved tokens imported Tokens will be reserved for ${count} addresses. The maximum allowed is ${LIMIT_RESERVED_ADDRESSES}`,
@@ -428,7 +428,7 @@ export function noMoreReservedSlotAvailableCSV(count) {
})
}
-export function noMoreWhitelistedSlotAvailable() {
+export const noMoreWhitelistedSlotAvailable = () => {
return sweetAlert2({
title: 'Maximum limit of addresses reached',
html: `You're not able to add more addresses to the whitelist. The maximum allowed is ${LIMIT_WHITELISTED_ADDRESSES}`,
@@ -436,7 +436,7 @@ export function noMoreWhitelistedSlotAvailable() {
})
}
-export function noMoreWhitelistedSlotAvailableCSV(count) {
+export const noMoreWhitelistedSlotAvailableCSV = count => {
return sweetAlert2({
title: 'Maximum limit of addresses reached',
html: `You're not able to add more addresses to the whitelist. Only ${count} addresses of the file could be added. The maximum allowed is ${LIMIT_WHITELISTED_ADDRESSES}`,
@@ -444,7 +444,7 @@ export function noMoreWhitelistedSlotAvailableCSV(count) {
})
}
-export function maxCapExceedsSupply(count) {
+export const maxCapExceedsSupply = count => {
return sweetAlert2({
title: `Max Cap exceeded tier's supply`,
html: `${count} addresses where added. Addresses with maxCap greater than tier's supply where discarded.`,
@@ -452,7 +452,7 @@ export function maxCapExceedsSupply(count) {
})
}
-export function networkChanged() {
+export const networkChanged = () => {
return sweetAlert2({
title: 'Network changed',
html: 'The network id was modified, please set up nifty wallet with the network id which you started',
@@ -460,7 +460,7 @@ export function networkChanged() {
})
}
-export function deployHasEnded() {
+export const deployHasEnded = () => {
return sweetAlert2({
title: 'Deploy ended',
html: 'The deploy is finished',
@@ -468,7 +468,7 @@ export function deployHasEnded() {
})
}
-export function transactionLost() {
+export const transactionLost = () => {
return sweetAlert2({
title: 'Tx Lost',
html: "Please cancel pending transaction, if there's any, in your wallet (Nifty Wallet or Metamask) and Continue",
diff --git a/src/utils/blockchainHelpers.js b/src/utils/blockchainHelpers.js
index 5bddd009e..ae8368d41 100644
--- a/src/utils/blockchainHelpers.js
+++ b/src/utils/blockchainHelpers.js
@@ -228,7 +228,7 @@ const deployContractInner = (account, abi, deployOpts, executionOrder) => {
})
}
-export function sendTXToContract(method, executionOrder) {
+export const sendTXToContract = (method, executionOrder) => {
return sendTX(method, CALL_METHOD, executionOrder)
}
@@ -362,7 +362,7 @@ const getTypeOfTxDisplayName = type => {
}
}
-export function attachToContract(abi, addr) {
+export const attachToContract = (abi, addr) => {
const { web3 } = web3Store
return web3.eth.getAccounts().then(accounts => {
@@ -386,7 +386,7 @@ const getApplicationInstance = async (app_instances, appName, appNameHash, i) =>
}
}
-async function getAllApplicationsInstances() {
+const getAllApplicationsInstances = async () => {
const whenRegistryExecContract = attachToSpecificCrowdsaleContract('registryExec')
const {
REACT_APP_MINTED_CAPPED_APP_NAME: MINTED_CAPPED_APP_NAME,
@@ -414,7 +414,7 @@ async function getAllApplicationsInstances() {
return Promise.all(whenCrowdsales).then(crowdsales => crowdsales.filter(crowdsale => crowdsale !== null))
}
-async function getOwnerApplicationsInstancesForProxy() {
+const getOwnerApplicationsInstancesForProxy = async () => {
const { web3 } = web3Store
const proxiesRegistryContract = await attachToSpecificCrowdsaleContract('ProxiesRegistry')
const accounts = await web3.eth.getAccounts()
@@ -447,7 +447,7 @@ async function getOwnerApplicationsInstancesForProxy() {
}
// eslint-disable-next-line no-unused-vars
-async function getOwnerApplicationsInstances() {
+const getOwnerApplicationsInstances = async () => {
const { web3 } = web3Store
const registryExecContract = await attachToSpecificCrowdsaleContract('registryExec')
const accounts = await web3.eth.getAccounts()
@@ -545,13 +545,13 @@ export const getCrowdsaleStrategyByName = async appName => {
}
}
-export async function loadRegistryAddresses() {
+export const loadRegistryAddresses = async () => {
const crowdsales = await getOwnerApplicationsInstancesForProxy()
logger.log('Crowdsales', crowdsales)
crowdsaleStore.setCrowdsales(crowdsales)
}
-export let getCurrentAccount = () => {
+export const getCurrentAccount = () => {
const { web3 } = web3Store
return new Promise((resolve, reject) => {
if (!web3) {
@@ -704,27 +704,27 @@ export let methodToCreateAppInstance = (contractName, methodName, getEncodedPara
return method
}
-function getCrowdsaleInfo(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleInfo = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleInfo = initCrowdsaleContract.methods.getCrowdsaleInfo(addr, execID).call()
return whenCrowdsaleInfo
}
-function getCrowdsaleContributors(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleContributors = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleUniqueBuyers = initCrowdsaleContract.methods.getCrowdsaleUniqueBuyers(addr, execID).call()
return whenCrowdsaleUniqueBuyers
}
-function getCrowdsaleStartAndEndTimes(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleStartAndEndTimes = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleStartAndEndTimes = initCrowdsaleContract.methods.getCrowdsaleStartAndEndTimes(addr, execID).call()
return whenCrowdsaleStartAndEndTimes
}
-function getCrowdsaleTierList(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleTierList = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleTierList = initCrowdsaleContract.methods.getCrowdsaleTierList(addr, execID).call()
return whenCrowdsaleTierList
}
-export async function getAllCrowdsaleAddresses() {
+export const getAllCrowdsaleAddresses = async () => {
const instances = await getAllApplicationsInstances()
const targetPrefix = 'idx'
@@ -786,7 +786,7 @@ export const isAddressValid = addr => {
return web3Store && web3Store.web3 && web3Store.web3.utils.isAddress(addr)
}
-export function getProxyParams({ abstractStorageAddr, networkID, appNameHash }) {
+export const getProxyParams = ({ abstractStorageAddr, networkID, appNameHash }) => {
return [
abstractStorageAddr,
JSON.parse(process.env['REACT_APP_REGISTRY_EXEC_ID'] || '{}')[networkID],
diff --git a/src/utils/fetchFile.js b/src/utils/fetchFile.js
index 5ca5b6500..cbe421968 100644
--- a/src/utils/fetchFile.js
+++ b/src/utils/fetchFile.js
@@ -1,15 +1,5 @@
-export function fetchFile(path) {
- return new Promise((resolve, reject) => {
- const rawFile = new XMLHttpRequest()
-
- rawFile.addEventListener('error', reject)
- rawFile.open('GET', path, true)
- rawFile.onreadystatechange = function() {
- if (rawFile.readyState === 4 && (rawFile.status === 200 || rawFile.status === 0)) {
- let allText = rawFile.responseText
- resolve(allText)
- }
- }
- rawFile.send(null)
- })
+export async function fetchFile(path) {
+ let response = await fetch(path)
+ let data = await response.text()
+ return data
}
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 923d49501..b2003cc22 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -9,7 +9,7 @@ import { isObservableArray } from 'mobx'
const logger = logdown('TW:utils:utils')
-export function getQueryVariable(variable) {
+export const getQueryVariable = variable => {
return queryString.parse(window.location.search)[variable]
}
@@ -44,8 +44,8 @@ export const getNetworkID = () => {
return isNetworkIDValid(networkID) ? networkID : null
}
-export function setFlatFileContentToState(file) {
- return fetchFile(file)
+export const setFlatFileContentToState = async file => {
+ return await fetchFile(file)
}
export const dateToTimestamp = date => new Date(date).getTime()
@@ -61,7 +61,7 @@ export const validateLaterTime = (laterTime, previousTime) => dateToTimestamp(la
export const validateLaterOrEqualTime = (laterTime, previousTime) =>
dateToTimestamp(laterTime) >= dateToTimestamp(previousTime)
-export function toFixed(x) {
+export const toFixed = x => {
if (Math.abs(x) < 1.0) {
let e = parseInt(x.toString().split('e-')[1], 10)
if (e) {
@@ -86,7 +86,11 @@ export const toast = {
return
}
- this.msg[type](message, options)
+ if (typeof this.msg[type] === 'function') {
+ this.msg[type](message, options)
+ } else {
+ return
+ }
}
}
@@ -273,12 +277,12 @@ export const convertDateToUTCTimezoneToDisplay = dateToConvert => {
.format('YYYY-MM-DD HH:mm (z ZZ)')
}
-export function getContractBySourceType(sourceType, isMintedCappedCrowdsale, { DutchProxy, MintedCappedProxy }) {
+export const getContractBySourceType = (sourceType, isMintedCappedCrowdsale, { DutchProxy, MintedCappedProxy }) => {
const parseContent = content => (isObservableArray(content) ? JSON.stringify(content.slice()) : content)
return isMintedCappedCrowdsale ? parseContent(MintedCappedProxy[sourceType]) : parseContent(DutchProxy[sourceType])
}
-export function getSourceTypeTitle(sourceType) {
+export const getSourceTypeTitle = sourceType => {
const sourceTypeName = {
abi: 'ABI',
bin: 'Creation Code',
@@ -288,7 +292,7 @@ export function getSourceTypeTitle(sourceType) {
return `Crowdsale Proxy Contract ${sourceTypeName[sourceType]}`
}
-export function updateProxyContractInfo({ contractAddress }, { web3Store, contractStore, crowdsaleStore }, params) {
+export const updateProxyContractInfo = ({ contractAddress }, { web3Store, contractStore, crowdsaleStore }, params) => {
const { web3 } = web3Store
const encoded = web3.eth.abi.encodeParameters(['address', 'bytes32', 'address', 'bytes32'], params)
diff --git a/test/components/Common/DisplayField.spec.js b/test/components/Common/DisplayField.spec.js
index 8ecb730c9..a459f4102 100644
--- a/test/components/Common/DisplayField.spec.js
+++ b/test/components/Common/DisplayField.spec.js
@@ -2,7 +2,7 @@ import React from 'react'
import { DisplayField } from '../../../src/components/Common/DisplayField'
import { Form } from 'react-final-form'
import Adapter from 'enzyme-adapter-react-15'
-import { configure, mount } from 'enzyme'
+import { configure, shallow } from 'enzyme'
configure({ adapter: new Adapter() })
@@ -19,7 +19,7 @@ describe('DisplayField ', () => {
large: 'Large',
extralarge: 'ExtraLarge'
}
- const wrapper = mount(
+ const wrapper = shallow(