forked from pacta-app/vote-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssembly.sol
More file actions
116 lines (96 loc) · 2.68 KB
/
Copy pathAssembly.sol
File metadata and controls
116 lines (96 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
pragma solidity >=0.0;
import "./owned.sol";
import "./signed.sol";
import "./LibAssembly.sol";
contract Assembly is owned, signed {
using LibAssembly for LibAssembly.Data;
LibAssembly.Data private data;
constructor(
string memory _identifier,
address _signatory
) public signed(_signatory) {
data.construct(_identifier);
}
// getter
function identifier() public view returns (string memory) {
return data.identifier;
}
function registrations(string memory s) public view returns (address) {
return data.registrations[s];
}
function shareholders(address a) public view returns (string memory) {
return data.shareholders[a];
}
function secrets(uint256 i) public view returns (string memory) {
return data.secrets[i];
}
function votings(uint256 i) public view returns (address) {
return data.votings[i];
}
function numSecrets() public view returns (uint256) {
return data.secrets.length;
}
function numVotings() public view returns (uint256) {
return data.votings.length;
}
function shares() public view returns (address) {
return address(data.shares);
}
// shareholder's access, security by signed messages
function register(
string memory secret,
uint8 v,
bytes32 r,
bytes32 s
) public restrict {
data.register(secret, address(this), v, r, s);
}
// administration, restricted to assembly owner
function setShareholder(
address _shareholder,
uint256 _shares,
uint8 v,
bytes32 r,
bytes32 s
)
public
restrict
issigned(abi.encode(_shareholder, _shares, address(this)), v, r, s)
{
data.setShareholder(_shareholder, _shares);
}
function setShareholders(
address[] memory _shareholders,
uint256[] memory _shares,
uint8 v,
bytes32 r,
bytes32 s
)
public
restrict
issigned(abi.encode(_shareholders, _shares, address(this)), v, r, s)
{
data.setShareholders(_shareholders, _shares);
}
event votingCreated(address);
function newVoting(
string memory title,
string memory proposal,
uint8 v,
bytes32 r,
bytes32 s
)
public
restrict
issigned(abi.encode(title, proposal, address(this)), v, r, s)
{
emit votingCreated(data.newVoting(title, proposal, signatory, owner));
}
function lock(
uint8 v,
bytes32 r,
bytes32 s
) public restrict issigned(abi.encode(address(this)), v, r, s) {
data.lock();
}
}