mirror of https://github.com/vacp2p/minime.git
test
This commit is contained in:
parent
81a606675c
commit
72437eabc6
|
@ -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
|
@ -264,31 +264,46 @@ var MiniMeToken = function () {
|
||||||
}], [{
|
}], [{
|
||||||
key: "deploy",
|
key: "deploy",
|
||||||
value: function deploy(web3, opts, cb) {
|
value: function deploy(web3, opts, cb) {
|
||||||
var params = Object.assign({}, opts);
|
var promise = new Promise(function (resolve, reject) {
|
||||||
params.parentToken = params.parentToken || 0;
|
var params = Object.assign({}, opts);
|
||||||
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
|
params.parentToken = params.parentToken || 0;
|
||||||
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
|
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
|
||||||
|
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
|
||||||
|
|
||||||
_async2.default.series([function (cb1) {
|
_async2.default.series([function (cb1) {
|
||||||
params.abi = _MiniMeTokenSol.MiniMeTokenFactoryAbi;
|
params.abi = _MiniMeTokenSol.MiniMeTokenFactoryAbi;
|
||||||
params.byteCode = _MiniMeTokenSol.MiniMeTokenFactoryByteCode;
|
params.byteCode = _MiniMeTokenSol.MiniMeTokenFactoryByteCode;
|
||||||
(0, _runethtx.deploy)(web3, params, function (err, _tokenFactory) {
|
(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) {
|
if (err) {
|
||||||
cb1(err);
|
reject(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
params.tokenFactory = _tokenFactory.address;
|
var minime = new MiniMeToken(web3, res[1].address);
|
||||||
cb1();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -98,35 +98,53 @@ export default class MiniMeToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
static deploy(web3, opts, cb) {
|
static deploy(web3, opts, cb) {
|
||||||
const params = Object.assign({}, opts);
|
const promise = new Promise((resolve, reject) => {
|
||||||
params.parentToken = params.parentToken || 0;
|
const params = Object.assign({}, opts);
|
||||||
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
|
params.parentToken = params.parentToken || 0;
|
||||||
params.transfersEnabled = typeof params.transfersEnabled === "undefined" ? true : params.transfersEnabled;
|
params.parentSnapShotBlock = params.parentSnapShotBlock || 0;
|
||||||
|
params.transfersEnabled = (typeof params.transfersEnabled === "undefined") ? true : params.transfersEnabled;
|
||||||
async.series([
|
console.log("1-> "+JSON.stringify(params, null, 2));
|
||||||
(cb1) => {
|
console.log("2-> "+typeof params.transfersEnabled);
|
||||||
params.abi = MiniMeTokenFactoryAbi;
|
async.series([
|
||||||
params.byteCode = MiniMeTokenFactoryByteCode;
|
(cb1) => {
|
||||||
deploy(web3, params, (err, _tokenFactory) => {
|
params.abi = MiniMeTokenFactoryAbi;
|
||||||
if (err) {
|
params.byteCode = MiniMeTokenFactoryByteCode;
|
||||||
cb1(err);
|
deploy(web3, params, (err, _tokenFactory) => {
|
||||||
return;
|
if (err) {
|
||||||
}
|
cb1(err);
|
||||||
params.tokenFactory = _tokenFactory.address;
|
return;
|
||||||
cb1();
|
}
|
||||||
});
|
params.tokenFactory = _tokenFactory.address;
|
||||||
},
|
cb1();
|
||||||
(cb1) => {
|
});
|
||||||
params.abi = MiniMeTokenAbi;
|
},
|
||||||
params.byteCode = MiniMeTokenByteCode;
|
(cb1) => {
|
||||||
deploy(web3, params, 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);
|
(err, res) => {
|
||||||
cb(null, minime);
|
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) {
|
createCloneToken(opts, cb) {
|
||||||
|
|
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in New Issue