liquid-funding/contracts/test/TestSimpleDelegatePlugin.sol

69 lines
1.9 KiB
Solidity
Raw Normal View History

2018-06-16 00:27:47 +00:00
pragma solidity ^0.4.18;
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 {
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 {
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;
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(
LiquidPledging liquidPledging,
string name,
string url,
uint64 commitTime
2018-03-27 17:55:37 +00:00
) public {
TestSimpleDelegatePlugin d = new TestSimpleDelegatePlugin(liquidPledging);
d.init(name, url, commitTime);
}
}