diff --git a/app/components/accountlist.js b/app/components/accountlist.js new file mode 100644 index 0000000..adcd873 --- /dev/null +++ b/app/components/accountlist.js @@ -0,0 +1,66 @@ +import web3 from 'Embark/web3' +import React from 'react'; +import { connect } from 'react-redux'; +import { Nav, MenuItem, NavDropdown } from 'react-bootstrap'; +import Blockies from 'react-blockies'; +import { string, bool, func, arrayOf, shape } from 'prop-types'; +import { getAccounts, getDefaultAccount, accountsIsLoading, actions as accountActions } from '../reducers/accounts'; +import './accountlist.css'; + +const AccList = ({ + accounts, defaultAccount, changeAccount, isLoading, classNameNavDropdown, +}) => ( + + {!isLoading ? +
+
+ +
+
+ +
+
+ :
Loading...
} +
+); + +AccList.propTypes = { + accounts: arrayOf(shape({ address: string, balance: string })).isRequired, + defaultAccount: string, + changeAccount: func.isRequired, + isLoading: bool.isRequired, + classNameNavDropdown: string +} + +const mapStateToProps = state => ({ + accounts: getAccounts(state), + defaultAccount: getDefaultAccount(state), + isLoading: accountsIsLoading(state), +}); + +const mapDispatchToProps = dispatch => ({ + changeAccount(address) { + web3.eth.defaultAccount = address; + dispatch(accountActions.updateDefaultAccount(address)); + }, +}); + +export default connect(mapStateToProps, mapDispatchToProps)(AccList); diff --git a/config/contracts.js b/config/contracts.js index 37c05f5..63eb6fd 100644 --- a/config/contracts.js +++ b/config/contracts.js @@ -29,6 +29,12 @@ module.exports = { }, UpdatableInstance: { deploy: false + }, + MiniMeToken: { + deploy: false + }, + MiniMeTokenFactory: { + deploy: true } } }, diff --git a/test/minimetoken.js b/test/minimetoken.js index d911652..1e63096 100644 --- a/test/minimetoken.js +++ b/test/minimetoken.js @@ -1,35 +1,40 @@ const utils = require('../utils/testUtils') -const ERC20Token = require('./erc20token'); -const Controlled = require('./controlled'); -describe("MiniMeToken", async function() { +const MiniMeToken = require('Embark/contracts/MiniMeToken'); +const ERC20TokenSpec = require('./abstract/erc20tokenspec'); +const ControlledSpec = require('./abstract/controlled'); + +config({ + contracts: { + "MiniMeTokenFactory": { + }, + "MiniMeToken": { + "args": [ + "$MiniMeTokenFactory", + utils.zeroAddress, + 0, + "TestMiniMeToken", + 18, + "TST", + true + ] + }, + ...ERC20TokenSpec.config.contracts + } +}); + + +contract("MiniMeToken", function() { this.timeout(0); var accounts; - var miniMeTokenClone; - const b = []; - before(function(done) { - var contractsConfig = { - "MiniMeTokenFactory": { - }, - "MiniMeToken": { - "args": [ - "$MiniMeTokenFactory", - utils.zeroAddress, - 0, - "TestMiniMeToken", - 18, - "TST", - true - ] - } - }; - EmbarkSpec.deployAll(contractsConfig, async function(accountsArr) { - accounts = accountsArr - done() + web3.eth.getAccounts().then(function (res) { + accounts = res; + done(); }); }); - + var miniMeTokenClone; + const b = []; it('should generate tokens for address 1', async () => { await MiniMeToken.methods.generateTokens(accounts[1], 10).send(); @@ -61,9 +66,7 @@ describe("MiniMeToken", async function() { 'MMTc', 0, true).send({ from: accounts[0]}); - let addr = miniMeTokenCloneTx.events.NewCloneToken.raw.topics[1]; - addr = `0x${addr.slice(26)}`; - addr = web3.utils.toChecksumAddress(addr); + let addr = miniMeTokenCloneTx.events.NewCloneToken.returnValues[0]; miniMeTokenClone = new web3.eth.Contract(MiniMeToken._jsonInterface, addr); b[3] = await web3.eth.getBlockNumber(); @@ -101,32 +104,17 @@ describe("MiniMeToken", async function() { assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[1]).call(), 12); assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[2]).call(), 4); }); + - var erc20tokenConfig = { - "MiniMeTokenFactory": { - }, - "Contract": { - "instanceOf" : "MiniMeToken", - "args": [ - "$MiniMeTokenFactory", - utils.zeroAddress, - 0, - "TestMiniMeToken", - 18, - "TST", - true - ] - } - } - - ERC20Token.Test(erc20tokenConfig, async function (accounts, MiniMeToken) { + it("should mint balances for ERC20TokenSpec", async function() { + let initialBalance = 7 * 10 ^ 18; for(i=0;i