liquid-funding/build/LiquidPledgingStorage_all.sol

156 lines
6.7 KiB
Solidity

///File: ./contracts/ILiquidPledgingPlugin.sol
pragma solidity ^0.4.11;
/*
Copyright 2017, Jordi Baylina
Contributors: Adrià Massanet <adria@codecontext.io>, RJ Ewing, Griff
Green, Arthur Lunn
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// @dev `ILiquidPledgingPlugin` is the basic interface for any
/// liquid pledging plugin
contract ILiquidPledgingPlugin {
/// @notice Plugins are used (much like web hooks) to initiate an action
/// upon any donation, delegation, or transfer; this is an optional feature
/// and allows for extreme customization of the contract. This function
/// implements any action that should be initiated before a transfer.
/// @param pledgeManager The admin or current manager of the pledge
/// @param pledgeFrom This is the Id from which value will be transfered.
/// @param pledgeTo This is the Id that value will be transfered to.
/// @param context The situation that is triggering the plugin:
/// 0 -> Plugin for the owner transferring pledge to another party
/// 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 intendedProject 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 intendedProject receiving pledge to another party
/// @param amount The amount of value that will be transfered.
function beforeTransfer(
uint64 pledgeManager,
uint64 pledgeFrom,
uint64 pledgeTo,
uint64 context,
address token,
uint amount ) public returns (uint maxAllowed);
/// @notice Plugins are used (much like web hooks) to initiate an action
/// upon any donation, delegation, or transfer; this is an optional feature
/// and allows for extreme customization of the contract. This function
/// implements any action that should be initiated after a transfer.
/// @param pledgeManager The admin or current manager of the pledge
/// @param pledgeFrom This is the Id from which value will be transfered.
/// @param pledgeTo This is the Id that value will be transfered to.
/// @param context The situation that is triggering the plugin:
/// 0 -> Plugin for the owner transferring pledge to another party
/// 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 intendedProject 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 intendedProject receiving pledge to another party
/// @param amount The amount of value that will be transfered.
function afterTransfer(
uint64 pledgeManager,
uint64 pledgeFrom,
uint64 pledgeTo,
uint64 context,
address token,
uint amount
) public;
}
///File: ./contracts/LiquidPledgingStorage.sol
pragma solidity ^0.4.18;
/// @dev This is an interface for `LPVault` which serves as a secure storage for
/// the ETH that backs the Pledges, only after `LiquidPledging` authorizes
/// payments can Pledges be converted for ETH
interface ILPVault {
function authorizePayment(bytes32 _ref, address _dest, address _token, uint _amount) public;
}
/// This contract contains all state variables used in LiquidPledging contracts
/// This is done to have everything in 1 location, b/c state variable layout
/// is MUST have be the same when performing an upgrade.
contract LiquidPledgingStorage {
enum PledgeAdminType { Giver, Delegate, Project }
enum PledgeState { Pledged, Paying, Paid }
/// @dev This struct defines the details of a `PledgeAdmin` which are
/// commonly referenced by their index in the `admins` array
/// and can own pledges and act as delegates
struct PledgeAdmin {
PledgeAdminType adminType; // Giver, Delegate or Project
address addr; // Account or contract address for admin
uint64 commitTime; // In seconds, used for time Givers' & Delegates' have to veto
uint64 parentProject; // Only for projects
bool canceled; //Always false except for canceled projects
/// @dev if the plugin is 0x0 then nothing happens, if its an address
// than that smart contract is called when appropriate
ILiquidPledgingPlugin plugin;
string name;
string url; // Can be IPFS hash
}
struct Pledge {
uint amount;
uint64[] delegationChain; // List of delegates in order of authority
uint64 owner; // PledgeAdmin
uint64 intendedProject; // Used when delegates are sending to projects
uint64 commitTime; // When the intendedProject will become the owner
uint64 oldPledge; // Points to the id that this Pledge was derived from
address token;
PledgeState pledgeState; // Pledged, Paying, Paid
}
PledgeAdmin[] admins; //The list of pledgeAdmins 0 means there is no admin
Pledge[] pledges;
/// @dev this mapping allows you to search for a specific pledge's
/// index number by the hash of that pledge
mapping (bytes32 => uint64) hPledge2idx;
// this whitelist is for non-proxied plugins
mapping (bytes32 => bool) pluginContractWhitelist;
// this whitelist is for proxied plugins
mapping (address => bool) pluginInstanceWhitelist;
bool public whitelistDisabled = false;
ILPVault public vault;
// reserve 50 slots for future upgrades. I'm not sure if this is necessary
// but b/c of multiple inheritance used in lp, better safe then sorry.
// especially since it is free
uint[50] private storageOffset;
}