proposed to intended refactor

This commit is contained in:
Jordi Baylina 2017-10-04 10:33:33 +02:00
parent aaa3be9305
commit 52e439318c
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
13 changed files with 69 additions and 69 deletions

View File

@ -3,4 +3,4 @@
exports.ILiquidPledgingPluginAbi = [{"constant":false,"inputs":[{"name":"noteManager","type":"uint64"},{"name":"noteFrom","type":"uint64"},{"name":"noteTo","type":"uint64"},{"name":"context","type":"uint64"},{"name":"amount","type":"uint256"}],"name":"afterTransfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"noteManager","type":"uint64"},{"name":"noteFrom","type":"uint64"},{"name":"noteTo","type":"uint64"},{"name":"context","type":"uint64"},{"name":"amount","type":"uint256"}],"name":"beforeTransfer","outputs":[{"name":"maxAllowed","type":"uint256"}],"payable":false,"type":"function"}]
exports.ILiquidPledgingPluginByteCode = "0x"
exports._solcVersion = "0.4.15+commit.bbb8e64f.Emscripten.clang"
exports._sha256 = "0xf6e4ddd089417930fe5b9ed3413eee1cb55b4dc73b45e2cef2af9447cfbf5bbc"
exports._sha256 = "0xef8854fe0982df3dec97b6aec02e2d850ad86c960ca5b3545346b7ca4c5e8c48"

View File

@ -11,13 +11,13 @@ contract ILiquidPledgingPlugin {
/// 1 -> Plugin for the first delegate transferring pledge to another party
/// 2 -> Plugin for the second delegate transferring pledge to another party
/// ...
/// 255 -> Plugin for the proposedCampaign transferring pledge to another party
/// 255 -> Plugin for the intendedCampaign transferring pledge to another party
///
/// 256 -> Plugin for the owner receiving pledge to another party
/// 257 -> Plugin for the first delegate receiving pledge to another party
/// 258 -> Plugin for the second delegate receiving pledge to another party
/// ...
/// 511 -> Plugin for the proposedCampaign receiving pledge to another party
/// 511 -> Plugin for the intendedCampaign receiving pledge to another party
function beforeTransfer(
uint64 noteManager,
uint64 noteFrom,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,13 +11,13 @@ contract ILiquidPledgingPlugin {
/// 1 -> Plugin for the first delegate transferring pledge to another party
/// 2 -> Plugin for the second delegate transferring pledge to another party
/// ...
/// 255 -> Plugin for the proposedCampaign transferring pledge to another party
/// 255 -> Plugin for the intendedCampaign transferring pledge to another party
///
/// 256 -> Plugin for the owner receiving pledge to another party
/// 257 -> Plugin for the first delegate receiving pledge to another party
/// 258 -> Plugin for the second delegate receiving pledge to another party
/// ...
/// 511 -> Plugin for the proposedCampaign receiving pledge to another party
/// 511 -> Plugin for the intendedCampaign receiving pledge to another party
function beforeTransfer(
uint64 noteManager,
uint64 noteFrom,
@ -70,8 +70,8 @@ contract LiquidPledgingBase {
uint amount;
uint64 owner; // PledgeAdmin
uint64[] delegationChain; // list of index numbers
uint64 proposedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the proposedCampaign will become the owner
uint64 intendedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the intendedCampaign will become the owner
uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from
PaymentState paymentState;
}
@ -243,7 +243,7 @@ contract LiquidPledgingBase {
uint amount,
uint64 owner,
uint64 nDelegates,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paymentState
@ -252,7 +252,7 @@ contract LiquidPledgingBase {
amount = n.amount;
owner = n.owner;
nDelegates = uint64(n.delegationChain.length);
proposedCampaign = n.proposedCampaign;
intendedCampaign = n.intendedCampaign;
commitTime = n.commitTime;
oldPledge = n.oldPledge;
paymentState = n.paymentState;
@ -305,18 +305,18 @@ contract LiquidPledgingBase {
function findPledge(
uint64 owner,
uint64[] delegationChain,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paid
) internal returns (uint64)
{
bytes32 hPledge = sha3(owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid);
bytes32 hPledge = sha3(owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid);
uint64 idx = hPledge2idx[hPledge];
if (idx > 0) return idx;
idx = uint64(pledges.length);
hPledge2idx[hPledge] = idx;
pledges.push(Pledge(0, owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid));
pledges.push(Pledge(0, owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid));
return idx;
}

File diff suppressed because one or more lines are too long

View File

@ -11,13 +11,13 @@ contract ILiquidPledgingPlugin {
/// 1 -> Plugin for the first delegate transferring pledge to another party
/// 2 -> Plugin for the second delegate transferring pledge to another party
/// ...
/// 255 -> Plugin for the proposedCampaign transferring pledge to another party
/// 255 -> Plugin for the intendedCampaign transferring pledge to another party
///
/// 256 -> Plugin for the owner receiving pledge to another party
/// 257 -> Plugin for the first delegate receiving pledge to another party
/// 258 -> Plugin for the second delegate receiving pledge to another party
/// ...
/// 511 -> Plugin for the proposedCampaign receiving pledge to another party
/// 511 -> Plugin for the intendedCampaign receiving pledge to another party
function beforeTransfer(
uint64 noteManager,
uint64 noteFrom,
@ -70,8 +70,8 @@ contract LiquidPledgingBase {
uint amount;
uint64 owner; // PledgeAdmin
uint64[] delegationChain; // list of index numbers
uint64 proposedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the proposedCampaign will become the owner
uint64 intendedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the intendedCampaign will become the owner
uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from
PaymentState paymentState;
}
@ -243,7 +243,7 @@ contract LiquidPledgingBase {
uint amount,
uint64 owner,
uint64 nDelegates,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paymentState
@ -252,7 +252,7 @@ contract LiquidPledgingBase {
amount = n.amount;
owner = n.owner;
nDelegates = uint64(n.delegationChain.length);
proposedCampaign = n.proposedCampaign;
intendedCampaign = n.intendedCampaign;
commitTime = n.commitTime;
oldPledge = n.oldPledge;
paymentState = n.paymentState;
@ -305,18 +305,18 @@ contract LiquidPledgingBase {
function findPledge(
uint64 owner,
uint64[] delegationChain,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paid
) internal returns (uint64)
{
bytes32 hPledge = sha3(owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid);
bytes32 hPledge = sha3(owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid);
uint64 idx = hPledge2idx[hPledge];
if (idx > 0) return idx;
idx = uint64(pledges.length);
hPledge2idx[hPledge] = idx;
pledges.push(Pledge(0, owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid));
pledges.push(Pledge(0, owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid));
return idx;
}
@ -815,7 +815,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
if (n.paymentState != PaymentState.Pledged) return idPledge;
// First send to a campaign if it's proposed and commited
if ((n.proposedCampaign > 0) && ( getTime() > n.commitTime)) {
if ((n.intendedCampaign > 0) && ( getTime() > n.commitTime)) {
uint64 oldPledge = findPledge(
n.owner,
n.delegationChain,
@ -824,7 +824,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
n.oldPledge,
PaymentState.Pledged);
uint64 toPledge = findPledge(
n.proposedCampaign,
n.intendedCampaign,
new uint64[](0),
0,
0,
@ -873,8 +873,8 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
allowedAmount = callPlugin(before, n.delegationChain[i], fromPledge, toPledge, offset + i+1, allowedAmount);
}
if (n.proposedCampaign > 0) {
allowedAmount = callPlugin(before, n.proposedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
if (n.intendedCampaign > 0) {
allowedAmount = callPlugin(before, n.intendedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
}
}

View File

@ -11,13 +11,13 @@ contract ILiquidPledgingPlugin {
/// 1 -> Plugin for the first delegate transferring pledge to another party
/// 2 -> Plugin for the second delegate transferring pledge to another party
/// ...
/// 255 -> Plugin for the proposedCampaign transferring pledge to another party
/// 255 -> Plugin for the intendedCampaign transferring pledge to another party
///
/// 256 -> Plugin for the owner receiving pledge to another party
/// 257 -> Plugin for the first delegate receiving pledge to another party
/// 258 -> Plugin for the second delegate receiving pledge to another party
/// ...
/// 511 -> Plugin for the proposedCampaign receiving pledge to another party
/// 511 -> Plugin for the intendedCampaign receiving pledge to another party
function beforeTransfer(
uint64 noteManager,
uint64 noteFrom,
@ -70,8 +70,8 @@ contract LiquidPledgingBase {
uint amount;
uint64 owner; // PledgeAdmin
uint64[] delegationChain; // list of index numbers
uint64 proposedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the proposedCampaign will become the owner
uint64 intendedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the intendedCampaign will become the owner
uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from
PaymentState paymentState;
}
@ -243,7 +243,7 @@ contract LiquidPledgingBase {
uint amount,
uint64 owner,
uint64 nDelegates,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paymentState
@ -252,7 +252,7 @@ contract LiquidPledgingBase {
amount = n.amount;
owner = n.owner;
nDelegates = uint64(n.delegationChain.length);
proposedCampaign = n.proposedCampaign;
intendedCampaign = n.intendedCampaign;
commitTime = n.commitTime;
oldPledge = n.oldPledge;
paymentState = n.paymentState;
@ -305,18 +305,18 @@ contract LiquidPledgingBase {
function findPledge(
uint64 owner,
uint64[] delegationChain,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paid
) internal returns (uint64)
{
bytes32 hPledge = sha3(owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid);
bytes32 hPledge = sha3(owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid);
uint64 idx = hPledge2idx[hPledge];
if (idx > 0) return idx;
idx = uint64(pledges.length);
hPledge2idx[hPledge] = idx;
pledges.push(Pledge(0, owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid));
pledges.push(Pledge(0, owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid));
return idx;
}
@ -815,7 +815,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
if (n.paymentState != PaymentState.Pledged) return idPledge;
// First send to a campaign if it's proposed and commited
if ((n.proposedCampaign > 0) && ( getTime() > n.commitTime)) {
if ((n.intendedCampaign > 0) && ( getTime() > n.commitTime)) {
uint64 oldPledge = findPledge(
n.owner,
n.delegationChain,
@ -824,7 +824,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
n.oldPledge,
PaymentState.Pledged);
uint64 toPledge = findPledge(
n.proposedCampaign,
n.intendedCampaign,
new uint64[](0),
0,
0,
@ -873,8 +873,8 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
allowedAmount = callPlugin(before, n.delegationChain[i], fromPledge, toPledge, offset + i+1, allowedAmount);
}
if (n.proposedCampaign > 0) {
allowedAmount = callPlugin(before, n.proposedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
if (n.intendedCampaign > 0) {
allowedAmount = callPlugin(before, n.intendedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
}
}

View File

@ -9,13 +9,13 @@ contract ILiquidPledgingPlugin {
/// 1 -> Plugin for the first delegate transferring pledge to another party
/// 2 -> Plugin for the second delegate transferring pledge to another party
/// ...
/// 255 -> Plugin for the proposedCampaign transferring pledge to another party
/// 255 -> Plugin for the intendedCampaign transferring pledge to another party
///
/// 256 -> Plugin for the owner receiving pledge to another party
/// 257 -> Plugin for the first delegate receiving pledge to another party
/// 258 -> Plugin for the second delegate receiving pledge to another party
/// ...
/// 511 -> Plugin for the proposedCampaign receiving pledge to another party
/// 511 -> Plugin for the intendedCampaign receiving pledge to another party
function beforeTransfer(
uint64 noteManager,
uint64 noteFrom,

View File

@ -412,7 +412,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
if (n.paymentState != PaymentState.Pledged) return idPledge;
// First send to a campaign if it's proposed and commited
if ((n.proposedCampaign > 0) && ( getTime() > n.commitTime)) {
if ((n.intendedCampaign > 0) && ( getTime() > n.commitTime)) {
uint64 oldPledge = findPledge(
n.owner,
n.delegationChain,
@ -421,7 +421,7 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
n.oldPledge,
PaymentState.Pledged);
uint64 toPledge = findPledge(
n.proposedCampaign,
n.intendedCampaign,
new uint64[](0),
0,
0,
@ -470,8 +470,8 @@ function donate(uint64 idGiver, uint64 idReceiver) payable {
allowedAmount = callPlugin(before, n.delegationChain[i], fromPledge, toPledge, offset + i+1, allowedAmount);
}
if (n.proposedCampaign > 0) {
allowedAmount = callPlugin(before, n.proposedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
if (n.intendedCampaign > 0) {
allowedAmount = callPlugin(before, n.intendedCampaign, fromPledge, toPledge, offset + 255, allowedAmount);
}
}

View File

@ -34,8 +34,8 @@ contract LiquidPledgingBase {
uint amount;
uint64 owner; // PledgeAdmin
uint64[] delegationChain; // list of index numbers
uint64 proposedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the proposedCampaign will become the owner
uint64 intendedCampaign; // TODO change the name only used for when delegates are precommiting to a campaign
uint64 commitTime; // When the intendedCampaign will become the owner
uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from
PaymentState paymentState;
}
@ -207,7 +207,7 @@ contract LiquidPledgingBase {
uint amount,
uint64 owner,
uint64 nDelegates,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paymentState
@ -216,7 +216,7 @@ contract LiquidPledgingBase {
amount = n.amount;
owner = n.owner;
nDelegates = uint64(n.delegationChain.length);
proposedCampaign = n.proposedCampaign;
intendedCampaign = n.intendedCampaign;
commitTime = n.commitTime;
oldPledge = n.oldPledge;
paymentState = n.paymentState;
@ -269,18 +269,18 @@ contract LiquidPledgingBase {
function findPledge(
uint64 owner,
uint64[] delegationChain,
uint64 proposedCampaign,
uint64 intendedCampaign,
uint64 commitTime,
uint64 oldPledge,
PaymentState paid
) internal returns (uint64)
{
bytes32 hPledge = sha3(owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid);
bytes32 hPledge = sha3(owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid);
uint64 idx = hPledge2idx[hPledge];
if (idx > 0) return idx;
idx = uint64(pledges.length);
hPledge2idx[hPledge] = idx;
pledges.push(Pledge(0, owner, delegationChain, proposedCampaign, commitTime, oldPledge, paid));
pledges.push(Pledge(0, owner, delegationChain, intendedCampaign, commitTime, oldPledge, paid));
return idx;
}

View File

@ -20,8 +20,8 @@ module.exports = (test) => {
pledge.amount = res.amount;
pledge.owner = res.owner;
if (res.proposedCampaign) {
pledge.proposedCampaign = res.proposedCampaign;
if (res.intendedCampaign) {
pledge.intendedCampaign = res.intendedCampaign;
pledge.commmitTime = res.commitTime;
}
if (res.oldPledge) {

View File

@ -234,7 +234,7 @@ describe('LiquidPledging test', () => {
assert.equal(st.pledges[8].owner, 1);
assert.equal(st.pledges[8].delegates.length, 1);
assert.equal(st.pledges[8].delegates[0].id, 2);
assert.equal(st.pledges[8].proposedCampaign, 4);
assert.equal(st.pledges[8].intendedCampaign, 4);
}).timeout(6000);
it('Giver should be able to send the remaining to campaign2', async () => {
await liquidPledging.transfer(1, 5, utils.toWei(0.02), 4, { from: giver1, $extraGas: 100000 });