liquid-funding-console/contracts/test/TestSimpleProjectPlugin.sol

54 lines
1.5 KiB
Solidity

pragma solidity ^0.4.18;
import "../LiquidPledging.sol";
// simple liquidPledging plugin contract for testing whitelist
contract TestSimpleProjectPlugin {
uint64 public idProject;
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);
function TestSimpleProjectPlugin() public {
require(msg.sender != tx.origin); // Avoids being created directly by mistake.
initPending = true;
}
function init(
LiquidPledging liquidPledging,
string name,
string url,
uint64 parentProject
) public {
require(initPending);
idProject = liquidPledging.addProject(name, url, address(this), parentProject, 0, ILiquidPledgingPlugin(this));
initPending = false;
}
function beforeTransfer(
uint64 pledgeAdmin,
uint64 pledgeFrom,
uint64 pledgeTo,
uint64 context,
uint amount
) external returns (uint maxAllowed) {
require(!initPending);
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);
}
}