make LiquidPledgingEscapable
This commit is contained in:
parent
49540b1eb7
commit
9cf0856e3d
|
@ -12,7 +12,7 @@
|
|||
"no-with": true,
|
||||
"no-empty-blocks": true,
|
||||
"no-unused-vars": true,
|
||||
"double-quotes": true,
|
||||
"quotes": true,
|
||||
"blank-lines": true,
|
||||
"indentation": true,
|
||||
"whitespace": true,
|
||||
|
|
|
@ -7,7 +7,8 @@ pragma solidity ^0.4.11;
|
|||
/// safety precaution, but once fully tested and optimized this contract will
|
||||
/// be a safe place to store funds equipped with optional variable time delays
|
||||
/// to allow for an optional escape hatch to be implemented
|
||||
import "../node_modules/giveth-common-contracts/contracts/Escapable.sol";
|
||||
import "giveth-common-contracts/contracts/Escapable.sol";
|
||||
|
||||
|
||||
/// @dev `LiquidPledging` is a basic interface to allow the `LPVault` contract
|
||||
/// to confirm and cancel payments in the `LiquidPledging` contract.
|
||||
|
@ -42,8 +43,9 @@ contract LPVault is Escapable {
|
|||
// @dev An array that contains all the payments for this LPVault
|
||||
Payment[] public payments;
|
||||
|
||||
function Vault(address _escapeHatchCaller, address _escapeHatchDestination)
|
||||
Escapable(_escapeHatchCaller, _escapeHatchDestination) public {
|
||||
function LPVault(address _escapeHatchCaller, address _escapeHatchDestination)
|
||||
Escapable(_escapeHatchCaller, _escapeHatchDestination) public
|
||||
{
|
||||
}
|
||||
|
||||
/// @dev `liquidPledging` is the only address that can call a function with
|
||||
|
@ -82,7 +84,9 @@ contract LPVault is Escapable {
|
|||
function authorizePayment(
|
||||
bytes32 _ref,
|
||||
address _dest,
|
||||
uint _amount ) public onlyLiquidPledging returns (uint) {
|
||||
uint _amount
|
||||
) public onlyLiquidPledging returns (uint)
|
||||
{
|
||||
uint idPayment = payments.length;
|
||||
payments.length ++;
|
||||
payments[idPayment].state = PaymentStatus.Pending;
|
||||
|
|
|
@ -37,7 +37,12 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||
/// @dev This constructor also calls the constructor
|
||||
/// for `LiquidPledgingBase`
|
||||
/// @param _vault The vault where ETH backing this pledge is stored
|
||||
function LiquidPledging(address _vault) LiquidPledgingBase(_vault) {
|
||||
function LiquidPledging(
|
||||
address _vault,
|
||||
address _escapeHatchCaller,
|
||||
address _escapeHatchDestination
|
||||
) LiquidPledgingBase(_vault, _escapeHatchCaller, _escapeHatchDestination) {
|
||||
|
||||
}
|
||||
|
||||
/// @notice This is how value enters into the system which creates pledges;
|
||||
|
|
|
@ -18,7 +18,7 @@ pragma solidity ^0.4.11;
|
|||
*/
|
||||
|
||||
import "./ILiquidPledgingPlugin.sol";
|
||||
import "../node_modules/giveth-common-contracts/contracts/Owned.sol";
|
||||
import "giveth-common-contracts/contracts/Escapable.sol";
|
||||
|
||||
/// @dev `LPVault` serves as an interface to allow the `LiquidPledgingBase`
|
||||
/// contract to interface with a `LPVault` contract
|
||||
|
@ -30,7 +30,7 @@ contract LPVault {
|
|||
/// @dev `LiquidPledgingBase` is the base level contract used to carry out
|
||||
/// liquid pledging's most basic functions, mostly handling and searching the
|
||||
/// data structures
|
||||
contract LiquidPledgingBase is Owned {
|
||||
contract LiquidPledgingBase is Escapable {
|
||||
|
||||
// Limits inserted to prevent large loops that could prevent canceling
|
||||
uint constant MAX_DELEGATES = 20;
|
||||
|
@ -97,7 +97,11 @@ contract LiquidPledgingBase is Owned {
|
|||
|
||||
/// @notice The Constructor creates `LiquidPledgingBase` on the blockchain
|
||||
/// @param _vault The vault where the ETH backing the pledges is stored
|
||||
function LiquidPledgingBase(address _vault) {
|
||||
function LiquidPledgingBase(
|
||||
address _vault,
|
||||
address _escapeHatchCaller,
|
||||
address _escapeHatchDestination
|
||||
) Escapable(_escapeHatchCaller, _escapeHatchDestination) public {
|
||||
admins.length = 1; // we reserve the 0 admin
|
||||
pledges.length = 1; // we reserve the 0 pledge
|
||||
vault = LPVault(_vault); // Assigns the specified vault
|
||||
|
|
|
@ -29,7 +29,11 @@ contract LiquidPledgingMock is LiquidPledging {
|
|||
/// @dev `LiquidPledgingMock` creates a standard `LiquidPledging`
|
||||
/// instance and sets the mocked time to the current blocktime.
|
||||
/// @param _vault The vault where ETH backing this pledge is stored
|
||||
function LiquidPledgingMock(address _vault) LiquidPledging(_vault) {
|
||||
function LiquidPledgingMock(
|
||||
address _vault,
|
||||
address _escapeHatchCaller,
|
||||
address _escapeHatchDestination
|
||||
) LiquidPledging(_vault, _escapeHatchCaller, _escapeHatchDestination) {
|
||||
mock_time = now;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('LiquidPledging plugins test', function () {
|
|||
|
||||
it('Should deploy LiquidPledging contract', async function() {
|
||||
vault = await Vault.new(web3, accounts[0], accounts[1]);
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 6500000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 6500000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address);
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('LiquidPledging cancelPledge normal scenario', function () {
|
|||
|
||||
it('Should deploy LiquidPledging contract', async () => {
|
||||
vault = await Vault.new(web3, accounts[0], accounts[1]);
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address);
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
});
|
||||
|
|
|
@ -58,7 +58,7 @@ describe('DelegationChain test', function () {
|
|||
|
||||
it('Should deploy LiquidPledging contract', async () => {
|
||||
vault = await Vault.new(web3, accounts[0], accounts[1]);
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address);
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
});
|
||||
|
|
|
@ -63,7 +63,7 @@ describe('LiquidPledging test', function () {
|
|||
|
||||
it('Should deploy LiquidPledging contract', async () => {
|
||||
vault = await LPVault.new(web3, accounts[0], accounts[1]);
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address);
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
});
|
||||
|
|
|
@ -58,7 +58,7 @@ describe('NormalizePledge test', function () {
|
|||
|
||||
it('Should deploy LiquidPledging contract', async () => {
|
||||
vault = await Vault.new(web3, accounts[0], accounts[1]);
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address);
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ const assertFail = require('./helpers/assertFail');
|
|||
|
||||
const LiquidPledging = liquidpledging.LiquidPledgingMock;
|
||||
const LiquidPledgingState = liquidpledging.LiquidPledgingState;
|
||||
const Vault = liquidpledging.Vault;
|
||||
const Vault = liquidpledging.LPVault;
|
||||
const assert = chai.assert;
|
||||
|
||||
describe('Vault test', function () {
|
||||
|
@ -51,7 +51,7 @@ describe('Vault test', function () {
|
|||
|
||||
it('Should deploy Vault contract', async function () {
|
||||
vault = await Vault.new(web3, escapeHatchCaller, escapeHatchDestination, { from: vaultOwner });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 6500000 });
|
||||
liquidPledging = await LiquidPledging.new(web3, vault.$address, escapeHatchCaller, escapeHatchDestination, { gas: 6500000 });
|
||||
await vault.setLiquidPledging(liquidPledging.$address, { from: vaultOwner });
|
||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||
|
||||
|
@ -94,7 +94,5 @@ describe('Vault test', function () {
|
|||
|
||||
assert.equal(expected, postBalance);
|
||||
});
|
||||
|
||||
it('should')
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue