This commit is contained in:
Jordi Baylina 2017-02-10 08:33:42 +01:00
parent 81a606675c
commit 72437eabc6
6 changed files with 134 additions and 50 deletions

View File

@ -149,6 +149,7 @@ contract MiniMeToken is Controlled {
decimals = _decimalUnits; // Set the decimals decimals = _decimalUnits; // Set the decimals
symbol = _tokenSymbol; // Set the symbol symbol = _tokenSymbol; // Set the symbol
parentToken = MiniMeToken(_parentToken); parentToken = MiniMeToken(_parentToken);
transfersEnabled = _transfersEnabled;
creationBlock = block.number; creationBlock = block.number;
} }

File diff suppressed because one or more lines are too long

19
dist/minimetoken.js vendored
View File

@ -264,6 +264,7 @@ var MiniMeToken = function () {
}], [{ }], [{
key: "deploy", key: "deploy",
value: function deploy(web3, opts, cb) { value: function deploy(web3, opts, cb) {
var promise = new Promise(function (resolve, reject) {
var params = Object.assign({}, opts); var params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0; params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0; params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
@ -285,10 +286,24 @@ var MiniMeToken = function () {
params.byteCode = _MiniMeTokenSol.MiniMeTokenByteCode; params.byteCode = _MiniMeTokenSol.MiniMeTokenByteCode;
(0, _runethtx.deploy)(web3, params, cb1); (0, _runethtx.deploy)(web3, params, cb1);
}], function (err, res) { }], function (err, res) {
if (err) return cb(err); if (err) {
reject(err);
return;
}
var minime = new MiniMeToken(web3, res[1].address); var minime = new MiniMeToken(web3, res[1].address);
cb(null, minime); resolve(minime);
}); });
});
if (cb) {
promise.then(function (value) {
cb(null, value);
}, function (reason) {
cb(reason);
});
} else {
return promise;
}
} }
}]); }]);

49
env.js Normal file
View File

@ -0,0 +1,49 @@
"use strict";
var Web3 = require('web3');
// create an instance of web3 using the HTTP provider.
// NOTE in mist web3 is already available, so check first if its available before instantiating
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var BigNumber = require('bignumber.js');
var eth = web3.eth;
var async = require('async');
var MiniMeToken = require('./dist/minimetoken.js');
var gcb = function(err, res) {
if (err) {
console.log("ERROR: "+err);
} else {
console.log(JSON.stringify(res,null,2));
}
}
var minimeToken;
function deployExample(cb) {
cb = cb || gcb;
async.series([
function(cb) {
MiniMeToken.deploy(web3, {
tokenName: "MiniMe Test Token",
decimalUnits: 18,
tokenSymbol: "MMT",
}, function(err, _minimeToken) {
if (err) return err;
minimeToken = _minimeToken;
console.log("Minime Token: " + minimeToken.contract.address);
cb();
});
},
function(cb) {
minimeToken.generateTokens({
owner: eth.accounts[ 1 ],
amount: 10,
from: eth.accounts[ 0 ],
},cb);
},
], cb);
}

View File

@ -98,11 +98,13 @@ export default class MiniMeToken {
} }
static deploy(web3, opts, cb) { static deploy(web3, opts, cb) {
const promise = new Promise((resolve, reject) => {
const params = Object.assign({}, opts); const params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0; params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0; params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled; params.transfersEnabled = (typeof params.transfersEnabled === "undefined") ? true : params.transfersEnabled;
console.log("1-> "+JSON.stringify(params, null, 2));
console.log("2-> "+typeof params.transfersEnabled);
async.series([ async.series([
(cb1) => { (cb1) => {
params.abi = MiniMeTokenFactoryAbi; params.abi = MiniMeTokenFactoryAbi;
@ -123,10 +125,26 @@ export default class MiniMeToken {
}, },
], ],
(err, res) => { (err, res) => {
if (err) return cb(err); if (err) {
reject(err);
return;
}
const minime = new MiniMeToken(web3, res[ 1 ].address); const minime = new MiniMeToken(web3, res[ 1 ].address);
cb(null, minime); resolve(minime);
}); });
});
if (cb) {
promise.then(
(value) => {
cb(null, value);
},
(reason) => {
cb(reason);
});
} else {
return promise;
}
} }
createCloneToken(opts, cb) { createCloneToken(opts, cb) {

View File

@ -51,6 +51,7 @@ describe("MiniMeToken test", () => {
owner: ethConnector.accounts[ 1 ], owner: ethConnector.accounts[ 1 ],
amount: 10, amount: 10,
from: ethConnector.accounts[ 0 ], from: ethConnector.accounts[ 0 ],
verbose: true,
}, cb); }, cb);
}, },
(cb) => { (cb) => {