mirror of https://github.com/vacp2p/minime.git
Merge pull request #17 from Giveth/fixRaceConditionClone2
Fix race condition and allow to clone a token in the future
This commit is contained in:
commit
6a5e38f4bd
|
@ -208,6 +208,8 @@ contract MiniMeToken is Controlled {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (parentSnapShotBlock >= block.number) throw;
|
||||
|
||||
// Do not allow transfer to 0x0 or the token contract itself
|
||||
if ((_to == 0) || (_to == address(this))) throw;
|
||||
|
||||
|
@ -376,7 +378,7 @@ contract MiniMeToken is Controlled {
|
|||
/// @param _cloneTokenSymbol Symbol of the clone token
|
||||
/// @param _snapshotBlock Block when the distribution of the parent token is
|
||||
/// copied to set the initial distribution of the new clone token;
|
||||
/// if the block is higher than the actual block, the current block is used
|
||||
/// if the block is zero than the actual block, the current block is used
|
||||
/// @param _transfersEnabled True if transfers are allowed in the clone
|
||||
/// @return The address of the new MiniMeToken Contract
|
||||
function createCloneToken(
|
||||
|
@ -386,7 +388,7 @@ contract MiniMeToken is Controlled {
|
|||
uint _snapshotBlock,
|
||||
bool _transfersEnabled
|
||||
) returns(address) {
|
||||
if (_snapshotBlock > block.number) _snapshotBlock = block.number;
|
||||
if (_snapshotBlock == 0) _snapshotBlock = block.number;
|
||||
MiniMeToken cloneToken = tokenFactory.createCloneToken(
|
||||
this,
|
||||
_snapshotBlock,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -269,7 +269,7 @@ describe("MiniMeToken test", () => {
|
|||
cloneTokenName: "Clone Token 1",
|
||||
cloneDecimalUnits: 18,
|
||||
cloneTokenSymbol: "MMTc",
|
||||
snapshotBlock: Number.MAX_SAFE_INTEGER,
|
||||
snapshotBlock: 0,
|
||||
transfersEnabled: true,
|
||||
}, (err, _miniMeTokenClone) => {
|
||||
assert.ifError(err);
|
||||
|
@ -319,6 +319,7 @@ describe("MiniMeToken test", () => {
|
|||
to: ethConnector.accounts[ 2 ],
|
||||
amount: 4,
|
||||
from: ethConnector.accounts[ 1 ],
|
||||
gas: 200000,
|
||||
}, cb);
|
||||
},
|
||||
(cb) => {
|
||||
|
@ -403,7 +404,7 @@ describe("MiniMeToken test", () => {
|
|||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
}).timeout(6000000);
|
||||
|
||||
function log(S) {
|
||||
if (verbose) {
|
||||
|
|
Loading…
Reference in New Issue