Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit 9cf0856

Browse files
committed
make LiquidPledgingEscapable
1 parent 49540b1 commit 9cf0856

11 files changed

+34
-19
lines changed

.soliumrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"no-with": true,
1313
"no-empty-blocks": true,
1414
"no-unused-vars": true,
15-
"double-quotes": true,
15+
"quotes": true,
1616
"blank-lines": true,
1717
"indentation": true,
1818
"whitespace": true,

contracts/LPVault.sol

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ pragma solidity ^0.4.11;
77
/// safety precaution, but once fully tested and optimized this contract will
88
/// be a safe place to store funds equipped with optional variable time delays
99
/// to allow for an optional escape hatch to be implemented
10-
import "../node_modules/giveth-common-contracts/contracts/Escapable.sol";
10+
import "giveth-common-contracts/contracts/Escapable.sol";
11+
1112

1213
/// @dev `LiquidPledging` is a basic interface to allow the `LPVault` contract
1314
/// to confirm and cancel payments in the `LiquidPledging` contract.
@@ -42,8 +43,9 @@ contract LPVault is Escapable {
4243
// @dev An array that contains all the payments for this LPVault
4344
Payment[] public payments;
4445

45-
function Vault(address _escapeHatchCaller, address _escapeHatchDestination)
46-
Escapable(_escapeHatchCaller, _escapeHatchDestination) public {
46+
function LPVault(address _escapeHatchCaller, address _escapeHatchDestination)
47+
Escapable(_escapeHatchCaller, _escapeHatchDestination) public
48+
{
4749
}
4850

4951
/// @dev `liquidPledging` is the only address that can call a function with
@@ -82,7 +84,9 @@ contract LPVault is Escapable {
8284
function authorizePayment(
8385
bytes32 _ref,
8486
address _dest,
85-
uint _amount ) public onlyLiquidPledging returns (uint) {
87+
uint _amount
88+
) public onlyLiquidPledging returns (uint)
89+
{
8690
uint idPayment = payments.length;
8791
payments.length ++;
8892
payments[idPayment].state = PaymentStatus.Pending;

contracts/LiquidPledging.sol

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ contract LiquidPledging is LiquidPledgingBase {
3737
/// @dev This constructor also calls the constructor
3838
/// for `LiquidPledgingBase`
3939
/// @param _vault The vault where ETH backing this pledge is stored
40-
function LiquidPledging(address _vault) LiquidPledgingBase(_vault) {
40+
function LiquidPledging(
41+
address _vault,
42+
address _escapeHatchCaller,
43+
address _escapeHatchDestination
44+
) LiquidPledgingBase(_vault, _escapeHatchCaller, _escapeHatchDestination) {
45+
4146
}
4247

4348
/// @notice This is how value enters into the system which creates pledges;

contracts/LiquidPledgingBase.sol

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pragma solidity ^0.4.11;
1818
*/
1919

2020
import "./ILiquidPledgingPlugin.sol";
21-
import "../node_modules/giveth-common-contracts/contracts/Owned.sol";
21+
import "giveth-common-contracts/contracts/Escapable.sol";
2222

2323
/// @dev `LPVault` serves as an interface to allow the `LiquidPledgingBase`
2424
/// contract to interface with a `LPVault` contract
@@ -30,7 +30,7 @@ contract LPVault {
3030
/// @dev `LiquidPledgingBase` is the base level contract used to carry out
3131
/// liquid pledging's most basic functions, mostly handling and searching the
3232
/// data structures
33-
contract LiquidPledgingBase is Owned {
33+
contract LiquidPledgingBase is Escapable {
3434

3535
// Limits inserted to prevent large loops that could prevent canceling
3636
uint constant MAX_DELEGATES = 20;
@@ -97,7 +97,11 @@ contract LiquidPledgingBase is Owned {
9797

9898
/// @notice The Constructor creates `LiquidPledgingBase` on the blockchain
9999
/// @param _vault The vault where the ETH backing the pledges is stored
100-
function LiquidPledgingBase(address _vault) {
100+
function LiquidPledgingBase(
101+
address _vault,
102+
address _escapeHatchCaller,
103+
address _escapeHatchDestination
104+
) Escapable(_escapeHatchCaller, _escapeHatchDestination) public {
101105
admins.length = 1; // we reserve the 0 admin
102106
pledges.length = 1; // we reserve the 0 pledge
103107
vault = LPVault(_vault); // Assigns the specified vault

contracts/LiquidPledgingMock.sol

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ contract LiquidPledgingMock is LiquidPledging {
2929
/// @dev `LiquidPledgingMock` creates a standard `LiquidPledging`
3030
/// instance and sets the mocked time to the current blocktime.
3131
/// @param _vault The vault where ETH backing this pledge is stored
32-
function LiquidPledgingMock(address _vault) LiquidPledging(_vault) {
32+
function LiquidPledgingMock(
33+
address _vault,
34+
address _escapeHatchCaller,
35+
address _escapeHatchDestination
36+
) LiquidPledging(_vault, _escapeHatchCaller, _escapeHatchDestination) {
3337
mock_time = now;
3438
}
3539

test/AdminPlugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('LiquidPledging plugins test', function () {
5555

5656
it('Should deploy LiquidPledging contract', async function() {
5757
vault = await Vault.new(web3, accounts[0], accounts[1]);
58-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 6500000 });
58+
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 6500000 });
5959
await vault.setLiquidPledging(liquidPledging.$address);
6060
liquidPledgingState = new LiquidPledgingState(liquidPledging);
6161
});

test/CancelPledge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('LiquidPledging cancelPledge normal scenario', function () {
5252

5353
it('Should deploy LiquidPledging contract', async () => {
5454
vault = await Vault.new(web3, accounts[0], accounts[1]);
55-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
55+
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
5656
await vault.setLiquidPledging(liquidPledging.$address);
5757
liquidPledgingState = new LiquidPledgingState(liquidPledging);
5858
});

test/DelegationChain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('DelegationChain test', function () {
5858

5959
it('Should deploy LiquidPledging contract', async () => {
6060
vault = await Vault.new(web3, accounts[0], accounts[1]);
61-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
61+
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
6262
await vault.setLiquidPledging(liquidPledging.$address);
6363
liquidPledgingState = new LiquidPledgingState(liquidPledging);
6464
});

test/NormalOperation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('LiquidPledging test', function () {
6363

6464
it('Should deploy LiquidPledging contract', async () => {
6565
vault = await LPVault.new(web3, accounts[0], accounts[1]);
66-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
66+
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
6767
await vault.setLiquidPledging(liquidPledging.$address);
6868
liquidPledgingState = new LiquidPledgingState(liquidPledging);
6969
});

test/NormalizePledge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('NormalizePledge test', function () {
5858

5959
it('Should deploy LiquidPledging contract', async () => {
6060
vault = await Vault.new(web3, accounts[0], accounts[1]);
61-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
61+
liquidPledging = await LiquidPledging.new(web3, vault.$address, accounts[0], accounts[1], { gas: 5800000 });
6262
await vault.setLiquidPledging(liquidPledging.$address);
6363
liquidPledgingState = new LiquidPledgingState(liquidPledging);
6464
});

test/Vault.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const assertFail = require('./helpers/assertFail');
88

99
const LiquidPledging = liquidpledging.LiquidPledgingMock;
1010
const LiquidPledgingState = liquidpledging.LiquidPledgingState;
11-
const Vault = liquidpledging.Vault;
11+
const Vault = liquidpledging.LPVault;
1212
const assert = chai.assert;
1313

1414
describe('Vault test', function () {
@@ -51,7 +51,7 @@ describe('Vault test', function () {
5151

5252
it('Should deploy Vault contract', async function () {
5353
vault = await Vault.new(web3, escapeHatchCaller, escapeHatchDestination, { from: vaultOwner });
54-
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 6500000 });
54+
liquidPledging = await LiquidPledging.new(web3, vault.$address, escapeHatchCaller, escapeHatchDestination, { gas: 6500000 });
5555
await vault.setLiquidPledging(liquidPledging.$address, { from: vaultOwner });
5656
liquidPledgingState = new LiquidPledgingState(liquidPledging);
5757

@@ -94,7 +94,5 @@ describe('Vault test', function () {
9494

9595
assert.equal(expected, postBalance);
9696
});
97-
98-
it('should')
9997
});
10098

0 commit comments

Comments
 (0)