update LPVault to latest aragonOs & solidity compiler
This commit is contained in:
parent
24ec03a4fe
commit
54a1faf570
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.4.18;
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2017, Jordi Baylina
|
Copyright 2017, Jordi Baylina
|
||||||
|
@ -24,9 +24,8 @@ pragma solidity ^0.4.18;
|
||||||
/// be a safe place to store funds equipped with optional variable time delays
|
/// be a safe place to store funds equipped with optional variable time delays
|
||||||
/// to allow for an optional escapeHatch to be implemented in case of issues;
|
/// to allow for an optional escapeHatch to be implemented in case of issues;
|
||||||
/// future versions of this contract will be enabled for tokens
|
/// future versions of this contract will be enabled for tokens
|
||||||
import "./EscapableApp.sol";
|
|
||||||
import "./LiquidPledgingACLHelpers.sol";
|
import "./LiquidPledgingACLHelpers.sol";
|
||||||
import "giveth-common-contracts/contracts/ERC20.sol";
|
import "@aragon/os/contracts/apps/AragonApp.sol";
|
||||||
|
|
||||||
/// @dev `LiquidPledging` is a basic interface to allow the `LPVault` contract
|
/// @dev `LiquidPledging` is a basic interface to allow the `LPVault` contract
|
||||||
/// to confirm and cancel payments in the `LiquidPledging` contract.
|
/// to confirm and cancel payments in the `LiquidPledging` contract.
|
||||||
|
@ -37,11 +36,12 @@ contract ILiquidPledging {
|
||||||
|
|
||||||
/// @dev `LPVault` is a higher level contract built off of the `Escapable`
|
/// @dev `LPVault` is a higher level contract built off of the `Escapable`
|
||||||
/// contract that holds funds for the liquid pledging system.
|
/// contract that holds funds for the liquid pledging system.
|
||||||
contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
contract LPVault is AragonApp, LiquidPledgingACLHelpers {
|
||||||
|
|
||||||
bytes32 constant public CONFIRM_PAYMENT_ROLE = keccak256("CONFIRM_PAYMENT_ROLE");
|
bytes32 constant public CONFIRM_PAYMENT_ROLE = keccak256("CONFIRM_PAYMENT_ROLE");
|
||||||
bytes32 constant public CANCEL_PAYMENT_ROLE = keccak256("CANCEL_PAYMENT_ROLE");
|
bytes32 constant public CANCEL_PAYMENT_ROLE = keccak256("CANCEL_PAYMENT_ROLE");
|
||||||
bytes32 constant public SET_AUTOPAY_ROLE = keccak256("SET_AUTOPAY_ROLE");
|
bytes32 constant public SET_AUTOPAY_ROLE = keccak256("SET_AUTOPAY_ROLE");
|
||||||
|
bytes32 constant public ESCAPE_HATCH_CALLER_ROLE = keccak256("ESCAPE_HATCH_CALLER_ROLE");
|
||||||
|
|
||||||
event AutoPaySet(bool autoPay);
|
event AutoPaySet(bool autoPay);
|
||||||
event EscapeFundsCalled(address token, uint amount);
|
event EscapeFundsCalled(address token, uint amount);
|
||||||
|
@ -85,22 +85,9 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function LPVault(address _escapeHatchDestination) EscapableApp(_escapeHatchDestination) public {
|
/// @param _liquidPledging Address of the liquidPledging instance associated
|
||||||
}
|
/// with this LPVault
|
||||||
|
function initialize(address _liquidPledging) onlyInit external {
|
||||||
function initialize(address _escapeHatchDestination) onlyInit public {
|
|
||||||
require(false); // overload the EscapableApp
|
|
||||||
_escapeHatchDestination;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param _liquidPledging
|
|
||||||
/// @param _escapeHatchDestination The address of a safe location (usu a
|
|
||||||
/// Multisig) to send the ether held in this contract; if a neutral address
|
|
||||||
/// is required, the WHG Multisig is an option:
|
|
||||||
/// 0x8Ff920020c8AD673661c8117f2855C384758C572
|
|
||||||
function initialize(address _liquidPledging, address _escapeHatchDestination) onlyInit external {
|
|
||||||
super.initialize(_escapeHatchDestination);
|
|
||||||
|
|
||||||
require(_liquidPledging != 0x0);
|
require(_liquidPledging != 0x0);
|
||||||
liquidPledging = ILiquidPledging(_liquidPledging);
|
liquidPledging = ILiquidPledging(_liquidPledging);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +99,7 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
/// every payment
|
/// every payment
|
||||||
function setAutopay(bool _automatic) external authP(SET_AUTOPAY_ROLE, arr(_automatic)) {
|
function setAutopay(bool _automatic) external authP(SET_AUTOPAY_ROLE, arr(_automatic)) {
|
||||||
autoPay = _automatic;
|
autoPay = _automatic;
|
||||||
AutoPaySet(autoPay);
|
emit AutoPaySet(autoPay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice If `autoPay == true` the transfer happens automatically `else` the `owner`
|
/// @notice If `autoPay == true` the transfer happens automatically `else` the `owner`
|
||||||
|
@ -137,7 +124,7 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
payments[idPayment].token = _token;
|
payments[idPayment].token = _token;
|
||||||
payments[idPayment].amount = _amount;
|
payments[idPayment].amount = _amount;
|
||||||
|
|
||||||
AuthorizePayment(idPayment, _ref, _dest, _token, _amount);
|
emit AuthorizePayment(idPayment, _ref, _dest, _token, _amount);
|
||||||
|
|
||||||
if (autoPay) {
|
if (autoPay) {
|
||||||
_doConfirmPayment(idPayment);
|
_doConfirmPayment(idPayment);
|
||||||
|
@ -180,16 +167,16 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transfer tokens to the escapeHatchDestination.
|
/**
|
||||||
/// Used as a safety mechanism to prevent the vault from holding too much value
|
* @dev By default, AragonApp will allow anyone to call transferToVault
|
||||||
/// before being thoroughly battle-tested.
|
* Because this app is designed to hold funds, we only want to call
|
||||||
/// @param _token to transfer
|
* transferToVault in the case of an emergency. Only senders with the
|
||||||
/// @param _amount to transfer
|
* ESCAPE_HATCH_CALLER_ROLE are allowed to pull the "escapeHatch"
|
||||||
function escapeFunds(address _token, uint _amount) external authP(ESCAPE_HATCH_CALLER_ROLE, arr(_token)) {
|
* @param token Token address that would be recovered
|
||||||
require(_token != 0x0);
|
* @return bool whether the app allows the recovery
|
||||||
ERC20 token = ERC20(_token);
|
*/
|
||||||
require(token.transfer(escapeHatchDestination, _amount));
|
function allowRecoverability(address token) public view returns (bool) {
|
||||||
EscapeFundsCalled(_token, _amount);
|
return canPerform(msg.sender, ESCAPE_HATCH_CALLER_ROLE, arr(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return The total number of payments that have ever been authorized
|
/// @return The total number of payments that have ever been authorized
|
||||||
|
@ -211,7 +198,7 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
ERC20 token = ERC20(p.token);
|
ERC20 token = ERC20(p.token);
|
||||||
require(token.transfer(p.dest, p.amount)); // Transfers token to dest
|
require(token.transfer(p.dest, p.amount)); // Transfers token to dest
|
||||||
|
|
||||||
ConfirmPayment(_idPayment, p.ref);
|
emit ConfirmPayment(_idPayment, p.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Cancels a pending payment (internal function)
|
/// @notice Cancels a pending payment (internal function)
|
||||||
|
@ -225,6 +212,6 @@ contract LPVault is EscapableApp, LiquidPledgingACLHelpers {
|
||||||
|
|
||||||
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
||||||
|
|
||||||
CancelPayment(_idPayment, p.ref);
|
emit CancelPayment(_idPayment, p.ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
|
@ -9,8 +9,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build; mocha --harmony",
|
"test": "npm run build; mocha --harmony",
|
||||||
"sol-compile":
|
"sol-compile": "solcpiler -i './contracts/**/*.sol' ./node_modules/@aragon/os/contracts/{kernel/Kernel.sol,acl/ACL.sol}",
|
||||||
"solcpiler --solc-version v0.4.18+commit.9cf6e910 -i './contracts/**/*.sol' ./node_modules/@aragon/os/contracts/{kernel/Kernel.sol,acl/ACL.sol}",
|
|
||||||
"js-compile": "babel -d lib/ js/",
|
"js-compile": "babel -d lib/ js/",
|
||||||
"build": "npm run sol-compile; npm run js-compile",
|
"build": "npm run sol-compile; npm run js-compile",
|
||||||
"prepublish": "npm run build"
|
"prepublish": "npm run build"
|
||||||
|
@ -19,7 +18,15 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/Giveth/liquidpledging.git"
|
"url": "git+https://github.com/Giveth/liquidpledging.git"
|
||||||
},
|
},
|
||||||
"keywords": ["liquid", "pledging", "tracking", "smart", "contract", "solidity", "donation"],
|
"keywords": [
|
||||||
|
"liquid",
|
||||||
|
"pledging",
|
||||||
|
"tracking",
|
||||||
|
"smart",
|
||||||
|
"contract",
|
||||||
|
"solidity",
|
||||||
|
"donation"
|
||||||
|
],
|
||||||
"author": "Jordi Baylina",
|
"author": "Jordi Baylina",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
@ -37,15 +44,15 @@
|
||||||
"lerna": "^2.2.0",
|
"lerna": "^2.2.0",
|
||||||
"mocha": "^3.5.0",
|
"mocha": "^3.5.0",
|
||||||
"random-bytes": "^1.0.0",
|
"random-bytes": "^1.0.0",
|
||||||
"solcpiler": "https://github.com/perissology/solcpiler.git#6393e66",
|
"solcpiler": "1.0.0-beta.2",
|
||||||
"web3": "1.0.0-beta.31"
|
"web3": "1.0.0-beta.34"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Giveth/liquidpledging#readme",
|
"homepage": "https://github.com/Giveth/liquidpledging#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aragon/os": "3.0.1",
|
"@aragon/os": "3.1.9",
|
||||||
"async": "^2.4.0",
|
"async": "^2.4.0",
|
||||||
"chai": "^4.1.0",
|
"chai": "^4.1.0",
|
||||||
"eth-contract-class": "^0.0.9",
|
"eth-contract-class": "^0.0.9",
|
||||||
"giveth-common-contracts": "^0.4.0"
|
"giveth-common-contracts": "0.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue