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
symbol = _tokenSymbol; // Set the symbol
parentToken = MiniMeToken(_parentToken);
transfersEnabled = _transfersEnabled;
creationBlock = block.number;
}

File diff suppressed because one or more lines are too long

53
dist/minimetoken.js vendored
View File

@ -264,31 +264,46 @@ var MiniMeToken = function () {
}], [{
key: "deploy",
value: function deploy(web3, opts, cb) {
var params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
var promise = new Promise(function (resolve, reject) {
var params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
_async2.default.series([function (cb1) {
params.abi = _MiniMeTokenSol.MiniMeTokenFactoryAbi;
params.byteCode = _MiniMeTokenSol.MiniMeTokenFactoryByteCode;
(0, _runethtx.deploy)(web3, params, function (err, _tokenFactory) {
_async2.default.series([function (cb1) {
params.abi = _MiniMeTokenSol.MiniMeTokenFactoryAbi;
params.byteCode = _MiniMeTokenSol.MiniMeTokenFactoryByteCode;
(0, _runethtx.deploy)(web3, params, function (err, _tokenFactory) {
if (err) {
cb1(err);
return;
}
params.tokenFactory = _tokenFactory.address;
cb1();
});
}, function (cb1) {
params.abi = _MiniMeTokenSol.MiniMeTokenAbi;
params.byteCode = _MiniMeTokenSol.MiniMeTokenByteCode;
(0, _runethtx.deploy)(web3, params, cb1);
}], function (err, res) {
if (err) {
cb1(err);
reject(err);
return;
}
params.tokenFactory = _tokenFactory.address;
cb1();
var minime = new MiniMeToken(web3, res[1].address);
resolve(minime);
});
}, function (cb1) {
params.abi = _MiniMeTokenSol.MiniMeTokenAbi;
params.byteCode = _MiniMeTokenSol.MiniMeTokenByteCode;
(0, _runethtx.deploy)(web3, params, cb1);
}], function (err, res) {
if (err) return cb(err);
var minime = new MiniMeToken(web3, res[1].address);
cb(null, 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,35 +98,53 @@ export default class MiniMeToken {
}
static deploy(web3, opts, cb) {
const params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
async.series([
(cb1) => {
params.abi = MiniMeTokenFactoryAbi;
params.byteCode = MiniMeTokenFactoryByteCode;
deploy(web3, params, (err, _tokenFactory) => {
if (err) {
cb1(err);
return;
}
params.tokenFactory = _tokenFactory.address;
cb1();
});
},
(cb1) => {
params.abi = MiniMeTokenAbi;
params.byteCode = MiniMeTokenByteCode;
deploy(web3, params, cb1);
},
],
(err, res) => {
if (err) return cb(err);
const minime = new MiniMeToken(web3, res[ 1 ].address);
cb(null, minime);
const promise = new Promise((resolve, reject) => {
const params = Object.assign({}, opts);
params.parentToken = params.parentToken || 0;
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
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([
(cb1) => {
params.abi = MiniMeTokenFactoryAbi;
params.byteCode = MiniMeTokenFactoryByteCode;
deploy(web3, params, (err, _tokenFactory) => {
if (err) {
cb1(err);
return;
}
params.tokenFactory = _tokenFactory.address;
cb1();
});
},
(cb1) => {
params.abi = MiniMeTokenAbi;
params.byteCode = MiniMeTokenByteCode;
deploy(web3, params, cb1);
},
],
(err, res) => {
if (err) {
reject(err);
return;
}
const minime = new MiniMeToken(web3, res[ 1 ].address);
resolve(minime);
});
});
if (cb) {
promise.then(
(value) => {
cb(null, value);
},
(reason) => {
cb(reason);
});
} else {
return promise;
}
}
createCloneToken(opts, cb) {

View File

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