url added

This commit is contained in:
Jordi Baylina 2017-10-04 11:40:26 +02:00
parent 52e439318c
commit b4d5e5657c
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
11 changed files with 105 additions and 47 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -60,6 +60,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType; // Giver, Delegate or Campaign PledgeAdminType adminType; // Giver, Delegate or Campaign
address addr; // account or contract address for admin address addr; // account or contract address for admin
string name; string name;
string url;
uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos
uint64 parentCampaign; // Only for campaigns uint64 parentCampaign; // Only for campaigns
bool canceled; //Always false except for canceled campaigns bool canceled; //Always false except for canceled campaigns
@ -112,7 +113,7 @@ contract LiquidPledgingBase {
////// //////
/// @notice Creates a giver. /// @notice Creates a giver.
function addGiver(string name, uint64 commitTime, ILiquidPledgingPlugin plugin function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin
) returns (uint64 idGiver) { ) returns (uint64 idGiver) {
idGiver = uint64(admins.length); idGiver = uint64(admins.length);
@ -121,6 +122,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Giver, PledgeAdminType.Giver,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -136,6 +138,7 @@ contract LiquidPledgingBase {
uint64 idGiver, uint64 idGiver,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage giver = findAdmin(idGiver); PledgeAdmin storage giver = findAdmin(idGiver);
@ -143,6 +146,7 @@ contract LiquidPledgingBase {
require(giver.addr == msg.sender); //current addr had to originate this tx require(giver.addr == msg.sender); //current addr had to originate this tx
giver.addr = newAddr; giver.addr = newAddr;
giver.name = newName; giver.name = newName;
giver.url = newUrl;
giver.commitTime = newCommitTime; giver.commitTime = newCommitTime;
GiverUpdated(idGiver); GiverUpdated(idGiver);
} }
@ -150,7 +154,7 @@ contract LiquidPledgingBase {
event GiverUpdated(uint64 indexed idGiver); event GiverUpdated(uint64 indexed idGiver);
/// @notice Creates a new Delegate /// @notice Creates a new Delegate
function addDelegate(string name, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number function addDelegate(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number
idDelegate = uint64(admins.length); idDelegate = uint64(admins.length);
@ -158,6 +162,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Delegate, PledgeAdminType.Delegate,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -173,12 +178,14 @@ contract LiquidPledgingBase {
uint64 idDelegate, uint64 idDelegate,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) { uint64 newCommitTime) {
PledgeAdmin storage delegate = findAdmin(idDelegate); PledgeAdmin storage delegate = findAdmin(idDelegate);
require(delegate.adminType == PledgeAdminType.Delegate); require(delegate.adminType == PledgeAdminType.Delegate);
require(delegate.addr == msg.sender); require(delegate.addr == msg.sender);
delegate.addr = newAddr; delegate.addr = newAddr;
delegate.name = newName; delegate.name = newName;
delegate.url = newUrl;
delegate.commitTime = newCommitTime; delegate.commitTime = newCommitTime;
DelegateUpdated(idDelegate); DelegateUpdated(idDelegate);
} }
@ -186,7 +193,7 @@ contract LiquidPledgingBase {
event DelegateUpdated(uint64 indexed idDelegate); event DelegateUpdated(uint64 indexed idDelegate);
/// @notice Creates a new Campaign /// @notice Creates a new Campaign
function addCampaign(string name, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) { function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
if (parentCampaign != 0) { if (parentCampaign != 0) {
PledgeAdmin storage pm = findAdmin(parentCampaign); PledgeAdmin storage pm = findAdmin(parentCampaign);
require(pm.adminType == PledgeAdminType.Campaign); require(pm.adminType == PledgeAdminType.Campaign);
@ -200,6 +207,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Campaign, PledgeAdminType.Campaign,
campaignAdmin, campaignAdmin,
name, name,
url,
commitTime, commitTime,
parentCampaign, parentCampaign,
false, false,
@ -216,6 +224,7 @@ contract LiquidPledgingBase {
uint64 idCampaign, uint64 idCampaign,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage campaign = findAdmin(idCampaign); PledgeAdmin storage campaign = findAdmin(idCampaign);
@ -223,6 +232,7 @@ contract LiquidPledgingBase {
require(campaign.addr == msg.sender); require(campaign.addr == msg.sender);
campaign.addr = newAddr; campaign.addr = newAddr;
campaign.name = newName; campaign.name = newName;
campaign.url = newUrl;
campaign.commitTime = newCommitTime; campaign.commitTime = newCommitTime;
CampaignUpdated(idCampaign); CampaignUpdated(idCampaign);
} }
@ -279,6 +289,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType, PledgeAdminType adminType,
address addr, address addr,
string name, string name,
string url,
uint64 commitTime, uint64 commitTime,
uint64 parentCampaign, uint64 parentCampaign,
bool canceled, bool canceled,
@ -288,6 +299,7 @@ contract LiquidPledgingBase {
adminType = m.adminType; adminType = m.adminType;
addr = m.addr; addr = m.addr;
name = m.name; name = m.name;
url = m.url;
commitTime = m.commitTime; commitTime = m.commitTime;
parentCampaign = m.parentCampaign; parentCampaign = m.parentCampaign;
canceled = m.canceled; canceled = m.canceled;

File diff suppressed because one or more lines are too long

View File

@ -60,6 +60,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType; // Giver, Delegate or Campaign PledgeAdminType adminType; // Giver, Delegate or Campaign
address addr; // account or contract address for admin address addr; // account or contract address for admin
string name; string name;
string url;
uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos
uint64 parentCampaign; // Only for campaigns uint64 parentCampaign; // Only for campaigns
bool canceled; //Always false except for canceled campaigns bool canceled; //Always false except for canceled campaigns
@ -112,7 +113,7 @@ contract LiquidPledgingBase {
////// //////
/// @notice Creates a giver. /// @notice Creates a giver.
function addGiver(string name, uint64 commitTime, ILiquidPledgingPlugin plugin function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin
) returns (uint64 idGiver) { ) returns (uint64 idGiver) {
idGiver = uint64(admins.length); idGiver = uint64(admins.length);
@ -121,6 +122,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Giver, PledgeAdminType.Giver,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -136,6 +138,7 @@ contract LiquidPledgingBase {
uint64 idGiver, uint64 idGiver,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage giver = findAdmin(idGiver); PledgeAdmin storage giver = findAdmin(idGiver);
@ -143,6 +146,7 @@ contract LiquidPledgingBase {
require(giver.addr == msg.sender); //current addr had to originate this tx require(giver.addr == msg.sender); //current addr had to originate this tx
giver.addr = newAddr; giver.addr = newAddr;
giver.name = newName; giver.name = newName;
giver.url = newUrl;
giver.commitTime = newCommitTime; giver.commitTime = newCommitTime;
GiverUpdated(idGiver); GiverUpdated(idGiver);
} }
@ -150,7 +154,7 @@ contract LiquidPledgingBase {
event GiverUpdated(uint64 indexed idGiver); event GiverUpdated(uint64 indexed idGiver);
/// @notice Creates a new Delegate /// @notice Creates a new Delegate
function addDelegate(string name, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number function addDelegate(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number
idDelegate = uint64(admins.length); idDelegate = uint64(admins.length);
@ -158,6 +162,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Delegate, PledgeAdminType.Delegate,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -173,12 +178,14 @@ contract LiquidPledgingBase {
uint64 idDelegate, uint64 idDelegate,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) { uint64 newCommitTime) {
PledgeAdmin storage delegate = findAdmin(idDelegate); PledgeAdmin storage delegate = findAdmin(idDelegate);
require(delegate.adminType == PledgeAdminType.Delegate); require(delegate.adminType == PledgeAdminType.Delegate);
require(delegate.addr == msg.sender); require(delegate.addr == msg.sender);
delegate.addr = newAddr; delegate.addr = newAddr;
delegate.name = newName; delegate.name = newName;
delegate.url = newUrl;
delegate.commitTime = newCommitTime; delegate.commitTime = newCommitTime;
DelegateUpdated(idDelegate); DelegateUpdated(idDelegate);
} }
@ -186,7 +193,7 @@ contract LiquidPledgingBase {
event DelegateUpdated(uint64 indexed idDelegate); event DelegateUpdated(uint64 indexed idDelegate);
/// @notice Creates a new Campaign /// @notice Creates a new Campaign
function addCampaign(string name, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) { function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
if (parentCampaign != 0) { if (parentCampaign != 0) {
PledgeAdmin storage pm = findAdmin(parentCampaign); PledgeAdmin storage pm = findAdmin(parentCampaign);
require(pm.adminType == PledgeAdminType.Campaign); require(pm.adminType == PledgeAdminType.Campaign);
@ -200,6 +207,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Campaign, PledgeAdminType.Campaign,
campaignAdmin, campaignAdmin,
name, name,
url,
commitTime, commitTime,
parentCampaign, parentCampaign,
false, false,
@ -216,6 +224,7 @@ contract LiquidPledgingBase {
uint64 idCampaign, uint64 idCampaign,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage campaign = findAdmin(idCampaign); PledgeAdmin storage campaign = findAdmin(idCampaign);
@ -223,6 +232,7 @@ contract LiquidPledgingBase {
require(campaign.addr == msg.sender); require(campaign.addr == msg.sender);
campaign.addr = newAddr; campaign.addr = newAddr;
campaign.name = newName; campaign.name = newName;
campaign.url = newUrl;
campaign.commitTime = newCommitTime; campaign.commitTime = newCommitTime;
CampaignUpdated(idCampaign); CampaignUpdated(idCampaign);
} }
@ -279,6 +289,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType, PledgeAdminType adminType,
address addr, address addr,
string name, string name,
string url,
uint64 commitTime, uint64 commitTime,
uint64 parentCampaign, uint64 parentCampaign,
bool canceled, bool canceled,
@ -288,6 +299,7 @@ contract LiquidPledgingBase {
adminType = m.adminType; adminType = m.adminType;
addr = m.addr; addr = m.addr;
name = m.name; name = m.name;
url = m.url;
commitTime = m.commitTime; commitTime = m.commitTime;
parentCampaign = m.parentCampaign; parentCampaign = m.parentCampaign;
canceled = m.canceled; canceled = m.canceled;
@ -427,7 +439,7 @@ contract LiquidPledging is LiquidPledgingBase {
function donate(uint64 idGiver, uint64 idReceiver) payable { function donate(uint64 idGiver, uint64 idReceiver) payable {
if (idGiver == 0) { if (idGiver == 0) {
idGiver = addGiver('', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime idGiver = addGiver('', '', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime
} }
PledgeAdmin storage sender = findAdmin(idGiver); PledgeAdmin storage sender = findAdmin(idGiver);

View File

@ -60,6 +60,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType; // Giver, Delegate or Campaign PledgeAdminType adminType; // Giver, Delegate or Campaign
address addr; // account or contract address for admin address addr; // account or contract address for admin
string name; string name;
string url;
uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos
uint64 parentCampaign; // Only for campaigns uint64 parentCampaign; // Only for campaigns
bool canceled; //Always false except for canceled campaigns bool canceled; //Always false except for canceled campaigns
@ -112,7 +113,7 @@ contract LiquidPledgingBase {
////// //////
/// @notice Creates a giver. /// @notice Creates a giver.
function addGiver(string name, uint64 commitTime, ILiquidPledgingPlugin plugin function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin
) returns (uint64 idGiver) { ) returns (uint64 idGiver) {
idGiver = uint64(admins.length); idGiver = uint64(admins.length);
@ -121,6 +122,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Giver, PledgeAdminType.Giver,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -136,6 +138,7 @@ contract LiquidPledgingBase {
uint64 idGiver, uint64 idGiver,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage giver = findAdmin(idGiver); PledgeAdmin storage giver = findAdmin(idGiver);
@ -143,6 +146,7 @@ contract LiquidPledgingBase {
require(giver.addr == msg.sender); //current addr had to originate this tx require(giver.addr == msg.sender); //current addr had to originate this tx
giver.addr = newAddr; giver.addr = newAddr;
giver.name = newName; giver.name = newName;
giver.url = newUrl;
giver.commitTime = newCommitTime; giver.commitTime = newCommitTime;
GiverUpdated(idGiver); GiverUpdated(idGiver);
} }
@ -150,7 +154,7 @@ contract LiquidPledgingBase {
event GiverUpdated(uint64 indexed idGiver); event GiverUpdated(uint64 indexed idGiver);
/// @notice Creates a new Delegate /// @notice Creates a new Delegate
function addDelegate(string name, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number function addDelegate(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number
idDelegate = uint64(admins.length); idDelegate = uint64(admins.length);
@ -158,6 +162,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Delegate, PledgeAdminType.Delegate,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -173,12 +178,14 @@ contract LiquidPledgingBase {
uint64 idDelegate, uint64 idDelegate,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) { uint64 newCommitTime) {
PledgeAdmin storage delegate = findAdmin(idDelegate); PledgeAdmin storage delegate = findAdmin(idDelegate);
require(delegate.adminType == PledgeAdminType.Delegate); require(delegate.adminType == PledgeAdminType.Delegate);
require(delegate.addr == msg.sender); require(delegate.addr == msg.sender);
delegate.addr = newAddr; delegate.addr = newAddr;
delegate.name = newName; delegate.name = newName;
delegate.url = newUrl;
delegate.commitTime = newCommitTime; delegate.commitTime = newCommitTime;
DelegateUpdated(idDelegate); DelegateUpdated(idDelegate);
} }
@ -186,7 +193,7 @@ contract LiquidPledgingBase {
event DelegateUpdated(uint64 indexed idDelegate); event DelegateUpdated(uint64 indexed idDelegate);
/// @notice Creates a new Campaign /// @notice Creates a new Campaign
function addCampaign(string name, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) { function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
if (parentCampaign != 0) { if (parentCampaign != 0) {
PledgeAdmin storage pm = findAdmin(parentCampaign); PledgeAdmin storage pm = findAdmin(parentCampaign);
require(pm.adminType == PledgeAdminType.Campaign); require(pm.adminType == PledgeAdminType.Campaign);
@ -200,6 +207,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Campaign, PledgeAdminType.Campaign,
campaignAdmin, campaignAdmin,
name, name,
url,
commitTime, commitTime,
parentCampaign, parentCampaign,
false, false,
@ -216,6 +224,7 @@ contract LiquidPledgingBase {
uint64 idCampaign, uint64 idCampaign,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage campaign = findAdmin(idCampaign); PledgeAdmin storage campaign = findAdmin(idCampaign);
@ -223,6 +232,7 @@ contract LiquidPledgingBase {
require(campaign.addr == msg.sender); require(campaign.addr == msg.sender);
campaign.addr = newAddr; campaign.addr = newAddr;
campaign.name = newName; campaign.name = newName;
campaign.url = newUrl;
campaign.commitTime = newCommitTime; campaign.commitTime = newCommitTime;
CampaignUpdated(idCampaign); CampaignUpdated(idCampaign);
} }
@ -279,6 +289,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType, PledgeAdminType adminType,
address addr, address addr,
string name, string name,
string url,
uint64 commitTime, uint64 commitTime,
uint64 parentCampaign, uint64 parentCampaign,
bool canceled, bool canceled,
@ -288,6 +299,7 @@ contract LiquidPledgingBase {
adminType = m.adminType; adminType = m.adminType;
addr = m.addr; addr = m.addr;
name = m.name; name = m.name;
url = m.url;
commitTime = m.commitTime; commitTime = m.commitTime;
parentCampaign = m.parentCampaign; parentCampaign = m.parentCampaign;
canceled = m.canceled; canceled = m.canceled;
@ -427,7 +439,7 @@ contract LiquidPledging is LiquidPledgingBase {
function donate(uint64 idGiver, uint64 idReceiver) payable { function donate(uint64 idGiver, uint64 idReceiver) payable {
if (idGiver == 0) { if (idGiver == 0) {
idGiver = addGiver('', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime idGiver = addGiver('', '', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime
} }
PledgeAdmin storage sender = findAdmin(idGiver); PledgeAdmin storage sender = findAdmin(idGiver);

View File

@ -24,7 +24,7 @@ contract LiquidPledging is LiquidPledgingBase {
function donate(uint64 idGiver, uint64 idReceiver) payable { function donate(uint64 idGiver, uint64 idReceiver) payable {
if (idGiver == 0) { if (idGiver == 0) {
idGiver = addGiver('', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime idGiver = addGiver('', '', 259200, ILiquidPledgingPlugin(0x0)); // default to 3 day commitTime
} }
PledgeAdmin storage sender = findAdmin(idGiver); PledgeAdmin storage sender = findAdmin(idGiver);

View File

@ -24,6 +24,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType; // Giver, Delegate or Campaign PledgeAdminType adminType; // Giver, Delegate or Campaign
address addr; // account or contract address for admin address addr; // account or contract address for admin
string name; string name;
string url;
uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos uint64 commitTime; // In seconds, used for Givers' & Delegates' vetos
uint64 parentCampaign; // Only for campaigns uint64 parentCampaign; // Only for campaigns
bool canceled; //Always false except for canceled campaigns bool canceled; //Always false except for canceled campaigns
@ -76,7 +77,7 @@ contract LiquidPledgingBase {
////// //////
/// @notice Creates a giver. /// @notice Creates a giver.
function addGiver(string name, uint64 commitTime, ILiquidPledgingPlugin plugin function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin
) returns (uint64 idGiver) { ) returns (uint64 idGiver) {
idGiver = uint64(admins.length); idGiver = uint64(admins.length);
@ -85,6 +86,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Giver, PledgeAdminType.Giver,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -100,6 +102,7 @@ contract LiquidPledgingBase {
uint64 idGiver, uint64 idGiver,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage giver = findAdmin(idGiver); PledgeAdmin storage giver = findAdmin(idGiver);
@ -107,6 +110,7 @@ contract LiquidPledgingBase {
require(giver.addr == msg.sender); //current addr had to originate this tx require(giver.addr == msg.sender); //current addr had to originate this tx
giver.addr = newAddr; giver.addr = newAddr;
giver.name = newName; giver.name = newName;
giver.url = newUrl;
giver.commitTime = newCommitTime; giver.commitTime = newCommitTime;
GiverUpdated(idGiver); GiverUpdated(idGiver);
} }
@ -114,7 +118,7 @@ contract LiquidPledgingBase {
event GiverUpdated(uint64 indexed idGiver); event GiverUpdated(uint64 indexed idGiver);
/// @notice Creates a new Delegate /// @notice Creates a new Delegate
function addDelegate(string name, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number function addDelegate(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idDelegate) { //TODO return index number
idDelegate = uint64(admins.length); idDelegate = uint64(admins.length);
@ -122,6 +126,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Delegate, PledgeAdminType.Delegate,
msg.sender, msg.sender,
name, name,
url,
commitTime, commitTime,
0, 0,
false, false,
@ -137,12 +142,14 @@ contract LiquidPledgingBase {
uint64 idDelegate, uint64 idDelegate,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) { uint64 newCommitTime) {
PledgeAdmin storage delegate = findAdmin(idDelegate); PledgeAdmin storage delegate = findAdmin(idDelegate);
require(delegate.adminType == PledgeAdminType.Delegate); require(delegate.adminType == PledgeAdminType.Delegate);
require(delegate.addr == msg.sender); require(delegate.addr == msg.sender);
delegate.addr = newAddr; delegate.addr = newAddr;
delegate.name = newName; delegate.name = newName;
delegate.url = newUrl;
delegate.commitTime = newCommitTime; delegate.commitTime = newCommitTime;
DelegateUpdated(idDelegate); DelegateUpdated(idDelegate);
} }
@ -150,7 +157,7 @@ contract LiquidPledgingBase {
event DelegateUpdated(uint64 indexed idDelegate); event DelegateUpdated(uint64 indexed idDelegate);
/// @notice Creates a new Campaign /// @notice Creates a new Campaign
function addCampaign(string name, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) { function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
if (parentCampaign != 0) { if (parentCampaign != 0) {
PledgeAdmin storage pm = findAdmin(parentCampaign); PledgeAdmin storage pm = findAdmin(parentCampaign);
require(pm.adminType == PledgeAdminType.Campaign); require(pm.adminType == PledgeAdminType.Campaign);
@ -164,6 +171,7 @@ contract LiquidPledgingBase {
PledgeAdminType.Campaign, PledgeAdminType.Campaign,
campaignAdmin, campaignAdmin,
name, name,
url,
commitTime, commitTime,
parentCampaign, parentCampaign,
false, false,
@ -180,6 +188,7 @@ contract LiquidPledgingBase {
uint64 idCampaign, uint64 idCampaign,
address newAddr, address newAddr,
string newName, string newName,
string newUrl,
uint64 newCommitTime) uint64 newCommitTime)
{ {
PledgeAdmin storage campaign = findAdmin(idCampaign); PledgeAdmin storage campaign = findAdmin(idCampaign);
@ -187,6 +196,7 @@ contract LiquidPledgingBase {
require(campaign.addr == msg.sender); require(campaign.addr == msg.sender);
campaign.addr = newAddr; campaign.addr = newAddr;
campaign.name = newName; campaign.name = newName;
campaign.url = newUrl;
campaign.commitTime = newCommitTime; campaign.commitTime = newCommitTime;
CampaignUpdated(idCampaign); CampaignUpdated(idCampaign);
} }
@ -243,6 +253,7 @@ contract LiquidPledgingBase {
PledgeAdminType adminType, PledgeAdminType adminType,
address addr, address addr,
string name, string name,
string url,
uint64 commitTime, uint64 commitTime,
uint64 parentCampaign, uint64 parentCampaign,
bool canceled, bool canceled,
@ -252,6 +263,7 @@ contract LiquidPledgingBase {
adminType = m.adminType; adminType = m.adminType;
addr = m.addr; addr = m.addr;
name = m.name; name = m.name;
url = m.url;
commitTime = m.commitTime; commitTime = m.commitTime;
parentCampaign = m.parentCampaign; parentCampaign = m.parentCampaign;
canceled = m.canceled; canceled = m.canceled;

View File

@ -45,6 +45,7 @@ module.exports = (test) => {
id: r.idDelegate, id: r.idDelegate,
addr: r.addr, addr: r.addr,
name: r.name, name: r.name,
url: r.url
})), })),
); );
} }
@ -72,6 +73,7 @@ module.exports = (test) => {
} }
admin.addr = res.addr; admin.addr = res.addr;
admin.name = res.name; admin.name = res.name;
admin.url = res.url;
admin.commitTime = res.commitTime; admin.commitTime = res.commitTime;
if (admin.paymentState === 'Campaign') { if (admin.paymentState === 'Campaign') {
admin.parentCampaign = res.parentCampaign; admin.parentCampaign = res.parentCampaign;
@ -142,6 +144,7 @@ module.exports = (test) => {
list[idDelegate] = { list[idDelegate] = {
idDelegate, idDelegate,
name: this.admins[idDelegate].name, name: this.admins[idDelegate].name,
url: this.admins[idDelegate].url,
pledges: [], pledges: [],
delegtes: [], delegtes: [],
}; };
@ -156,6 +159,7 @@ module.exports = (test) => {
pledges: [], pledges: [],
commitedCampaigns: [], commitedCampaigns: [],
name: this.admins[idCampaign].name, name: this.admins[idCampaign].name,
url: this.admins[idCampaign].url,
commitTime: this.admins[idCampaign].commitTime, commitTime: this.admins[idCampaign].commitTime,
owner: this.admins[idCampaign].owner, owner: this.admins[idCampaign].owner,
parentCampaign: this.admins[idCampaign].parentCampaign, parentCampaign: this.admins[idCampaign].parentCampaign,

View File

@ -1,6 +1,6 @@
{ {
"name": "liquidpledging", "name": "liquidpledging",
"version": "0.0.7", "version": "0.0.8",
"description": "Liquid Pledging Smart Contract", "description": "Liquid Pledging Smart Contract",
"main": "index.js", "main": "index.js",
"directories": { "directories": {

View File

@ -53,7 +53,7 @@ describe('LiquidPledging test', () => {
before(async () => { before(async () => {
const testrpc = TestRPC.server({ const testrpc = TestRPC.server({
ws: true, ws: true,
gasLimit: 5200000, gasLimit: 5800000,
total_accounts: 10, total_accounts: 10,
}); });
@ -71,18 +71,19 @@ describe('LiquidPledging test', () => {
}); });
it('Should deploy LiquidPledging contract', async () => { it('Should deploy LiquidPledging contract', async () => {
vault = await Vault.new(web3); vault = await Vault.new(web3);
liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5200000 }); liquidPledging = await LiquidPledging.new(web3, vault.$address, { gas: 5800000 });
await vault.setLiquidPledging(liquidPledging.$address); await vault.setLiquidPledging(liquidPledging.$address);
}).timeout(6000); }).timeout(6000);
it('Should create a giver', async () => { it('Should create a giver', async () => {
await liquidPledging.addGiver('Giver1', 86400, 0, { from: giver1 }); await liquidPledging.addGiver('Giver1', 'URLGiver1', 86400, 0, { from: giver1 });
const nAdmins = await liquidPledging.numberOfPledgeAdmins(); const nAdmins = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins, 1); assert.equal(nAdmins, 1);
const res = await liquidPledging.getPledgeAdmin(1); const res = await liquidPledging.getPledgeAdmin(1);
assert.equal(res[0], 0); // Giver assert.equal(res[0], 0); // Giver
assert.equal(res[1], giver1); assert.equal(res[1], giver1);
assert.equal(res[2], 'Giver1'); assert.equal(res[2], 'Giver1');
assert.equal(res[3], 86400); assert.equal(res[3], 'URLGiver1');
assert.equal(res[4], 86400);
}).timeout(6000); }).timeout(6000);
it('Should make a donation', async () => { it('Should make a donation', async () => {
await liquidPledging.donate(1, 1, { from: giver1, value: utils.toWei(1) }); await liquidPledging.donate(1, 1, { from: giver1, value: utils.toWei(1) });
@ -91,13 +92,15 @@ describe('LiquidPledging test', () => {
await liquidPledging.getPledge(1); await liquidPledging.getPledge(1);
}).timeout(6000); }).timeout(6000);
it('Should create a delegate', async () => { it('Should create a delegate', async () => {
await liquidPledging.addDelegate('Delegate1', 0, 0, { from: delegate1 }); await liquidPledging.addDelegate('Delegate1', 'URLDelegate1', 0, 0, { from: delegate1 });
const nAdmins = await liquidPledging.numberOfPledgeAdmins(); const nAdmins = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins, 2); assert.equal(nAdmins, 2);
const res = await liquidPledging.getPledgeAdmin(2); const res = await liquidPledging.getPledgeAdmin(2);
assert.equal(res[0], 1); // Giver assert.equal(res[0], 1); // Giver
assert.equal(res[1], delegate1); assert.equal(res[1], delegate1);
assert.equal(res[2], 'Delegate1'); assert.equal(res[2], 'Delegate1');
assert.equal(res[3], 'URLDelegate1');
assert.equal(res[4], 0);
}).timeout(6000); }).timeout(6000);
it('Giver should delegate on the delegate', async () => { it('Giver should delegate on the delegate', async () => {
await liquidPledging.transfer(1, 1, utils.toWei(0.5), 2, { from: giver1 }); await liquidPledging.transfer(1, 1, utils.toWei(0.5), 2, { from: giver1 });
@ -115,7 +118,7 @@ describe('LiquidPledging test', () => {
assert.equal(d[2], 'Delegate1'); assert.equal(d[2], 'Delegate1');
}).timeout(6000); }).timeout(6000);
it('Should create a 2 campaigns', async () => { it('Should create a 2 campaigns', async () => {
await liquidPledging.addCampaign('Campaign1', adminCampaign1, 0, 86400, 0, { from: adminCampaign1 }); await liquidPledging.addCampaign('Campaign1', 'URLCampaign1', adminCampaign1, 0, 86400, 0, { from: adminCampaign1 });
const nAdmins = await liquidPledging.numberOfPledgeAdmins(); const nAdmins = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins, 3); assert.equal(nAdmins, 3);
@ -123,11 +126,12 @@ describe('LiquidPledging test', () => {
assert.equal(res[0], 2); // Campaign type assert.equal(res[0], 2); // Campaign type
assert.equal(res[1], adminCampaign1); assert.equal(res[1], adminCampaign1);
assert.equal(res[2], 'Campaign1'); assert.equal(res[2], 'Campaign1');
assert.equal(res[3], 86400); assert.equal(res[3], 'URLCampaign1');
assert.equal(res[4], 0); assert.equal(res[4], 86400);
assert.equal(res[5], false); assert.equal(res[5], 0);
assert.equal(res[6], false);
await liquidPledging.addCampaign('Campaign2', adminCampaign2, 0, 86400, 0, { from: adminCampaign2 }); await liquidPledging.addCampaign('Campaign2', 'URLCampaign2', adminCampaign2, 0, 86400, 0, { from: adminCampaign2 });
const nAdmins2 = await liquidPledging.numberOfPledgeAdmins(); const nAdmins2 = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins2, 4); assert.equal(nAdmins2, 4);
@ -135,9 +139,10 @@ describe('LiquidPledging test', () => {
assert.equal(res4[0], 2); // Campaign type assert.equal(res4[0], 2); // Campaign type
assert.equal(res4[1], adminCampaign2); assert.equal(res4[1], adminCampaign2);
assert.equal(res4[2], 'Campaign2'); assert.equal(res4[2], 'Campaign2');
assert.equal(res4[3], 86400); assert.equal(res4[3], 'URLCampaign2');
assert.equal(res4[4], 0); assert.equal(res4[4], 86400);
assert.equal(res4[5], false); assert.equal(res4[5], 0);
assert.equal(res4[6], false);
}).timeout(6000); }).timeout(6000);
it('Delegate should assign to campaign1', async () => { it('Delegate should assign to campaign1', async () => {
const n = Math.floor(new Date().getTime() / 1000); const n = Math.floor(new Date().getTime() / 1000);
@ -244,8 +249,8 @@ describe('LiquidPledging test', () => {
assert.equal(utils.fromWei(st.pledges[4].amount), 0.12); assert.equal(utils.fromWei(st.pledges[4].amount), 0.12);
}).timeout(6000); }).timeout(6000);
it('A subcampaign 2a and a delegate2 is created', async () => { it('A subcampaign 2a and a delegate2 is created', async () => {
await liquidPledging.addCampaign('Campaign2a', adminCampaign2a, 4, 86400, 0, { from: adminCampaign2 }); await liquidPledging.addCampaign('Campaign2a', 'URLCampaign2a', adminCampaign2a, 4, 86400, 0, { from: adminCampaign2 });
await liquidPledging.addDelegate('Delegate2', 0, 0, { from: delegate2 }); await liquidPledging.addDelegate('Delegate2', 'URLDelegate2', 0, 0, { from: delegate2 });
const nAdmins = await liquidPledging.numberOfPledgeAdmins(); const nAdmins = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins, 6); assert.equal(nAdmins, 6);
}).timeout(6000); }).timeout(6000);
@ -323,6 +328,7 @@ describe('LiquidPledging test', () => {
assert.equal(res[0], 0); // Giver assert.equal(res[0], 0); // Giver
assert.equal(res[1], giver2); assert.equal(res[1], giver2);
assert.equal(res[2], ''); assert.equal(res[2], '');
assert.equal(res[3], 259200); // default to 3 day commitTime assert.equal(res[3], '');
assert.equal(res[4], 259200); // default to 3 day commitTime
}).timeout(6000); }).timeout(6000);
}); });