ethereum 0.4.75 → 0.4.80
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.
- checksums.yaml +4 -4
- data/contracts/AuditorRegistry.sol +1 -1
- data/contracts/CustodianInterface.sol +8 -3
- data/contracts/CustodianRegistry.sol +29 -3
- data/contracts/DigixConfiguration.sol +21 -9
- data/contracts/Directory.sol +53 -11
- data/contracts/DoublyLinked.sol +54 -0
- data/contracts/GenericInterface.sol +56 -0
- data/contracts/GenericRegistry.sol +15 -0
- data/contracts/Gold.sol +81 -43
- data/contracts/GoldRegistry.sol +58 -25
- data/contracts/Interface.sol +4 -34
- data/contracts/VendorInterface.sol +61 -4
- data/contracts/VendorRegistry.sol +3 -15
- data/lib/ethereum/contract_initializer.rb +2 -2
- data/lib/ethereum/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: befea2e8d4a0984de8d00db21e1d3e8069ae444b
|
4
|
+
data.tar.gz: 224ac503b98fe2c838538648b7034d7cd78b69eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 213fec4859c390068a7d6e0f9dd0cb262f6e05f23bb61cc02d0236e1475f3fabc01c28c6976731ee83440ed4e86761d9378ecb8a4ff4080279e7f9233f66eda5
|
7
|
+
data.tar.gz: 689c5d782fca556d657d24a49d4e06edad39c2cca80e12889517cf9543ccd0bd05bb440482fbeb13aefff9044b22716f698fbc61cc89d5479cc0114106b01d18
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import "contracts/Interface.sol";
|
2
|
+
import "contracts/Gold.sol";
|
3
|
+
import "contracts/GoldRegistry.sol";
|
2
4
|
|
3
5
|
contract CustodianInterface is Interface {
|
4
6
|
|
@@ -6,11 +8,14 @@ contract CustodianInterface is Interface {
|
|
6
8
|
owner = msg.sender;
|
7
9
|
config = _config;
|
8
10
|
}
|
9
|
-
|
10
|
-
function
|
11
|
-
|
11
|
+
|
12
|
+
function receiveFromVendor(address _gold, bytes32 _doc) ifemployee {
|
13
|
+
GoldRegistry(goldRegistry()).receiveFromVendor(_gold, _doc);
|
12
14
|
}
|
13
15
|
|
16
|
+
function transferCustodian(address _gold, address _cstdn) ifemployee {
|
17
|
+
}
|
18
|
+
|
14
19
|
function isRedeemable(address _gold) public returns (bool) {
|
15
20
|
return true;
|
16
21
|
}
|
@@ -1,11 +1,37 @@
|
|
1
|
-
|
1
|
+
import "contracts/Directory.sol";
|
2
|
+
import "contracts/GenericRegistry.sol";
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
contract CustodianRegistry is GenericRegistry {
|
5
|
+
|
6
|
+
Directory.AddressBoolMap custodians;
|
7
|
+
|
8
|
+
struct Custodian {
|
9
|
+
bytes32 name;
|
10
|
+
}
|
11
|
+
|
12
|
+
mapping (address => Custodian) custodianNames;
|
5
13
|
|
6
14
|
function CustodianRegistry(address _conf) {
|
7
15
|
config = _conf;
|
8
16
|
}
|
17
|
+
|
18
|
+
function register(address _acct) ifadmin {
|
19
|
+
if (!Directory.insert(custodians, _acct))
|
20
|
+
throw;
|
21
|
+
}
|
22
|
+
|
23
|
+
function unregister(address _acct) ifadmin {
|
24
|
+
if (!Directory.remove(custodians, _acct))
|
25
|
+
throw;
|
26
|
+
}
|
27
|
+
|
28
|
+
function setCustodianName(address _cstdn, bytes32 _name) ifadmin {
|
29
|
+
custodianNames[_cstdn].name = _name;
|
30
|
+
}
|
31
|
+
|
32
|
+
function getCustodianName(address _cstdn) public returns (bytes32) {
|
33
|
+
return custodianNames[_cstdn].name;
|
34
|
+
}
|
9
35
|
|
10
36
|
function isCustodian(address _cust) public returns (bool) {
|
11
37
|
return Directory.contains(custodians, _cust);
|
@@ -1,12 +1,14 @@
|
|
1
1
|
contract DigixConfiguration {
|
2
2
|
|
3
3
|
address owner;
|
4
|
-
Directory.
|
4
|
+
Directory.AddressBoolMap admins;
|
5
5
|
|
6
|
-
mapping (bytes32 => address)
|
6
|
+
mapping (bytes32 => address) configaddr;
|
7
|
+
mapping (bytes32 => uint256) configint;
|
7
8
|
|
8
9
|
event SetOwner(address indexed owner, address indexed by);
|
9
|
-
event
|
10
|
+
event AddConfigEntryA(bytes32 indexed key, address indexed val, address indexed by);
|
11
|
+
event AddConfigEntryI(bytes32 indexed key, uint256 indexed val, address indexed by);
|
10
12
|
event RegisterAdmin(address indexed account, address indexed by);
|
11
13
|
event UnregisterAdmin(address indexed account, address indexed by);
|
12
14
|
|
@@ -27,14 +29,24 @@ contract DigixConfiguration {
|
|
27
29
|
SetOwner(_newowner, msg.sender);
|
28
30
|
}
|
29
31
|
|
30
|
-
function
|
31
|
-
address _oldaddress =
|
32
|
-
|
33
|
-
|
32
|
+
function addConfigEntryAddr(bytes32 _key, address _val) ifowner {
|
33
|
+
address _oldaddress = configaddr[_key];
|
34
|
+
configaddr[_key] = _val;
|
35
|
+
AddConfigEntryA(_key, _val, msg.sender);
|
34
36
|
}
|
35
37
|
|
36
|
-
function
|
37
|
-
return
|
38
|
+
function getConfigEntryAddr(bytes32 _key) public constant returns (address) {
|
39
|
+
return configaddr[_key];
|
40
|
+
}
|
41
|
+
|
42
|
+
function addConfigEntryInt(bytes32 _key, uint256 _val) ifowner {
|
43
|
+
uint256 _oldaddress = configint[_key];
|
44
|
+
configint[_key] = _val;
|
45
|
+
AddConfigEntryI(_key, _val, msg.sender);
|
46
|
+
}
|
47
|
+
|
48
|
+
function getConfigEntryInt(bytes32 _key) public constant returns (uint256) {
|
49
|
+
return configint[_key];
|
38
50
|
}
|
39
51
|
|
40
52
|
function registerAdmin(address _acct) ifowner {
|
data/contracts/Directory.sol
CHANGED
@@ -1,23 +1,65 @@
|
|
1
1
|
library Directory {
|
2
2
|
|
3
|
-
struct
|
3
|
+
struct AddressBytesMap { mapping(address => bytes32) bytesentries; }
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
struct AddressAddressMap { mapping(address => address) addrentries; }
|
6
|
+
|
7
|
+
struct AddressBoolMap { mapping(address => bool) boolentries; }
|
8
|
+
|
9
|
+
function insert(AddressBytesMap storage self, address key, bytes32 val) returns (bool) {
|
10
|
+
if (self.bytesentries[key] == val) return false;
|
11
|
+
self.bytesentries[key] = val;
|
12
|
+
return true;
|
13
|
+
}
|
14
|
+
|
15
|
+
function insert(AddressBoolMap storage self, address key) returns (bool) {
|
16
|
+
if (self.boolentries[key]) return false;
|
17
|
+
self.boolentries[key] = true;
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
|
21
|
+
function insert(AddressAddressMap storage self, address key, address val) returns (bool) {
|
22
|
+
if (self.addrentries[key] == val) return false;
|
23
|
+
self.addrentries[key] = val;
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
|
27
|
+
function remove(AddressBytesMap storage self, address key) returns (bool) {
|
28
|
+
if (self.bytesentries[key] == 0x0) return false;
|
29
|
+
self.bytesentries[key] = 0x0;
|
9
30
|
return true;
|
10
31
|
}
|
11
32
|
|
12
|
-
function remove(
|
13
|
-
if (!self.
|
14
|
-
|
15
|
-
self.entries[acct] = false;
|
33
|
+
function remove(AddressBoolMap storage self, address key) returns (bool) {
|
34
|
+
if (!self.boolentries[key]) return false;
|
35
|
+
self.boolentries[key] = false;
|
16
36
|
return true;
|
17
37
|
}
|
18
38
|
|
19
|
-
function
|
20
|
-
|
39
|
+
function remove(AddressAddressMap storage self, address key) returns (bool) {
|
40
|
+
if (self.addrentries[key] == 0x0000000000000000000000000000000000000000) return false;
|
41
|
+
self.addrentries[key] = 0x0000000000000000000000000000000000000000;
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
|
45
|
+
function contains(AddressBytesMap storage self, address key) returns (bool) {
|
46
|
+
if (self.bytesentries[key] != 0x0) return true;
|
47
|
+
}
|
48
|
+
|
49
|
+
function contains(AddressBoolMap storage self, address key) returns (bool) {
|
50
|
+
return self.boolentries[key];
|
51
|
+
}
|
52
|
+
|
53
|
+
function contains(AddressAddressMap storage self, address key) returns (bool) {
|
54
|
+
if (self.addrentries[key] != 0x0000000000000000000000000000000000000000) return true;
|
55
|
+
}
|
56
|
+
|
57
|
+
function containsAndMatches(AddressBytesMap storage self, address key, bytes32 val) returns (bool) {
|
58
|
+
return (self.bytesentries[key] == val);
|
59
|
+
}
|
60
|
+
|
61
|
+
function containsAndMatches(AddressAddressMap storage self, address key, address val) returns (bool) {
|
62
|
+
return (self.addrentries[key] == val);
|
21
63
|
}
|
22
64
|
|
23
65
|
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
library DoublyLinked {
|
2
|
+
|
3
|
+
struct List {
|
4
|
+
uint80 first;
|
5
|
+
uint80 last;
|
6
|
+
uint80 count;
|
7
|
+
Item[] items;
|
8
|
+
}
|
9
|
+
|
10
|
+
uint80 constant None = uint80(-1);
|
11
|
+
|
12
|
+
struct Item {
|
13
|
+
uint80 prev;
|
14
|
+
uint80 next;
|
15
|
+
bytes32 data;
|
16
|
+
}
|
17
|
+
|
18
|
+
function append(List storage self, bytes32 _data) {
|
19
|
+
var index = self.items.push(Item({prev: self.last, next: None, data: _data}));
|
20
|
+
if (self.last == None)
|
21
|
+
{
|
22
|
+
if (self.first != None || self.count != 0) throw;
|
23
|
+
self.first = self.last = uint80(index - 1);
|
24
|
+
self.count = 1;
|
25
|
+
}
|
26
|
+
else
|
27
|
+
{
|
28
|
+
self.items[self.last].next = uint80(index - 1);
|
29
|
+
self.last = uint80(index - 1);
|
30
|
+
self.count ++;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
function remove(List storage self, uint80 _index) {
|
35
|
+
Item item = self.items[_index];
|
36
|
+
if (item.prev == None)
|
37
|
+
self.first = item.next;
|
38
|
+
if (item.next == None)
|
39
|
+
self.last = item.prev;
|
40
|
+
if (item.prev != None)
|
41
|
+
self.items[item.prev].next = item.next;
|
42
|
+
if (item.next != None)
|
43
|
+
self.items[item.next].prev = item.prev;
|
44
|
+
delete self.items[_index];
|
45
|
+
self.count++;
|
46
|
+
}
|
47
|
+
|
48
|
+
// Iterator interface
|
49
|
+
function iterate_start(List storage self) returns (uint80) { return self.first; }
|
50
|
+
function iterate_valid(List storage self, uint80 _index) returns (bool) { return _index < self.items.length; }
|
51
|
+
function iterate_prev(List storage self, uint80 _index) returns (uint80) { return self.items[_index].prev; }
|
52
|
+
function iterate_next(List storage self, uint80 _index) returns (uint80) { return self.items[_index].next; }
|
53
|
+
function iterate_get(List storage self, uint80 _index) returns (bytes32) { return self.items[_index].data; }
|
54
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import "contracts/Directory.sol";
|
2
|
+
import "contracts/DoublyLinked.sol";
|
3
|
+
import "contracts/DigixConfiguration.sol";
|
4
|
+
import "contracts/VendorRegistry.sol";
|
5
|
+
import "contracts/CustodianRegistry.sol";
|
6
|
+
import "contracts/AuditorRegistry.sol";
|
7
|
+
|
8
|
+
contract GenericInterface {
|
9
|
+
|
10
|
+
address config;
|
11
|
+
address owner;
|
12
|
+
|
13
|
+
function getConfigAddress() public returns (address) {
|
14
|
+
return config;
|
15
|
+
}
|
16
|
+
|
17
|
+
function goldRegistry() public returns (address) {
|
18
|
+
return DigixConfiguration(config).getConfigEntryAddr("registry/gold");
|
19
|
+
}
|
20
|
+
|
21
|
+
function vendorRegistry() public returns (address) {
|
22
|
+
return DigixConfiguration(config).getConfigEntryAddr("registry/vendor");
|
23
|
+
}
|
24
|
+
|
25
|
+
function custodianRegistry() public returns (address) {
|
26
|
+
return DigixConfiguration(config).getConfigEntryAddr("registry/custodian");
|
27
|
+
}
|
28
|
+
|
29
|
+
function auditorRegistry() public returns (address) {
|
30
|
+
return DigixConfiguration(config).getConfigEntryAddr("registry/auditor");
|
31
|
+
}
|
32
|
+
|
33
|
+
function isGoldRegistry(address _greg) public returns (bool) {
|
34
|
+
return (goldRegistry() == _greg);
|
35
|
+
}
|
36
|
+
|
37
|
+
function isCustodian(address _cust) public returns (bool) {
|
38
|
+
return CustodianRegistry(custodianRegistry()).isCustodian(_cust);
|
39
|
+
}
|
40
|
+
|
41
|
+
function isAuditor(address _adtr) public returns (bool) {
|
42
|
+
return AuditorRegistry(auditorRegistry()).isAuditor(_adtr);
|
43
|
+
}
|
44
|
+
|
45
|
+
function isVendor(address _vndr) public returns (bool) {
|
46
|
+
return VendorRegistry(vendorRegistry()).isVendor(_vndr);
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
modifier ifvendor { if(isVendor(msg.sender)) _ }
|
51
|
+
modifier ifowner { if(msg.sender == owner) _ }
|
52
|
+
modifier ifcustodian { if(isCustodian(msg.sender)) _ }
|
53
|
+
modifier ifauditor { if(isAuditor(msg.sender)) _ }
|
54
|
+
modifier ifgoldregistry { if(isGoldRegistry(msg.sender)) _ }
|
55
|
+
|
56
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
contract GenericRegistry {
|
2
|
+
|
3
|
+
address config;
|
4
|
+
|
5
|
+
function isAdmin(address _acct) public returns (bool) {
|
6
|
+
return DigixConfiguration(config).isAdmin(_acct);
|
7
|
+
}
|
8
|
+
|
9
|
+
function getConfigAddress() public returns (address) {
|
10
|
+
return config;
|
11
|
+
}
|
12
|
+
|
13
|
+
modifier ifadmin { if(isAdmin(msg.sender)) _ }
|
14
|
+
|
15
|
+
}
|
data/contracts/Gold.sol
CHANGED
@@ -1,67 +1,105 @@
|
|
1
|
-
|
1
|
+
import "contracts/GenericInterface.sol";
|
2
|
+
import "contracts/GoldRegistry.sol";
|
2
3
|
|
3
|
-
|
4
|
-
address owner;
|
5
|
-
uint lastfeecalc;
|
6
|
-
bool locked;
|
4
|
+
contract Gold is GenericInterface {
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
uint256 weight;
|
7
|
+
uint256 serial;
|
8
|
+
uint256 lastStoragePayment;
|
9
|
+
uint256 base;
|
10
|
+
uint256 auditCount;
|
11
|
+
bool registered;
|
12
|
+
bool active;
|
13
|
+
|
14
|
+
modifier ifowner { if(owner == msg.sender) _ }
|
15
|
+
modifier ifcansend { if(canSend()) _ }
|
16
|
+
modifier ifunregistered { if(registered == false) _ }
|
17
|
+
|
18
|
+
event GoldAuditReport(bool indexed passed, address indexed document, address indexed auditor);
|
19
|
+
|
20
|
+
function Gold(address _conf, uint256 _wt) {
|
21
|
+
base = 1000000000;
|
22
|
+
owner = msg.sender;
|
23
|
+
config = _conf;
|
24
|
+
auditCount = 0;
|
25
|
+
weight = base * _wt;
|
26
|
+
registered = false;
|
27
|
+
active = false;
|
28
|
+
lastStoragePayment = block.timestamp;
|
13
29
|
}
|
14
30
|
|
15
|
-
|
16
|
-
|
17
|
-
bytes32 serialNumber;
|
18
|
-
bytes32 vendorReceipt;
|
19
|
-
bytes32 custodianReceipt;
|
31
|
+
function register(address _owner) ifgoldregistry {
|
32
|
+
owner = _owner;
|
20
33
|
}
|
21
34
|
|
22
|
-
|
23
|
-
|
24
|
-
uint lastPayment;
|
35
|
+
function activate() ifgoldregistry {
|
36
|
+
active = true;
|
25
37
|
}
|
26
38
|
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
function getCalculatedFees() public returns (uint256) {
|
40
|
+
uint256 _totalfee = 0;
|
41
|
+
uint256 _dayseconds = 60; // 86400 seconds buy for testing we set to one minute
|
42
|
+
uint256 _lp = lastStoragePayment;
|
43
|
+
uint256 _wt = weight;
|
44
|
+
uint256 _dailyRatePpb = getStorageRate();
|
45
|
+
uint256 _startRun = block.timestamp;
|
46
|
+
while ((_startRun - _lp) > _dayseconds) {
|
47
|
+
uint256 _calculatedFee = ((_wt * _dailyRatePpb) / base);
|
48
|
+
_wt -= _calculatedFee;
|
49
|
+
_totalfee += _calculatedFee;
|
50
|
+
_lp += _dayseconds;
|
51
|
+
}
|
52
|
+
return _totalfee;
|
53
|
+
}
|
30
54
|
|
31
|
-
|
55
|
+
function mint() ifowner ifcansend {
|
56
|
+
|
57
|
+
}
|
32
58
|
|
33
|
-
|
59
|
+
function transferOwner(address _recipient) ifowner ifcansend {
|
60
|
+
owner = _recipient;
|
61
|
+
}
|
34
62
|
|
35
|
-
function
|
36
|
-
owner
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
63
|
+
function getOwner() public returns (address) {
|
64
|
+
return owner;
|
65
|
+
}
|
66
|
+
|
67
|
+
function getLastStoragePayDate() public returns (uint256) {
|
68
|
+
return lastStoragePayment;
|
41
69
|
}
|
42
70
|
|
43
|
-
function
|
44
|
-
return
|
71
|
+
function getStorageRate() public returns (uint256) {
|
72
|
+
return DigixConfiguration(config).getConfigEntryInt("rates/storage");
|
45
73
|
}
|
46
74
|
|
47
|
-
function
|
48
|
-
return (
|
75
|
+
function getWeightMinusFees() public returns (uint256) {
|
76
|
+
return (weight - getCalculatedFees());
|
49
77
|
}
|
50
78
|
|
51
|
-
function
|
52
|
-
return (
|
79
|
+
function hasFees() public returns (bool) {
|
80
|
+
return (getCalculatedFees() > 0);
|
53
81
|
}
|
54
82
|
|
55
|
-
function
|
56
|
-
|
57
|
-
uint dailyRate = 10277777777;
|
58
|
-
var rate = dailyRate * _days;
|
59
|
-
var fee = (rate * info.weight);
|
60
|
-
return ((info.weight * base) - fee);
|
83
|
+
function isActive() public returns (bool) {
|
84
|
+
return active;
|
61
85
|
}
|
62
86
|
|
63
|
-
function
|
64
|
-
|
87
|
+
function isYellow() public returns (bool) {
|
88
|
+
uint256 daylength = 60;
|
89
|
+
return ((block.timestamp - lastStoragePayment) > (daylength * 30));
|
90
|
+
}
|
91
|
+
|
92
|
+
function isRed() public returns (bool) {
|
93
|
+
uint256 daylength = 60;
|
94
|
+
return ((block.timestamp - lastStoragePayment) > (daylength * 90));
|
95
|
+
}
|
96
|
+
|
97
|
+
function canSend() public returns (bool) {
|
98
|
+
return (!isRed());
|
99
|
+
}
|
100
|
+
|
101
|
+
function getWeight() public returns (uint256) {
|
102
|
+
return weight;
|
65
103
|
}
|
66
104
|
|
67
105
|
}
|
data/contracts/GoldRegistry.sol
CHANGED
@@ -1,48 +1,81 @@
|
|
1
1
|
import "contracts/DigixConfiguration.sol";
|
2
|
-
import "contracts/
|
3
|
-
import "contracts/
|
4
|
-
import "contracts/CustodianRegistry.sol";
|
5
|
-
import "contracts/AuditorRegistry.sol";
|
2
|
+
import "contracts/GenericInterface.sol";
|
3
|
+
import "contracts/Gold.sol";
|
6
4
|
|
7
|
-
contract GoldRegistry {
|
5
|
+
contract GoldRegistry is GenericInterface {
|
8
6
|
|
9
7
|
address config;
|
10
8
|
|
11
|
-
Directory.
|
9
|
+
Directory.AddressBoolMap entries;
|
10
|
+
Directory.AddressAddressMap custodianPending;
|
11
|
+
|
12
|
+
struct Asset {
|
13
|
+
address vendor;
|
14
|
+
address custodian;
|
15
|
+
bytes32 vendorDoc;
|
16
|
+
bytes32 custodianDoc;
|
17
|
+
}
|
18
|
+
|
19
|
+
mapping (address => Directory.AddressBoolMap) vendorAssets;
|
20
|
+
mapping (address => Directory.AddressBoolMap) custodianAssets;
|
21
|
+
mapping (address => Asset) registeredAssets;
|
12
22
|
|
13
23
|
function GoldRegistry(address _conf) {
|
14
24
|
config = _conf;
|
15
25
|
}
|
16
26
|
|
17
|
-
|
18
|
-
|
19
|
-
|
27
|
+
event AddGold(address indexed gold, address indexed vendor);
|
28
|
+
event CustodianAssignment(address indexed gold, address indexed custodian, address indexed vendor);
|
29
|
+
event RemoveGold(address indexed gold, address indexed custodian);
|
30
|
+
|
31
|
+
function registerGold(address _gold, address _owner, bytes32 _doc) ifvendor {
|
32
|
+
if (!Directory.insert(entries, _gold)) throw;
|
33
|
+
if (!Directory.insert(vendorAssets[msg.sender], _gold)) throw;
|
34
|
+
Asset _asset = registeredAssets[_gold];
|
35
|
+
_asset.vendor = msg.sender;
|
36
|
+
_asset.vendorDoc = _doc;
|
37
|
+
Gold(_gold).register(_owner);
|
38
|
+
}
|
39
|
+
|
40
|
+
function isRegistered(address _gold) public returns (bool) {
|
41
|
+
return Directory.contains(entries, _gold);
|
42
|
+
}
|
20
43
|
|
21
|
-
function
|
22
|
-
return
|
44
|
+
function isVendorOf(address _gold, address _vndr) public returns (bool) {
|
45
|
+
return Directory.contains(vendorAssets[_vndr], _gold);
|
23
46
|
}
|
24
47
|
|
25
|
-
function
|
26
|
-
return
|
48
|
+
function isCustodianOf(address _gold, address _cstdn) public returns (bool) {
|
49
|
+
return Directory.contains(custodianAssets[_cstdn], _gold);
|
27
50
|
}
|
28
|
-
|
29
|
-
function
|
30
|
-
|
51
|
+
|
52
|
+
function delegateCustodian(address _gold, address _cstdn) ifvendor {
|
53
|
+
if (isVendorOf(_gold, msg.sender)) {
|
54
|
+
if (!Directory.insert(custodianPending, _gold, _cstdn)) throw;
|
55
|
+
CustodianAssignment(_gold, _cstdn, msg.sender);
|
56
|
+
}
|
31
57
|
}
|
32
58
|
|
33
|
-
function
|
34
|
-
|
59
|
+
function receiveFromVendor(address _gold, bytes32 _doc) ifcustodian {
|
60
|
+
if (Directory.containsAndMatches(custodianPending, _gold, msg.sender)) {
|
61
|
+
if (!Directory.remove(custodianPending, _gold)) throw;
|
62
|
+
if (!Directory.insert(custodianAssets[msg.sender], _gold)) throw;
|
63
|
+
Asset _asset = registeredAssets[_gold];
|
64
|
+
_asset.custodian = msg.sender;
|
65
|
+
_asset.custodianDoc = _doc;
|
66
|
+
Gold(_gold).activate();
|
67
|
+
}
|
35
68
|
}
|
36
|
-
|
37
|
-
function
|
38
|
-
|
69
|
+
|
70
|
+
function submitAudit(address _gold, bytes32 _doc, bool _passed) ifauditor {
|
71
|
+
|
39
72
|
}
|
40
|
-
|
41
|
-
function
|
42
|
-
|
73
|
+
|
74
|
+
function requestRedemption(address _gold) ifowner {
|
75
|
+
|
43
76
|
}
|
44
77
|
|
45
|
-
function
|
78
|
+
function markRedeemed(address _gold) ifcustodian {
|
46
79
|
|
47
80
|
}
|
48
81
|
|
data/contracts/Interface.sol
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
import "contracts/
|
2
|
-
import "contracts/CustodianRegistry.sol";
|
3
|
-
import "contracts/AuditorRegistry.sol";
|
1
|
+
import "contracts/GenericInterface.sol";
|
4
2
|
|
5
|
-
contract Interface {
|
3
|
+
contract Interface is GenericInterface {
|
6
4
|
|
7
5
|
address owner;
|
8
|
-
address config;
|
9
6
|
|
10
|
-
Directory.
|
7
|
+
Directory.AddressBoolMap employees;
|
11
8
|
|
12
9
|
modifier ifowner { if(owner == msg.sender) _ }
|
13
10
|
modifier ifemployee { if(isEmployee(msg.sender)) _ }
|
11
|
+
modifier ifemployeeorigin { if(isEmployee(tx.origin)) _ }
|
14
12
|
|
15
13
|
function registerEmployee(address _acct) ifowner {
|
16
14
|
if (!Directory.insert(employees, _acct))
|
@@ -26,32 +24,4 @@ contract Interface {
|
|
26
24
|
return Directory.contains(employees, _acct);
|
27
25
|
}
|
28
26
|
|
29
|
-
function goldRegistry() public returns (address) {
|
30
|
-
return DigixConfiguration(config).getConfigEntry("registry/gold");
|
31
|
-
}
|
32
|
-
|
33
|
-
function vendorRegistry() public returns (address) {
|
34
|
-
return DigixConfiguration(config).getConfigEntry("registry/vendor");
|
35
|
-
}
|
36
|
-
|
37
|
-
function custodianRegistry() public returns (address) {
|
38
|
-
return DigixConfiguration(config).getConfigEntry("registry/custodian");
|
39
|
-
}
|
40
|
-
|
41
|
-
function auditorRegistry() public returns (address) {
|
42
|
-
return DigixConfiguration(config).getConfigEntry("registry/auditor");
|
43
|
-
}
|
44
|
-
|
45
|
-
function isCustodian(address _cust) public returns (bool) {
|
46
|
-
return CustodianRegistry(custodianRegistry()).isCustodian(_cust);
|
47
|
-
}
|
48
|
-
|
49
|
-
function isAuditor(address _adtr) public returns (bool) {
|
50
|
-
return AuditorRegistry(auditorRegistry()).isAuditor(_adtr);
|
51
|
-
}
|
52
|
-
|
53
|
-
function isVendor(address _vndr) public returns (bool) {
|
54
|
-
return VendorRegistry(vendorRegistry()).isVendor(_vndr);
|
55
|
-
}
|
56
|
-
|
57
27
|
}
|
@@ -1,23 +1,80 @@
|
|
1
1
|
import "contracts/Interface.sol";
|
2
2
|
import "contracts/Gold.sol";
|
3
|
+
import "contracts/GoldRegistry.sol";
|
4
|
+
import "contracts/DoublyLinked.sol";
|
3
5
|
|
4
6
|
contract VendorInterface is Interface {
|
5
7
|
|
8
|
+
DoublyLinked.List openOrders;
|
9
|
+
|
10
|
+
enum OrderStatus { Open, Cancelled, Completed }
|
11
|
+
|
12
|
+
struct Order {
|
13
|
+
bytes32 sku;
|
14
|
+
address buyer;
|
15
|
+
uint status;
|
16
|
+
}
|
17
|
+
|
18
|
+
mapping (bytes32 => Order) orders;
|
19
|
+
|
6
20
|
function VendorInterface(address _config) {
|
7
21
|
owner = msg.sender;
|
8
22
|
config = _config;
|
9
23
|
}
|
10
24
|
|
11
|
-
function registerGold(address _asset) ifemployee {
|
12
|
-
|
25
|
+
function registerGold(address _asset, address _owner, bytes32 _doc) ifemployee {
|
26
|
+
GoldRegistry(goldRegistry()).registerGold(_asset, _owner, _doc);
|
27
|
+
}
|
28
|
+
|
29
|
+
function delegateCustodian(address _asset, address _cstdn) ifemployee {
|
30
|
+
GoldRegistry(goldRegistry()).delegateCustodian(_asset, _cstdn);
|
31
|
+
}
|
32
|
+
|
33
|
+
function append(bytes32 _data) {
|
34
|
+
DoublyLinked.append(openOrders, _data);
|
35
|
+
}
|
36
|
+
|
37
|
+
function createOrder(bytes32 _orderId, bytes32 _sku, address _buyer) {
|
38
|
+
Order _order = orders[_orderId];
|
39
|
+
_order.sku = _sku;
|
40
|
+
_order.buyer = _buyer;
|
41
|
+
_order.status = uint(OrderStatus.Open);
|
42
|
+
DoublyLinked.append(openOrders, _orderId);
|
43
|
+
}
|
44
|
+
|
45
|
+
function start() returns (uint80) {
|
46
|
+
return DoublyLinked.iterate_start(openOrders);
|
13
47
|
}
|
14
48
|
|
15
|
-
function
|
49
|
+
function getOrder(uint80 _idx) returns (bytes32 _orderId, bytes32 _sku, address _buyer) {
|
50
|
+
_orderId = DoublyLinked.iterate_get(openOrders, _idx);
|
51
|
+
_sku = orders[_orderId].sku;
|
52
|
+
_buyer = orders[_orderId].buyer;
|
53
|
+
}
|
16
54
|
|
55
|
+
function next(uint80 _idx) returns(uint80) {
|
56
|
+
return DoublyLinked.iterate_next(openOrders, _idx);
|
57
|
+
}
|
58
|
+
|
59
|
+
function valid(uint80 _idx) returns(bool) {
|
60
|
+
return DoublyLinked.iterate_valid(openOrders, _idx);
|
17
61
|
}
|
18
62
|
|
19
|
-
function
|
63
|
+
function prev(uint80 _idx) returns(uint80) {
|
64
|
+
return DoublyLinked.iterate_prev(openOrders, _idx);
|
65
|
+
}
|
20
66
|
|
67
|
+
function processOrder(bytes32 _orderId) returns (bool success) {
|
68
|
+
var it = DoublyLinked.iterate_start(openOrders);
|
69
|
+
while (DoublyLinked.iterate_valid(openOrders, it)) {
|
70
|
+
if (DoublyLinked.iterate_get(openOrders, it) == _orderId) {
|
71
|
+
DoublyLinked.remove(openOrders, it);
|
72
|
+
orders[_orderId].status = uint(OrderStatus.Completed);
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
it = DoublyLinked.iterate_next(openOrders, it);
|
76
|
+
}
|
77
|
+
return false;
|
21
78
|
}
|
22
79
|
|
23
80
|
}
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import "contracts/
|
2
|
-
import "contracts/Directory.sol";
|
1
|
+
import "contracts/GenericRegistry.sol";
|
3
2
|
|
4
|
-
contract VendorRegistry {
|
3
|
+
contract VendorRegistry is GenericRegistry {
|
5
4
|
|
6
|
-
|
7
|
-
Directory.Data vendors;
|
5
|
+
Directory.AddressBoolMap vendors;
|
8
6
|
|
9
7
|
struct Vendor {
|
10
8
|
bytes32 name;
|
@@ -12,20 +10,10 @@ contract VendorRegistry {
|
|
12
10
|
|
13
11
|
mapping (address => Vendor) vendorNames;
|
14
12
|
|
15
|
-
modifier ifadmin { if(isAdmin(msg.sender)) _ }
|
16
|
-
|
17
13
|
function VendorRegistry(address _conf) {
|
18
14
|
config = _conf;
|
19
15
|
}
|
20
16
|
|
21
|
-
function isAdmin(address _acct) public returns (bool) {
|
22
|
-
return DigixConfiguration(config).isAdmin(_acct);
|
23
|
-
}
|
24
|
-
|
25
|
-
function getConfigAddress() public returns (address) {
|
26
|
-
return config;
|
27
|
-
}
|
28
|
-
|
29
17
|
function register(address _acct) ifadmin {
|
30
18
|
if (!Directory.insert(vendors, _acct))
|
31
19
|
throw;
|
@@ -9,10 +9,10 @@ module Ethereum
|
|
9
9
|
@binary = contract["bin"] unless contract.nil?
|
10
10
|
@name = contract_name
|
11
11
|
@project_initializer = project_initializer
|
12
|
-
matchdata = /_+[a-zA-Z]+_
|
12
|
+
matchdata = @binary.scan(/_+[a-zA-Z]+_+/).uniq
|
13
13
|
@needs_linking = matchdata.present?
|
14
14
|
if @needs_linking
|
15
|
-
@libraries = matchdata.
|
15
|
+
@libraries = matchdata.collect do |libname|
|
16
16
|
{name: libname.gsub(/_+/,''), sigil: libname}
|
17
17
|
end
|
18
18
|
end
|
data/lib/ethereum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethereum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DigixGlobal Pte Ltd (https://dgx.io)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,9 @@ files:
|
|
121
121
|
- contracts/CustodianRegistry.sol
|
122
122
|
- contracts/DigixConfiguration.sol
|
123
123
|
- contracts/Directory.sol
|
124
|
+
- contracts/DoublyLinked.sol
|
125
|
+
- contracts/GenericInterface.sol
|
126
|
+
- contracts/GenericRegistry.sol
|
124
127
|
- contracts/Gold.sol
|
125
128
|
- contracts/GoldRegistry.sol
|
126
129
|
- contracts/GoldTokenLedger.sol
|