@reality.eth/contracts 3.0.1 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/chains/chainid.network.json +7691 -1349
- package/chains/deployments/1/ETH/RealityETH-3.0.json +4 -1
- package/chains/deployments/1/SWISE/RealityETH_ERC20-3.0.json +7 -0
- package/chains/deployments/10/OETH/RealityETH-3.0.json +6 -0
- package/chains/deployments/100/GNO/RealityETH_ERC20-3.0.json +7 -0
- package/chains/deployments/100/SWISE/RealityETH_ERC20-3.0.json +7 -0
- package/chains/deployments/100/XDAI/RealityETH-3.0.json +3 -1
- package/chains/deployments/1337702/ETH/RealityETH-3.0.json +6 -0
- package/chains/deployments/4/ETH/RealityETH-3.0.json +3 -1
- package/chains/deployments/42/ETH/RealityETH-3.0.json +2 -1
- package/chains/deployments/56/DEXE/RealityETH_ERC20-3.0.json +7 -0
- package/chains/deployments/69/OETH/RealityETH-3.0.json +6 -0
- package/chains/deployments/77/XDAI/RealityETH-2.1-rc1.json +1 -3
- package/chains/deployments/777/CTH/RealityETH-3.0.json +6 -0
- package/chains/supported.json +23 -3
- package/development/contracts/Arbitrator.sol +7 -6
- package/development/contracts/BalanceHolder.sol +4 -2
- package/development/contracts/{BalanceHolderERC20.sol → BalanceHolder_ERC20.sol} +3 -2
- package/development/contracts/IArbitrator.sol +4 -7
- package/development/contracts/IArbitratorForeignProxy.sol +12 -0
- package/development/contracts/IBalanceHolder.sol +3 -1
- package/development/contracts/IBalanceHolder_ERC20.sol +11 -0
- package/development/contracts/IERC20.sol +1 -1
- package/development/contracts/IOwned.sol +1 -1
- package/development/contracts/IRealityETH.sol +63 -0
- package/development/contracts/IRealityETH_ERC20.sol +67 -0
- package/development/contracts/Owned.sol +4 -2
- package/development/contracts/RealityETH-3.0.sol +4 -82
- package/development/contracts/RealityETH_ERC20-3.0.sol +3 -3
- package/generated/chains.json +95 -22
- package/generated/contracts.json +89 -7
- package/generated/tokens.json +34 -2
- package/index.js +9 -4
- package/package.json +3 -3
- package/scripts/deploy.js +14 -3
- package/scripts/fetch_and_reformat_chains_json.js +31 -0
- package/scripts/{format_abi.js → format_json.js} +0 -0
- package/scripts/generate_chains_json.js +3 -0
- package/scripts/send_funds.js +52 -0
- package/tokens/CTH.json +7 -0
- package/tokens/DEXE.json +7 -0
- package/tokens/ETH.json +2 -1
- package/tokens/GNO.json +1 -0
- package/tokens/OETH.json +8 -0
- package/tokens/SWISE.json +8 -0
- package/development/contracts/IRealitio.sol +0 -44
- package/development/contracts/MultiSigWallet.sol +0 -391
- package/development/contracts/Realitio.sol +0 -756
- package/development/contracts/RealitioERC20.sol +0 -825
- package/development/contracts/RealitioSafeMath256.sol +0 -36
- package/development/contracts/RealitioSafeMath32.sol +0 -17
- package/development/contracts/Realitio_v2_1.sol +0 -819
- package/development/contracts/SplitterWallet.sol +0 -142
- package/tests/python/test_wallet.py +0 -185
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const ethers = require('ethers');
|
|
3
|
+
|
|
4
|
+
const from = process.argv[2]
|
|
5
|
+
if (!from) {
|
|
6
|
+
throw new Error("Usage: node migrate_wallet.js <from> <to> <rpc>");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const to = process.argv[3]
|
|
10
|
+
if (!to) {
|
|
11
|
+
throw new Error("Usage: node migrate_wallet.js <from> <to> <rpc>");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const rpc = process.argv[4];
|
|
15
|
+
if (!rpc) {
|
|
16
|
+
throw new Error("Usage: node migrate_wallet.js <from> <to> <rpc>");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// For infura we just pass the network name eg kovan
|
|
20
|
+
const provider = (rpc.startsWith('http')) ? new ethers.providers.JsonRpcProvider(rpc) : new ethers.providers.InfuraProvider(rpc);
|
|
21
|
+
|
|
22
|
+
const fpriv = fs.readFileSync(from, 'utf8').replace(/\n/, '')
|
|
23
|
+
const tpriv = fs.readFileSync(to, 'utf8').replace(/\n/, '')
|
|
24
|
+
|
|
25
|
+
const f = new ethers.Wallet(fpriv, provider);
|
|
26
|
+
const t = new ethers.Wallet(tpriv, provider);
|
|
27
|
+
|
|
28
|
+
//console.log(provider);
|
|
29
|
+
migrateFunds(provider, f, t);
|
|
30
|
+
|
|
31
|
+
async function migrateFunds(provider, f, t) {
|
|
32
|
+
|
|
33
|
+
const bal = await provider.getBalance(f.signingKey.address)
|
|
34
|
+
const gas_price = await provider.getGasPrice()
|
|
35
|
+
const nonce = await provider.getTransactionCount(f.signingKey.address, 'latest')
|
|
36
|
+
const gas_limit = 21000;
|
|
37
|
+
|
|
38
|
+
// console.log(f)
|
|
39
|
+
|
|
40
|
+
const txdata = {
|
|
41
|
+
to: t.signingKey.address,
|
|
42
|
+
value: bal.sub((gas_price.mul(gas_limit))),
|
|
43
|
+
nonce: nonce,
|
|
44
|
+
gasLimit: ethers.utils.hexlify(gas_limit),
|
|
45
|
+
gasPrice: gas_price,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const walletSigner = f.connect(provider)
|
|
49
|
+
const response = await walletSigner.sendTransaction(txdata);
|
|
50
|
+
console.log('sent tx', response.hash)
|
|
51
|
+
|
|
52
|
+
};
|
package/tokens/CTH.json
ADDED
package/tokens/DEXE.json
ADDED
package/tokens/ETH.json
CHANGED
package/tokens/GNO.json
CHANGED
package/tokens/OETH.json
ADDED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.6;
|
|
4
|
-
|
|
5
|
-
interface IRealitio {
|
|
6
|
-
function claimWinnings ( bytes32 question_id, bytes32[] memory history_hashes, address[] memory addrs, uint256[] memory bonds, bytes32[] memory answers ) external;
|
|
7
|
-
function getFinalAnswerIfMatches ( bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond ) external view returns ( bytes32 );
|
|
8
|
-
function getBounty ( bytes32 question_id ) external view returns ( uint256 );
|
|
9
|
-
function getArbitrator ( bytes32 question_id ) external view returns ( address );
|
|
10
|
-
function getBond ( bytes32 question_id ) external view returns ( uint256 );
|
|
11
|
-
function claimMultipleAndWithdrawBalance ( bytes32[] memory question_ids, uint256[] memory lengths, bytes32[] memory hist_hashes, address[] memory addrs, uint256[] memory bonds, bytes32[] memory answers ) external;
|
|
12
|
-
function withdraw ( ) external;
|
|
13
|
-
function submitAnswerReveal ( bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond ) external;
|
|
14
|
-
function setQuestionFee ( uint256 fee ) external;
|
|
15
|
-
function template_hashes ( uint256 ) external view returns ( bytes32 );
|
|
16
|
-
function getContentHash ( bytes32 question_id ) external view returns ( bytes32 );
|
|
17
|
-
function question_claims ( bytes32 ) external view returns ( address payee, uint256 last_bond, uint256 queued_funds );
|
|
18
|
-
function fundAnswerBounty ( bytes32 question_id ) external payable;
|
|
19
|
-
function arbitrator_question_fees ( address ) external view returns ( uint256 );
|
|
20
|
-
function balanceOf ( address ) external view returns ( uint256 );
|
|
21
|
-
function askQuestion ( uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce ) external payable returns ( bytes32 );
|
|
22
|
-
function submitAnswer ( bytes32 question_id, bytes32 answer, uint256 max_previous ) external payable;
|
|
23
|
-
function submitAnswerFor ( bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer ) external payable; // Only available from v2.1
|
|
24
|
-
function isFinalized ( bytes32 question_id ) external view returns ( bool );
|
|
25
|
-
function getHistoryHash ( bytes32 question_id ) external view returns ( bytes32 );
|
|
26
|
-
function commitments ( bytes32 ) external view returns ( uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer );
|
|
27
|
-
function createTemplate ( string memory content ) external returns ( uint256 );
|
|
28
|
-
function getBestAnswer ( bytes32 question_id ) external view returns ( bytes32 );
|
|
29
|
-
function isPendingArbitration ( bytes32 question_id ) external view returns ( bool );
|
|
30
|
-
function questions ( bytes32 ) external view returns ( bytes32 content_hash, address arbitrator, uint32 opening_ts, uint32 timeout, uint32 finalize_ts, bool is_pending_arbitration, uint256 bounty, bytes32 best_answer, bytes32 history_hash, uint256 bond );
|
|
31
|
-
function getOpeningTS ( bytes32 question_id ) external view returns ( uint32 );
|
|
32
|
-
function getTimeout ( bytes32 question_id ) external view returns ( uint32 );
|
|
33
|
-
function createTemplateAndAskQuestion ( string memory content, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce ) external payable returns ( bytes32 );
|
|
34
|
-
function getFinalAnswer ( bytes32 question_id ) external view returns ( bytes32 );
|
|
35
|
-
function getFinalizeTS ( bytes32 question_id ) external view returns ( uint32 );
|
|
36
|
-
function templates ( uint256 ) external view returns ( uint256 );
|
|
37
|
-
function resultFor ( bytes32 question_id ) external view returns ( bytes32 );
|
|
38
|
-
function submitAnswerCommitment ( bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer ) external payable;
|
|
39
|
-
function notifyOfArbitrationRequest ( bytes32 question_id, address requester, uint256 max_previous ) external;
|
|
40
|
-
function submitAnswerByArbitrator ( bytes32 question_id, bytes32 answer, address answerer ) external;
|
|
41
|
-
function assignWinnerAndSubmitAnswerByArbitrator( bytes32 question_id, bytes32 answer, address payee_if_wrong, bytes32 last_history_hash, bytes32 last_answer_or_commitment_id, address last_answerer ) external;
|
|
42
|
-
function cancelArbitration(bytes32 question_id) external; // Only available from v2.1
|
|
43
|
-
}
|
|
44
|
-
|
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
pragma solidity ^0.4.25;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
|
|
5
|
-
/// @author Stefan George - <stefan.george@consensys.net>
|
|
6
|
-
contract MultiSigWallet {
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Events
|
|
10
|
-
*/
|
|
11
|
-
event Confirmation(address indexed sender, uint indexed transactionId);
|
|
12
|
-
event Revocation(address indexed sender, uint indexed transactionId);
|
|
13
|
-
event Submission(uint indexed transactionId);
|
|
14
|
-
event Execution(uint indexed transactionId);
|
|
15
|
-
event ExecutionFailure(uint indexed transactionId);
|
|
16
|
-
event Deposit(address indexed sender, uint value);
|
|
17
|
-
event OwnerAddition(address indexed owner);
|
|
18
|
-
event OwnerRemoval(address indexed owner);
|
|
19
|
-
event RequirementChange(uint required);
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
* Constants
|
|
23
|
-
*/
|
|
24
|
-
uint constant public MAX_OWNER_COUNT = 50;
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* Storage
|
|
28
|
-
*/
|
|
29
|
-
mapping (uint => Transaction) public transactions;
|
|
30
|
-
mapping (uint => mapping (address => bool)) public confirmations;
|
|
31
|
-
mapping (address => bool) public isOwner;
|
|
32
|
-
address[] public owners;
|
|
33
|
-
uint public required;
|
|
34
|
-
uint public transactionCount;
|
|
35
|
-
|
|
36
|
-
struct Transaction {
|
|
37
|
-
address destination;
|
|
38
|
-
uint value;
|
|
39
|
-
bytes data;
|
|
40
|
-
bool executed;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
* Modifiers
|
|
45
|
-
*/
|
|
46
|
-
modifier onlyWallet() {
|
|
47
|
-
require(msg.sender == address(this));
|
|
48
|
-
_;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
modifier ownerDoesNotExist(address owner) {
|
|
52
|
-
require(!isOwner[owner]);
|
|
53
|
-
_;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
modifier ownerExists(address owner) {
|
|
57
|
-
require(isOwner[owner]);
|
|
58
|
-
_;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
modifier transactionExists(uint transactionId) {
|
|
62
|
-
require(transactions[transactionId].destination != 0);
|
|
63
|
-
_;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
modifier confirmed(uint transactionId, address owner) {
|
|
67
|
-
require(confirmations[transactionId][owner]);
|
|
68
|
-
_;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
modifier notConfirmed(uint transactionId, address owner) {
|
|
72
|
-
require(!confirmations[transactionId][owner]);
|
|
73
|
-
_;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
modifier notExecuted(uint transactionId) {
|
|
77
|
-
require(!transactions[transactionId].executed);
|
|
78
|
-
_;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
modifier notNull(address _address) {
|
|
82
|
-
require(_address != 0);
|
|
83
|
-
_;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
modifier validRequirement(uint ownerCount, uint _required) {
|
|
87
|
-
require(ownerCount <= MAX_OWNER_COUNT
|
|
88
|
-
&& _required <= ownerCount
|
|
89
|
-
&& _required != 0
|
|
90
|
-
&& ownerCount != 0);
|
|
91
|
-
_;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/// @dev Fallback function allows to deposit ether.
|
|
95
|
-
function()
|
|
96
|
-
public payable
|
|
97
|
-
{
|
|
98
|
-
if (msg.value > 0)
|
|
99
|
-
emit Deposit(msg.sender, msg.value);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/*
|
|
103
|
-
* Public functions
|
|
104
|
-
*/
|
|
105
|
-
/// @dev Contract constructor sets initial owners and required number of confirmations.
|
|
106
|
-
/// @param _owners List of initial owners.
|
|
107
|
-
/// @param _required Number of required confirmations.
|
|
108
|
-
constructor(address[] _owners, uint _required)
|
|
109
|
-
public
|
|
110
|
-
validRequirement(_owners.length, _required)
|
|
111
|
-
{
|
|
112
|
-
for (uint i=0; i<_owners.length; i++) {
|
|
113
|
-
require(!isOwner[_owners[i]] && _owners[i] != 0);
|
|
114
|
-
isOwner[_owners[i]] = true;
|
|
115
|
-
}
|
|
116
|
-
owners = _owners;
|
|
117
|
-
required = _required;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/// @dev Allows to add a new owner. Transaction has to be sent by wallet.
|
|
121
|
-
/// @param owner Address of new owner.
|
|
122
|
-
function addOwner(address owner)
|
|
123
|
-
public
|
|
124
|
-
onlyWallet
|
|
125
|
-
ownerDoesNotExist(owner)
|
|
126
|
-
notNull(owner)
|
|
127
|
-
validRequirement(owners.length + 1, required)
|
|
128
|
-
{
|
|
129
|
-
isOwner[owner] = true;
|
|
130
|
-
owners.push(owner);
|
|
131
|
-
emit OwnerAddition(owner);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/// @dev Allows to remove an owner. Transaction has to be sent by wallet.
|
|
135
|
-
/// @param owner Address of owner.
|
|
136
|
-
function removeOwner(address owner)
|
|
137
|
-
public
|
|
138
|
-
onlyWallet
|
|
139
|
-
ownerExists(owner)
|
|
140
|
-
{
|
|
141
|
-
isOwner[owner] = false;
|
|
142
|
-
for (uint i=0; i<owners.length - 1; i++)
|
|
143
|
-
if (owners[i] == owner) {
|
|
144
|
-
owners[i] = owners[owners.length - 1];
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
owners.length -= 1;
|
|
148
|
-
if (required > owners.length)
|
|
149
|
-
changeRequirement(owners.length);
|
|
150
|
-
emit OwnerRemoval(owner);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
|
|
154
|
-
/// @param owner Address of owner to be replaced.
|
|
155
|
-
/// @param newOwner Address of new owner.
|
|
156
|
-
function replaceOwner(address owner, address newOwner)
|
|
157
|
-
public
|
|
158
|
-
onlyWallet
|
|
159
|
-
ownerExists(owner)
|
|
160
|
-
ownerDoesNotExist(newOwner)
|
|
161
|
-
{
|
|
162
|
-
for (uint i=0; i<owners.length; i++)
|
|
163
|
-
if (owners[i] == owner) {
|
|
164
|
-
owners[i] = newOwner;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
isOwner[owner] = false;
|
|
168
|
-
isOwner[newOwner] = true;
|
|
169
|
-
emit OwnerRemoval(owner);
|
|
170
|
-
emit OwnerAddition(newOwner);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
|
|
174
|
-
/// @param _required Number of required confirmations.
|
|
175
|
-
function changeRequirement(uint _required)
|
|
176
|
-
public
|
|
177
|
-
onlyWallet
|
|
178
|
-
validRequirement(owners.length, _required)
|
|
179
|
-
{
|
|
180
|
-
required = _required;
|
|
181
|
-
emit RequirementChange(_required);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/// @dev Allows an owner to submit and confirm a transaction.
|
|
185
|
-
/// @param destination Transaction target address.
|
|
186
|
-
/// @param value Transaction ether value.
|
|
187
|
-
/// @param data Transaction data payload.
|
|
188
|
-
/// @return Returns transaction ID.
|
|
189
|
-
function submitTransaction(address destination, uint value, bytes data)
|
|
190
|
-
public
|
|
191
|
-
returns (uint transactionId)
|
|
192
|
-
{
|
|
193
|
-
transactionId = addTransaction(destination, value, data);
|
|
194
|
-
//confirmTransaction(transactionId);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/// @dev Allows an owner to confirm a transaction.
|
|
198
|
-
/// @param transactionId Transaction ID.
|
|
199
|
-
function confirmTransaction(uint transactionId)
|
|
200
|
-
public
|
|
201
|
-
ownerExists(msg.sender)
|
|
202
|
-
transactionExists(transactionId)
|
|
203
|
-
notConfirmed(transactionId, msg.sender)
|
|
204
|
-
{
|
|
205
|
-
confirmations[transactionId][msg.sender] = true;
|
|
206
|
-
emit Confirmation(msg.sender, transactionId);
|
|
207
|
-
executeTransaction(transactionId);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/// @dev Allows an owner to revoke a confirmation for a transaction.
|
|
211
|
-
/// @param transactionId Transaction ID.
|
|
212
|
-
function revokeConfirmation(uint transactionId)
|
|
213
|
-
public
|
|
214
|
-
ownerExists(msg.sender)
|
|
215
|
-
confirmed(transactionId, msg.sender)
|
|
216
|
-
notExecuted(transactionId)
|
|
217
|
-
{
|
|
218
|
-
confirmations[transactionId][msg.sender] = false;
|
|
219
|
-
emit Revocation(msg.sender, transactionId);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/// @dev Allows anyone to execute a confirmed transaction.
|
|
223
|
-
/// @param transactionId Transaction ID.
|
|
224
|
-
function executeTransaction(uint transactionId)
|
|
225
|
-
public
|
|
226
|
-
ownerExists(msg.sender)
|
|
227
|
-
confirmed(transactionId, msg.sender)
|
|
228
|
-
notExecuted(transactionId)
|
|
229
|
-
{
|
|
230
|
-
if (isConfirmed(transactionId)) {
|
|
231
|
-
Transaction storage txn = transactions[transactionId];
|
|
232
|
-
txn.executed = true;
|
|
233
|
-
if (external_call(txn.destination, txn.value, txn.data.length, txn.data))
|
|
234
|
-
emit Execution(transactionId);
|
|
235
|
-
else {
|
|
236
|
-
emit ExecutionFailure(transactionId);
|
|
237
|
-
txn.executed = false;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// call has been separated into its own function in order to take advantage
|
|
243
|
-
// of the Solidity's code generator to produce a loop that copies tx.data into memory.
|
|
244
|
-
function external_call(address destination, uint value, uint dataLength, bytes data) private returns (bool) {
|
|
245
|
-
bool result;
|
|
246
|
-
assembly {
|
|
247
|
-
let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
|
|
248
|
-
let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
|
|
249
|
-
result := call(
|
|
250
|
-
sub(gas, 34710), // 34710 is the value that solidity is currently emitting
|
|
251
|
-
// It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
|
|
252
|
-
// callNewAccountGas (25000, in case the destination address does not exist and needs creating)
|
|
253
|
-
destination,
|
|
254
|
-
value,
|
|
255
|
-
d,
|
|
256
|
-
dataLength, // Size of the input (in bytes) - this is what fixes the padding problem
|
|
257
|
-
x,
|
|
258
|
-
0 // Output is ignored, therefore the output size is zero
|
|
259
|
-
)
|
|
260
|
-
}
|
|
261
|
-
return result;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/// @dev Returns the confirmation status of a transaction.
|
|
265
|
-
/// @param transactionId Transaction ID.
|
|
266
|
-
/// @return Confirmation status.
|
|
267
|
-
function isConfirmed(uint transactionId)
|
|
268
|
-
public
|
|
269
|
-
constant
|
|
270
|
-
returns (bool)
|
|
271
|
-
{
|
|
272
|
-
uint count = 0;
|
|
273
|
-
for (uint i=0; i<owners.length; i++) {
|
|
274
|
-
if (confirmations[transactionId][owners[i]])
|
|
275
|
-
count += 1;
|
|
276
|
-
if (count == required)
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/*
|
|
282
|
-
* Internal functions
|
|
283
|
-
*/
|
|
284
|
-
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
|
|
285
|
-
/// @param destination Transaction target address.
|
|
286
|
-
/// @param value Transaction ether value.
|
|
287
|
-
/// @param data Transaction data payload.
|
|
288
|
-
/// @return Returns transaction ID.
|
|
289
|
-
function addTransaction(address destination, uint value, bytes data)
|
|
290
|
-
internal
|
|
291
|
-
returns (uint transactionId)
|
|
292
|
-
{
|
|
293
|
-
transactionId = transactionCount;
|
|
294
|
-
transactions[transactionId] = Transaction({
|
|
295
|
-
destination: destination,
|
|
296
|
-
value: value,
|
|
297
|
-
data: data,
|
|
298
|
-
executed: false
|
|
299
|
-
});
|
|
300
|
-
transactionCount += 1;
|
|
301
|
-
emit Submission(transactionId);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/*
|
|
305
|
-
* Web3 call functions
|
|
306
|
-
*/
|
|
307
|
-
/// @dev Returns number of confirmations of a transaction.
|
|
308
|
-
/// @param transactionId Transaction ID.
|
|
309
|
-
/// @return Number of confirmations.
|
|
310
|
-
function getConfirmationCount(uint transactionId)
|
|
311
|
-
public
|
|
312
|
-
constant
|
|
313
|
-
returns (uint count)
|
|
314
|
-
{
|
|
315
|
-
for (uint i=0; i<owners.length; i++)
|
|
316
|
-
if (confirmations[transactionId][owners[i]])
|
|
317
|
-
count += 1;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/// @dev Returns total number of transactions after filers are applied.
|
|
321
|
-
/// @param pending Include pending transactions.
|
|
322
|
-
/// @param executed Include executed transactions.
|
|
323
|
-
/// @return Total number of transactions after filters are applied.
|
|
324
|
-
function getTransactionCount(bool pending, bool executed)
|
|
325
|
-
public
|
|
326
|
-
constant
|
|
327
|
-
returns (uint count)
|
|
328
|
-
{
|
|
329
|
-
for (uint i=0; i<transactionCount; i++)
|
|
330
|
-
if ( pending && !transactions[i].executed
|
|
331
|
-
|| executed && transactions[i].executed)
|
|
332
|
-
count += 1;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/// @dev Returns list of owners.
|
|
336
|
-
/// @return List of owner addresses.
|
|
337
|
-
function getOwners()
|
|
338
|
-
public
|
|
339
|
-
constant
|
|
340
|
-
returns (address[])
|
|
341
|
-
{
|
|
342
|
-
return owners;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/// @dev Returns array with owner addresses, which confirmed transaction.
|
|
346
|
-
/// @param transactionId Transaction ID.
|
|
347
|
-
/// @return Returns array of owner addresses.
|
|
348
|
-
function getConfirmations(uint transactionId)
|
|
349
|
-
public
|
|
350
|
-
constant
|
|
351
|
-
returns (address[] _confirmations)
|
|
352
|
-
{
|
|
353
|
-
address[] memory confirmationsTemp = new address[](owners.length);
|
|
354
|
-
uint count = 0;
|
|
355
|
-
uint i;
|
|
356
|
-
for (i=0; i<owners.length; i++)
|
|
357
|
-
if (confirmations[transactionId][owners[i]]) {
|
|
358
|
-
confirmationsTemp[count] = owners[i];
|
|
359
|
-
count += 1;
|
|
360
|
-
}
|
|
361
|
-
_confirmations = new address[](count);
|
|
362
|
-
for (i=0; i<count; i++)
|
|
363
|
-
_confirmations[i] = confirmationsTemp[i];
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/// @dev Returns list of transaction IDs in defined range.
|
|
367
|
-
/// @param from Index start position of transaction array.
|
|
368
|
-
/// @param to Index end position of transaction array.
|
|
369
|
-
/// @param pending Include pending transactions.
|
|
370
|
-
/// @param executed Include executed transactions.
|
|
371
|
-
/// @return Returns array of transaction IDs.
|
|
372
|
-
function getTransactionIds(uint from, uint to, bool pending, bool executed)
|
|
373
|
-
public
|
|
374
|
-
constant
|
|
375
|
-
returns (uint[] _transactionIds)
|
|
376
|
-
{
|
|
377
|
-
uint[] memory transactionIdsTemp = new uint[](transactionCount);
|
|
378
|
-
uint count = 0;
|
|
379
|
-
uint i;
|
|
380
|
-
for (i=0; i<transactionCount; i++)
|
|
381
|
-
if ( pending && !transactions[i].executed
|
|
382
|
-
|| executed && transactions[i].executed)
|
|
383
|
-
{
|
|
384
|
-
transactionIdsTemp[count] = i;
|
|
385
|
-
count += 1;
|
|
386
|
-
}
|
|
387
|
-
_transactionIds = new uint[](to - from);
|
|
388
|
-
for (i=from; i<to; i++)
|
|
389
|
-
_transactionIds[i - from] = transactionIdsTemp[i];
|
|
390
|
-
}
|
|
391
|
-
}
|