Javascript 如何使用块菌测试代码读取固态的公共变量?
我试图通过truffle控制台从我的公共变量solidity中获取一个值,但我不知道正确的语法 松露版本 块菌v5.0.14(核心:5.0.14) 坚固度-0.5.4(solc js) 节点v11.10.1 Web3.jsv1.0.0-beta.37 这是我已经尝试过的Javascript 如何使用块菌测试代码读取固态的公共变量?,javascript,testing,ethereum,web3,truffle,Javascript,Testing,Ethereum,Web3,Truffle,我试图通过truffle控制台从我的公共变量solidity中获取一个值,但我不知道正确的语法 松露版本 块菌v5.0.14(核心:5.0.14) 坚固度-0.5.4(solc js) 节点v11.10.1 Web3.jsv1.0.0-beta.37 这是我已经尝试过的 我用下面的命令安装了块菌 我有一个名为ProxyContract的合同,我设置了2_deploy_migration.js 迁移合同 当我键入ProxyContract来提示时,我可以看到某个对象的信息片段,它看起来很好 我试图
truffle(开发)>proxyNemodax.committeeStatus.call(0)
抛出:
{错误:无效地址(arg=”“,coderType=“地址”,值=0)
在ABICoder.encodeParameters(/usr/local/lib/node\u modules/truffle/build/webpack://~/web3 eth abi/src/index.js:96:1)
在AbiCoder.encode(/usr/local/lib/node\u modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/abi coder.js:897:1)
在CoderTuple.encode(/usr/local/lib/node_modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/abi coder.js:764:1)
at pack(/usr/local/lib/node_modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/abi coder.js:604:1)
在Array.forEach()处
在/usr/local/lib/node_modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/abi coder.js:605:21
在CoderAddress.encode(/usr/local/lib/node\u modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/abi coder.js:467:1)
在Object.throwError(/usr/local/lib/node\u modules/truffle/build/webpack://~/web3 eth abi/~/ethers/utils/errors.js:68:1)
原因:“无效地址”,
代码:“无效的_参数”,
arg:“”,
coderType:'地址',
值:0}
这是我的密码
pragma solidity 0.5.4;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title MultiOwnable
*
* @dev Require majority approval of multiple owners to use and access to features
* when restrictions on access to critical functions are required.
*
*/
contract MultiOwnable {
using SafeMath for uint8;
struct CommitteeStatusPack{
/**
* Key informations for decisions.
* To save some gas, choosing the struct.
*/
uint8 numOfOwners;
uint8 numOfVotes;
uint8 numOfMinOwners;
bytes proposedFuncData;
}
CommitteeStatusPack public committeeStatus;
address[] public ballot; // To make sure if it already was voted
mapping(address => bool) public owner;
event Vote(address indexed proposer, bytes indexed proposedFuncData);
event Propose(address indexed proposer, bytes indexed proposedFuncData);
event Dismiss(address indexed proposer, bytes indexed proposedFuncData);
event AddedOwner(address newOwner);
event RemovedOwner(address removedOwner);
event TransferOwnership(address from, address to);
/**
* Organize initial committee.
*
* @notice committee must be 3 at least.
* you have to use this contract to be inherited because it is internal.
*
* @param _coOwner1 _coOwner2 _coOwner3 _coOwner4 _coOwner5 committee members
*/
constructor(address _coOwner1, address _coOwner2, address _coOwner3, address _coOwner4, address _coOwner5) internal {
require(_coOwner1 != address(0x0) &&
_coOwner2 != address(0x0) &&
_coOwner3 != address(0x0) &&
_coOwner4 != address(0x0) &&
_coOwner5 != address(0x0));
require(_coOwner1 != _coOwner2 &&
_coOwner1 != _coOwner3 &&
_coOwner1 != _coOwner4 &&
_coOwner1 != _coOwner5 &&
_coOwner2 != _coOwner3 &&
_coOwner2 != _coOwner4 &&
_coOwner2 != _coOwner5 &&
_coOwner3 != _coOwner4 &&
_coOwner3 != _coOwner5 &&
_coOwner4 != _coOwner5); // SmartDec Recommendations
owner[_coOwner1] = true;
owner[_coOwner2] = true;
owner[_coOwner3] = true;
owner[_coOwner4] = true;
owner[_coOwner5] = true;
committeeStatus.numOfOwners = 5;
committeeStatus.numOfMinOwners = 5;
emit AddedOwner(_coOwner1);
emit AddedOwner(_coOwner2);
emit AddedOwner(_coOwner3);
emit AddedOwner(_coOwner4);
emit AddedOwner(_coOwner5);
}
modifier onlyOwner() {
require(owner[msg.sender]);
_;
}
/**
* Pre-check if it's decided by committee
*
* @notice If there is a majority approval,
* the function with this modifier will not be executed.
*/
modifier committeeApproved() {
/* check if proposed Function Name and real function Name are correct */
require( keccak256(committeeStatus.proposedFuncData) == keccak256(msg.data) ); // SmartDec Recommendations
/* To check majority */
require(committeeStatus.numOfVotes > committeeStatus.numOfOwners.div(2));
_;
_dismiss(); //Once a commission-approved proposal is made, the proposal is initialized.
}
/**
* Suggest the functions you want to use.
*
* @notice To use some importan functions, propose function must be done first and voted.
*/
function propose(bytes memory _targetFuncData) onlyOwner public {
/* Check if there're any ongoing proposals */
require(committeeStatus.numOfVotes == 0);
require(committeeStatus.proposedFuncData.length == 0);
/* regist function informations that proposer want to run */
committeeStatus.proposedFuncData = _targetFuncData;
emit Propose(msg.sender, _targetFuncData);
}
/**
* Proposal is withdrawn
*
* @notice When the proposed function is no longer used or deprecated,
* proposal is discarded
*/
function dismiss() onlyOwner public {
_dismiss();
}
/**
* Suggest the functions you want to use.
*
* @notice 'dismiss' is executed even after successfully executing the proposed function.
* If 'msg.sender' want to pass permission, he can't pass the 'committeeApproved' modifier.
* internal functions are required to enable this.
*/
function _dismiss() internal {
emit Dismiss(msg.sender, committeeStatus.proposedFuncData);
committeeStatus.numOfVotes = 0;
committeeStatus.proposedFuncData = "";
delete ballot;
}
/**
* Owners vote for proposed item
*
* @notice if only there're proposals, 'vote' is processed.
* the result must be majority.
* one ticket for each owner.
*/
function vote() onlyOwner public {
// Check duplicated voting list.
uint length = ballot.length; // SmartDec Recommendations
for(uint i=0; i<length; i++) // SmartDec Recommendations
require(ballot[i] != msg.sender);
//onlyOnwers can vote, if there's ongoing proposal.
require( committeeStatus.proposedFuncData.length != 0 );
//Check, if everyone voted.
//require(committeeStatus.numOfOwners > committeeStatus.numOfVotes); // SmartDec Recommendations
committeeStatus.numOfVotes++;
ballot.push(msg.sender);
emit Vote(msg.sender, committeeStatus.proposedFuncData);
}
/**
* Existing owner transfers permissions to new owner.
*
* @notice It transfers authority to the person who was not the owner.
* Approval from the committee is required.
*/
function transferOwnership(address _newOwner) onlyOwner committeeApproved public {
require( _newOwner != address(0x0) ); // callisto recommendation
require( owner[_newOwner] == false );
owner[msg.sender] = false;
owner[_newOwner] = true;
emit TransferOwnership(msg.sender, _newOwner);
}
/**
* Add new Owner to committee
*
* @notice Approval from the committee is required.
*
*/
function addOwner(address _newOwner) onlyOwner committeeApproved public {
require( _newOwner != address(0x0) );
require( owner[_newOwner] != true );
owner[_newOwner] = true;
committeeStatus.numOfOwners++;
emit AddedOwner(_newOwner);
}
/**
* Remove the Owner from committee
*
* @notice Approval from the committee is required.
*
*/
function removeOwner(address _toRemove) onlyOwner committeeApproved public {
require( _toRemove != address(0x0) );
require( owner[_toRemove] == true );
require( committeeStatus.numOfOwners > committeeStatus.numOfMinOwners ); // must keep Number of Minimum Owners at least.
owner[_toRemove] = false;
committeeStatus.numOfOwners--;
emit RemovedOwner(_toRemove);
}
}
contract Pausable is MultiOwnable {
event Pause();
event Unpause();
bool internal paused;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
modifier noReentrancy() {
require(!paused);
paused = true;
_;
paused = false;
}
/* When you discover your smart contract is under attack, you can buy time to upgrade the contract by
immediately pausing the contract.
*/
function pause() public onlyOwner committeeApproved whenNotPaused {
paused = true;
emit Pause();
}
function unpause() public onlyOwner committeeApproved whenPaused {
paused = false;
emit Unpause();
}
}
/**
* Contract Managing TokenExchanger's address used by ProxyNemodax
*/
contract RunningContractManager is Pausable {
address public implementation; //SmartDec Recommendations
event Upgraded(address indexed newContract);
function upgrade(address _newAddr) onlyOwner committeeApproved external {
require(implementation != _newAddr);
implementation = _newAddr;
emit Upgraded(_newAddr); // SmartDec Recommendations
}
/* SmartDec Recommendations
function runningAddress() onlyOwner external view returns (address){
return implementation;
}
*/
}
/**
* @title NemodaxStorage
*
* @dev This is contract for proxyNemodax data order list.
* Contract shouldn't be changed as possible.
* If it should be edited, please add from the end of the contract .
*/
contract NemodaxStorage is RunningContractManager {
// Never ever change the order of variables below!!!!
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
mapping (address => bool) public frozenExpired; // SmartDec Recommendations
bool private initialized;
uint256 public tokenPerEth;
bool public opened = true;
}
/**
* @title ProxyNemodax
*
* @dev The only fallback function will forward transaction to TokenExchanger Contract.
* and the result of calculation would be stored in ProxyNemodax
*
*/
contract ProxyNemodax is NemodaxStorage {
/* Initialize new committee. this will be real committee accounts, not from TokenExchanger contract */
constructor(address _coOwner1,
address _coOwner2,
address _coOwner3,
address _coOwner4,
address _coOwner5)
MultiOwnable( _coOwner1, _coOwner2, _coOwner3, _coOwner4, _coOwner5) public {}
function () payable external {
address localImpl = implementation;
require(localImpl != address(0x0));
assembly {
let ptr := mload(0x40)
switch calldatasize
case 0 { } // just to receive ethereum
default{
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, localImpl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
}
}
pragma坚实度0.5.4;
/**
*@title SafeMath
*@dev Math操作与引发错误的安全检查
*/
图书馆安全数学{
/**
*@dev乘以两个数字,溢出时抛出。
*/
函数mul(uint256 a,uint256 b)内部纯返回(uint256 c){
//气体优化:这比断言“a”不是零,而是
//如果还测试了“b”,则福利将丢失。
//见:https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
如果(a==0){
返回0;
}
c=a*b;
断言(c/a==b);
返回c;
}
/**
*@dev两个数字的整数除法,截断商。
*/
函数div(uint256 a,uint256 b)内部纯返回(uint256){
//assert(b>0);//当Solidity除以0时自动抛出
//uint256 c=a/b;
//assert(a==b*c+a%b);//在任何情况下都是这样
返回a/b;
}
/**
*@dev减去两个数字,溢出时抛出(即如果减数大于分钟数)。
*/
函数子(uint256 a,uint256 b)内部纯返回(uint256){
断言(b=a);
返回c;
}
}
/**
*@title多所有权
*
*@dev需要多个所有者的多数批准才能使用和访问功能
*当需要限制访问关键功能时。
*
*/
合同多所有权{
对uint8使用SafeMath;
结构委员会数据包{
/**
*决策的关键信息。
*要节省一些气体,请选择结构。
*/
8名业主;
8票;
8名小业主;
建议的字节数据;
}
公共事务委员会;
地址[]公共投票;//以确保它是否已被投票
映射(地址=>bool)公共所有者;
事件投票(地址索引提议者,字节索引提议数据);
事件提议(地址索引提议者,字节索引提议数据);
事件解除(地址索引提议者,字节索引提议数据);
事件加法器(地址newOwner);
事件RemovedOwner(地址RemovedOwner);
事件转移所有权(地址自,地址至);
/**
*组织初始委员会。
*
*@通知委员会必须至少为3人。
*您必须使用此合同才能继承,因为它是内部的。
*
*@paramcoOwner1coOwner2coOwner3coOwner4coOwner5委员会成员
*/
构造函数(地址为1,地址为2,地址为3,地址为4,地址为5)内部{
require(_coOwner1!=地址(0x0)&&
_coOwner2!=地址(0x0)&&
_coOwner3!=地址(0x0)&&
_coOwner4!=地址(0x0)&&
_coOwner5!=地址(0x0));
需要(\u coOwner1!=\u coOwner2&&
_coOwner1!=\u coOwner3&&
_coOwner1!=\u coOwner4&&
_coOwner1!=\u coOwner5&&
_coOwner2!=\u coOwner3&&
_coOwner2!=\u coOwner4&&
_coOwner2!=\u coOwner5&&
_coOwner3!=\u coOwner4&&
_coOwner3!=\u coOwner5&&
_coOwner4!=\u coOwner5);//SmartDec建议
所有者[_coOwner1]=真;
所有者[_coOwner2]=真;
所有者[_coOwner3]=真;
所有者[_coOwner4]=真;
所有者[_coOwner5]=真;
committeeStatus.numOfOwners=5;
committeeStatus.numfminowners=5;
发射加法器(_coOwner1);
发射加法器(_coOwner2);
发射加法器(_coOwner3);
发射加法器(_coOwner4);
发射加法器(_coOwner5);
}
仅修饰符所有者(){
要求(所有者[消息发送者]);
_;
}
/**
*预先检查是否由委员会决定
*
*@如果获得大多数人的批准,
*带有此修饰符的函数将不会
const ProxyContract = artifacts.require("./ProxyContract.sol");
module.exports = function(deployer) {
deployer.deploy(ProxyContract).then( () => console.log("ProxyContract: " + ProxyContract.address))
}
truffle(develop)> migrate
truffle(develop)> var proxyContract = await ProxyContract.deployed()
undefined
truffle(develop)> proxyContract.committeeStatus.call().then(function (res) {console.log(res)})
Thrown:
Error: Invalid number of parameters for "committeeStatus". Got 0 expected 1!
at processTicksAndRejections (internal/process/next_tick.js:81:5)
at Promise (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/execute.js:128:1)
at Object._createTxObject (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:699:1)
at Object.InvalidNumberOfParams (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-helpers/src/errors.js:32:1)
truffle(develop)> proxyContract.committeeStatus
{ [Function]
call: [Function],
sendTransaction: [Function],
estimateGas: [Function],
request: [Function] }
truffle(develop)> proxyNemodax.committeeStatus.toString()
function() {
var params = {};
var defaultBlock = "latest";
var args = Array.prototype.slice.call(arguments);
var lastArg = args[args.length - 1];
// Extract defaultBlock parameter
if (execute.hasDefaultBlock(args, lastArg, methodABI.inputs)) {
defaultBlock = args.pop();
}
// Extract tx params
if (execute.hasTxParams(lastArg)) {
params = args.pop();
}
params.to = address;
params = utils.merge(constructor.class_defaults, params);
return new Promise(async (resolve, reject) => {
let result;
try {
await constructor.detectNetwork();
args = utils.convertToEthersBN(args);
result = await fn(...args).call(params, defaultBlock);
result = reformat.numbers.call(
constructor,
result,
methodABI.outputs
);
resolve(result);
} catch (err) {
reject(err);
}
});
}'
truffle(develop)> proxyNemodax.committeeStatus.call(0)
Thrown:
{ Error: invalid address (arg="", coderType="address", value=0)
at ABICoder.encodeParameters (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/src/index.js:96:1)
at AbiCoder.encode (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/abi-coder.js:897:1)
at CoderTuple.encode (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/abi-coder.js:764:1)
at pack (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/abi-coder.js:604:1)
at Array.forEach (<anonymous>)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/abi-coder.js:605:21
at CoderAddress.encode (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/abi-coder.js:467:1)
at Object.throwError (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-abi/~/ethers/utils/errors.js:68:1)
reason: 'invalid address',
code: 'INVALID_ARGUMENT',
arg: '',
coderType: 'address',
value: 0 }
pragma solidity 0.5.4;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title MultiOwnable
*
* @dev Require majority approval of multiple owners to use and access to features
* when restrictions on access to critical functions are required.
*
*/
contract MultiOwnable {
using SafeMath for uint8;
struct CommitteeStatusPack{
/**
* Key informations for decisions.
* To save some gas, choosing the struct.
*/
uint8 numOfOwners;
uint8 numOfVotes;
uint8 numOfMinOwners;
bytes proposedFuncData;
}
CommitteeStatusPack public committeeStatus;
address[] public ballot; // To make sure if it already was voted
mapping(address => bool) public owner;
event Vote(address indexed proposer, bytes indexed proposedFuncData);
event Propose(address indexed proposer, bytes indexed proposedFuncData);
event Dismiss(address indexed proposer, bytes indexed proposedFuncData);
event AddedOwner(address newOwner);
event RemovedOwner(address removedOwner);
event TransferOwnership(address from, address to);
/**
* Organize initial committee.
*
* @notice committee must be 3 at least.
* you have to use this contract to be inherited because it is internal.
*
* @param _coOwner1 _coOwner2 _coOwner3 _coOwner4 _coOwner5 committee members
*/
constructor(address _coOwner1, address _coOwner2, address _coOwner3, address _coOwner4, address _coOwner5) internal {
require(_coOwner1 != address(0x0) &&
_coOwner2 != address(0x0) &&
_coOwner3 != address(0x0) &&
_coOwner4 != address(0x0) &&
_coOwner5 != address(0x0));
require(_coOwner1 != _coOwner2 &&
_coOwner1 != _coOwner3 &&
_coOwner1 != _coOwner4 &&
_coOwner1 != _coOwner5 &&
_coOwner2 != _coOwner3 &&
_coOwner2 != _coOwner4 &&
_coOwner2 != _coOwner5 &&
_coOwner3 != _coOwner4 &&
_coOwner3 != _coOwner5 &&
_coOwner4 != _coOwner5); // SmartDec Recommendations
owner[_coOwner1] = true;
owner[_coOwner2] = true;
owner[_coOwner3] = true;
owner[_coOwner4] = true;
owner[_coOwner5] = true;
committeeStatus.numOfOwners = 5;
committeeStatus.numOfMinOwners = 5;
emit AddedOwner(_coOwner1);
emit AddedOwner(_coOwner2);
emit AddedOwner(_coOwner3);
emit AddedOwner(_coOwner4);
emit AddedOwner(_coOwner5);
}
modifier onlyOwner() {
require(owner[msg.sender]);
_;
}
/**
* Pre-check if it's decided by committee
*
* @notice If there is a majority approval,
* the function with this modifier will not be executed.
*/
modifier committeeApproved() {
/* check if proposed Function Name and real function Name are correct */
require( keccak256(committeeStatus.proposedFuncData) == keccak256(msg.data) ); // SmartDec Recommendations
/* To check majority */
require(committeeStatus.numOfVotes > committeeStatus.numOfOwners.div(2));
_;
_dismiss(); //Once a commission-approved proposal is made, the proposal is initialized.
}
/**
* Suggest the functions you want to use.
*
* @notice To use some importan functions, propose function must be done first and voted.
*/
function propose(bytes memory _targetFuncData) onlyOwner public {
/* Check if there're any ongoing proposals */
require(committeeStatus.numOfVotes == 0);
require(committeeStatus.proposedFuncData.length == 0);
/* regist function informations that proposer want to run */
committeeStatus.proposedFuncData = _targetFuncData;
emit Propose(msg.sender, _targetFuncData);
}
/**
* Proposal is withdrawn
*
* @notice When the proposed function is no longer used or deprecated,
* proposal is discarded
*/
function dismiss() onlyOwner public {
_dismiss();
}
/**
* Suggest the functions you want to use.
*
* @notice 'dismiss' is executed even after successfully executing the proposed function.
* If 'msg.sender' want to pass permission, he can't pass the 'committeeApproved' modifier.
* internal functions are required to enable this.
*/
function _dismiss() internal {
emit Dismiss(msg.sender, committeeStatus.proposedFuncData);
committeeStatus.numOfVotes = 0;
committeeStatus.proposedFuncData = "";
delete ballot;
}
/**
* Owners vote for proposed item
*
* @notice if only there're proposals, 'vote' is processed.
* the result must be majority.
* one ticket for each owner.
*/
function vote() onlyOwner public {
// Check duplicated voting list.
uint length = ballot.length; // SmartDec Recommendations
for(uint i=0; i<length; i++) // SmartDec Recommendations
require(ballot[i] != msg.sender);
//onlyOnwers can vote, if there's ongoing proposal.
require( committeeStatus.proposedFuncData.length != 0 );
//Check, if everyone voted.
//require(committeeStatus.numOfOwners > committeeStatus.numOfVotes); // SmartDec Recommendations
committeeStatus.numOfVotes++;
ballot.push(msg.sender);
emit Vote(msg.sender, committeeStatus.proposedFuncData);
}
/**
* Existing owner transfers permissions to new owner.
*
* @notice It transfers authority to the person who was not the owner.
* Approval from the committee is required.
*/
function transferOwnership(address _newOwner) onlyOwner committeeApproved public {
require( _newOwner != address(0x0) ); // callisto recommendation
require( owner[_newOwner] == false );
owner[msg.sender] = false;
owner[_newOwner] = true;
emit TransferOwnership(msg.sender, _newOwner);
}
/**
* Add new Owner to committee
*
* @notice Approval from the committee is required.
*
*/
function addOwner(address _newOwner) onlyOwner committeeApproved public {
require( _newOwner != address(0x0) );
require( owner[_newOwner] != true );
owner[_newOwner] = true;
committeeStatus.numOfOwners++;
emit AddedOwner(_newOwner);
}
/**
* Remove the Owner from committee
*
* @notice Approval from the committee is required.
*
*/
function removeOwner(address _toRemove) onlyOwner committeeApproved public {
require( _toRemove != address(0x0) );
require( owner[_toRemove] == true );
require( committeeStatus.numOfOwners > committeeStatus.numOfMinOwners ); // must keep Number of Minimum Owners at least.
owner[_toRemove] = false;
committeeStatus.numOfOwners--;
emit RemovedOwner(_toRemove);
}
}
contract Pausable is MultiOwnable {
event Pause();
event Unpause();
bool internal paused;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
modifier noReentrancy() {
require(!paused);
paused = true;
_;
paused = false;
}
/* When you discover your smart contract is under attack, you can buy time to upgrade the contract by
immediately pausing the contract.
*/
function pause() public onlyOwner committeeApproved whenNotPaused {
paused = true;
emit Pause();
}
function unpause() public onlyOwner committeeApproved whenPaused {
paused = false;
emit Unpause();
}
}
/**
* Contract Managing TokenExchanger's address used by ProxyNemodax
*/
contract RunningContractManager is Pausable {
address public implementation; //SmartDec Recommendations
event Upgraded(address indexed newContract);
function upgrade(address _newAddr) onlyOwner committeeApproved external {
require(implementation != _newAddr);
implementation = _newAddr;
emit Upgraded(_newAddr); // SmartDec Recommendations
}
/* SmartDec Recommendations
function runningAddress() onlyOwner external view returns (address){
return implementation;
}
*/
}
/**
* @title NemodaxStorage
*
* @dev This is contract for proxyNemodax data order list.
* Contract shouldn't be changed as possible.
* If it should be edited, please add from the end of the contract .
*/
contract NemodaxStorage is RunningContractManager {
// Never ever change the order of variables below!!!!
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
/* This creates an array with all balances */
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
mapping (address => bool) public frozenExpired; // SmartDec Recommendations
bool private initialized;
uint256 public tokenPerEth;
bool public opened = true;
}
/**
* @title ProxyNemodax
*
* @dev The only fallback function will forward transaction to TokenExchanger Contract.
* and the result of calculation would be stored in ProxyNemodax
*
*/
contract ProxyNemodax is NemodaxStorage {
/* Initialize new committee. this will be real committee accounts, not from TokenExchanger contract */
constructor(address _coOwner1,
address _coOwner2,
address _coOwner3,
address _coOwner4,
address _coOwner5)
MultiOwnable( _coOwner1, _coOwner2, _coOwner3, _coOwner4, _coOwner5) public {}
function () payable external {
address localImpl = implementation;
require(localImpl != address(0x0));
assembly {
let ptr := mload(0x40)
switch calldatasize
case 0 { } // just to receive ethereum
default{
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, localImpl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
}
}
Error: Invalid number of parameters for "committeeStatus". Got 0 expected 1!
{
"constant": true,
"inputs": [],
"name": "committeeStatus",
"outputs": [
{
"name": "numOfOwners",
"type": "uint8"
},
{
"name": "numOfVotes",
"type": "uint8"
},
{
"name": "numOfMinOwners",
"type": "uint8"
},
{
"name": "proposedFuncData",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},