2018-06-16 00:27:47 +00:00
|
|
|
pragma solidity ^0.4.18;
|
2018-01-24 17:57:03 +00:00
|
|
|
|
|
|
|
import "../LiquidPledging.sol";
|
|
|
|
|
|
|
|
// simple liquidPledging plugin contract for testing whitelist
|
|
|
|
contract TestSimpleDelegatePlugin {
|
|
|
|
|
|
|
|
uint64 public idDelegate;
|
|
|
|
LiquidPledging liquidPledging;
|
|
|
|
bool initPending;
|
|
|
|
|
|
|
|
event BeforeTransfer(uint64 pledgeAdmin, uint64 pledgeFrom, uint64 pledgeTo, uint64 context, uint amount);
|
|
|
|
event AfterTransfer(uint64 pledgeAdmin, uint64 pledgeFrom, uint64 pledgeTo, uint64 context, uint amount);
|
|
|
|
|
2018-03-27 17:55:37 +00:00
|
|
|
function TestSimpleDelegatePlugin(LiquidPledging _liquidPledging) public {
|
2018-01-24 17:57:03 +00:00
|
|
|
require(msg.sender != tx.origin); // Avoids being created directly by mistake.
|
|
|
|
liquidPledging = _liquidPledging;
|
|
|
|
initPending = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function init(
|
|
|
|
string name,
|
|
|
|
string url,
|
|
|
|
uint64 commitTime
|
2018-03-27 17:55:37 +00:00
|
|
|
) public {
|
2018-01-24 17:57:03 +00:00
|
|
|
require(initPending);
|
|
|
|
idDelegate = liquidPledging.addDelegate(name, url, commitTime, ILiquidPledgingPlugin(this));
|
|
|
|
initPending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function beforeTransfer(
|
|
|
|
uint64 pledgeAdmin,
|
|
|
|
uint64 pledgeFrom,
|
|
|
|
uint64 pledgeTo,
|
|
|
|
uint64 context,
|
|
|
|
uint amount
|
|
|
|
) external returns (uint maxAllowed) {
|
|
|
|
require(!initPending);
|
2018-06-16 00:27:47 +00:00
|
|
|
maxAllowed;
|
2018-01-24 17:57:03 +00:00
|
|
|
BeforeTransfer(pledgeAdmin, pledgeFrom, pledgeTo, context, amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
function afterTransfer(
|
|
|
|
uint64 pledgeAdmin,
|
|
|
|
uint64 pledgeFrom,
|
|
|
|
uint64 pledgeTo,
|
|
|
|
uint64 context,
|
|
|
|
uint amount
|
|
|
|
) external {
|
|
|
|
require(!initPending);
|
|
|
|
AfterTransfer(pledgeAdmin, pledgeFrom, pledgeTo, context, amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
contract TestSimpleDelegatePluginFactory {
|
|
|
|
|
2018-03-27 17:55:37 +00:00
|
|
|
function TestSimpleDelegatePluginFactory(
|
2018-01-24 17:57:03 +00:00
|
|
|
LiquidPledging liquidPledging,
|
|
|
|
string name,
|
|
|
|
string url,
|
|
|
|
uint64 commitTime
|
2018-03-27 17:55:37 +00:00
|
|
|
) public {
|
2018-01-24 17:57:03 +00:00
|
|
|
TestSimpleDelegatePlugin d = new TestSimpleDelegatePlugin(liquidPledging);
|
|
|
|
d.init(name, url, commitTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|