ethereum 0.4.45 → 0.4.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,94 @@
1
+ contract ParticipantRegistry {
2
+
3
+ enum ParticipantTypes { Admin, Vendor, Custodian, Auditor }
4
+ struct ParticipantDatabase {
5
+ mapping (address => bool) auditors;
6
+ mapping (address => bool) vendors;
7
+ mapping (address => bool) custodians;
8
+ mapping (address => bool) registrars;
9
+ }
10
+
11
+ address owner;
12
+ ParticipantDatabase participantdb;
13
+
14
+ event AddParticipant(address indexed participant, uint indexed participanttype);
15
+ event RemoveParticipant(address indexed participant, uint indexed participanttype);
16
+
17
+ modifier ifowner { if (msg.sender == owner) _ }
18
+ modifier ifregistrar { if ((participantdb.registrars[tx.origin]) || (tx.origin == owner)) _ }
19
+ modifier onlyvendor { if (isVendor(tx.origin) == true) _ }
20
+ modifier onlycustodian { if (isCustodian(tx.origin) == true) _ }
21
+ modifier onlyauditor { if (isAuditor(tx.origin) == true) _ }
22
+
23
+ function ParticipantRegistry() {
24
+ owner = msg.sender;
25
+ }
26
+
27
+ function getOwner() returns (address oa) {
28
+ oa = owner;
29
+ }
30
+
31
+ function setOwner(address nown) ifowner {
32
+ owner = nown;
33
+ }
34
+
35
+ function registerAdmin(address regraddr) ifowner {
36
+ participantdb.registrars[regraddr] = true;
37
+ AddParticipant(regraddr, uint(ParticipantTypes.Admin));
38
+ }
39
+
40
+ function unregisterAdmin(address regraddr) ifowner {
41
+ participantdb.registrars[regraddr] = false;
42
+ RemoveParticipant(regraddr, uint(ParticipantTypes.Admin));
43
+ }
44
+
45
+ function registerVendor(address vendoraddress) ifregistrar {
46
+ participantdb.vendors[vendoraddress] = true;
47
+ AddParticipant(vendoraddress, uint(ParticipantTypes.Vendor));
48
+ }
49
+
50
+ function unregisterVendor(address vendoraddress) ifregistrar {
51
+ participantdb.vendors[vendoraddress] = false;
52
+ RemoveParticipant(vendoraddress, uint(ParticipantTypes.Vendor));
53
+ }
54
+
55
+ function registerCustodian(address custodianaddress) ifregistrar {
56
+ participantdb.custodians[custodianaddress] = true;
57
+ AddParticipant(custodianaddress, uint(ParticipantTypes.Custodian));
58
+ }
59
+
60
+ function unregisterCustodian(address custodianaddress) ifregistrar {
61
+ participantdb.custodians[custodianaddress] = false;
62
+ RemoveParticipant(custodianaddress, uint(ParticipantTypes.Custodian));
63
+ }
64
+
65
+ function registerAuditor(address auditoraddress) ifregistrar {
66
+ participantdb.auditors[auditoraddress] = true;
67
+ AddParticipant(auditoraddress, uint(ParticipantTypes.Auditor));
68
+ }
69
+
70
+ function unregisterAuditor(address auditoraddress) ifregistrar {
71
+ participantdb.auditors[auditoraddress] = false;
72
+ RemoveParticipant(auditoraddress, uint(ParticipantTypes.Auditor));
73
+ }
74
+
75
+ function isVendor(address vendoraddress) returns (bool) {
76
+ return participantdb.vendors[vendoraddress];
77
+ }
78
+
79
+ function isCustodian(address custodianaddress) returns (bool) {
80
+ return participantdb.custodians[custodianaddress];
81
+ }
82
+
83
+ function isAuditor(address auditoraddress) returns (bool) {
84
+ return participantdb.auditors[auditoraddress];
85
+ }
86
+
87
+ function isRegistrar(address regraddr) returns (bool) {
88
+ return participantdb.registrars[regraddr];
89
+ }
90
+ }
91
+
92
+
93
+
94
+ //#include [ParticipantRegistry]
@@ -0,0 +1,54 @@
1
+ ////////////////////////////////////////////////////////////
2
+ // This is an example contract hacked together at a meetup.
3
+ // It is by far not complete and only used to show some
4
+ // features of Solidity.
5
+ ////////////////////////////////////////////////////////////
6
+ contract QueueContract
7
+ {
8
+ struct Queue {
9
+ uint[] data;
10
+ uint front;
11
+ uint back;
12
+ }
13
+ /// @dev the number of elements stored in the queue.
14
+ function length(Queue storage q) constant internal returns (uint) {
15
+ return q.back - q.front;
16
+ }
17
+ /// @dev the number of elements this queue can hold
18
+ function capacity(Queue storage q) constant internal returns (uint) {
19
+ return q.data.length - 1;
20
+ }
21
+ /// @dev push a new element to the back of the queue
22
+ function push(Queue storage q, uint data) internal
23
+ {
24
+ if ((q.back + 1) % q.data.length == q.front)
25
+ return; // throw;
26
+ q.data[q.back] = data;
27
+ q.back = (q.back + 1) % q.data.length;
28
+ }
29
+ /// @dev remove and return the element at the front of the queue
30
+ function pop(Queue storage q) internal returns (uint r)
31
+ {
32
+ if (q.back == q.front)
33
+ return; // throw;
34
+ r = q.data[q.front];
35
+ delete q.data[q.front];
36
+ q.front = (q.front + 1) % q.data.length;
37
+ }
38
+ }
39
+
40
+ contract QueueUserMayBeDeliveryDroneCotnrol is QueueContract {
41
+ Queue requests;
42
+ function QueueUserMayBeDeliveryDroneCotnrol() {
43
+ requests.data.length = 200;
44
+ }
45
+ function addRequest(uint d) {
46
+ push(requests, d);
47
+ }
48
+ function popRequest() returns (uint) {
49
+ return pop(requests);
50
+ }
51
+ function queueLength() returns (uint) {
52
+ return length(requests);
53
+ }
54
+ }
@@ -2,12 +2,13 @@ module Ethereum
2
2
 
3
3
  class ContractInitializer
4
4
 
5
- attr_accessor :abi, :binary, :name, :libraries, :needs_linking
5
+ attr_accessor :abi, :binary, :name, :libraries, :needs_linking, :project_initializer
6
6
 
7
- def initialize(contract_name, contract)
7
+ def initialize(contract_name, contract, project_initializer)
8
8
  @abi = JSON.parse(contract["abi"]) unless contract.nil?
9
9
  @binary = contract["bin"] unless contract.nil?
10
10
  @name = contract_name
11
+ @project_initializer = project_initializer
11
12
  matchdata = /_+[a-zA-Z]+_+/.match(@binary)
12
13
  @needs_linking = matchdata.present?
13
14
  if @needs_linking
@@ -20,11 +21,20 @@ module Ethereum
20
21
  def link_libraries
21
22
  if @needs_linking
22
23
  @libraries.each do |library|
23
- ENV['ETHEREUM_DEPLOYER_WAIT_TIME'] ||= "120"
24
- wait_time = ENV['ETHEREUM_DEPLOYER_WAIT_TIME'].to_i
25
- library_instance = library[:name].constantize.new
26
- library_instance.deploy_and_wait(wait_time)
27
- @binary.gsub!(library[:sigil], library_instance.address.gsub(/^0x/,''))
24
+ name = library[:name]
25
+ if @project_initializer.libraries[name].nil?
26
+ ENV['ETHEREUM_DEPLOYER_WAIT_TIME'] ||= "120"
27
+ wait_time = ENV['ETHEREUM_DEPLOYER_WAIT_TIME'].to_i
28
+ library_instance = library[:name].constantize.new
29
+ puts "Deploying library #{name}"
30
+ library_instance.deploy_and_wait(wait_time)
31
+ puts "Library deployed at #{library_instance.address}"
32
+ @project_initializer.libraries[name] = library_instance.address
33
+ @binary.gsub!(library[:sigil], library_instance.address.gsub(/^0x/,''))
34
+ else
35
+ address = @project_initializer.libraries[name]
36
+ @binary.gsub!(library[:sigil], address.gsub(/^0x/,''))
37
+ end
28
38
  end
29
39
  end
30
40
  end
@@ -2,7 +2,7 @@ module Ethereum
2
2
 
3
3
  class ProjectInitializer
4
4
 
5
- attr_accessor :contract_names, :combined_output, :contracts
5
+ attr_accessor :contract_names, :combined_output, :contracts, :libraries
6
6
 
7
7
  def initialize(location)
8
8
  ENV['ETHEREUM_SOLIDITY_BINARY'] ||= "/usr/local/bin/solc"
@@ -12,8 +12,9 @@ module Ethereum
12
12
  raw_data = `#{compile_command}`
13
13
  data = JSON.parse(raw_data)
14
14
  @contract_names = data["contracts"].keys
15
+ @libraries = {}
15
16
  @contracts = @contract_names.collect do |contract_name|
16
- ContractInitializer.new(contract_name, data["contracts"][contract_name])
17
+ ContractInitializer.new(contract_name, data["contracts"][contract_name], self)
17
18
  end
18
19
  end
19
20
 
@@ -1,3 +1,3 @@
1
1
  module Ethereum
2
- VERSION = "0.4.45"
2
+ VERSION = "0.4.50"
3
3
  end
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.45
4
+ version: 0.4.50
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-23 00:00:00.000000000 Z
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,7 +115,31 @@ files:
115
115
  - bin/console
116
116
  - bin/setup
117
117
  - contracts/AccountingLib.sol
118
+ - contracts/AuditorInterface.sol
119
+ - contracts/AuditorRegistry.sol
120
+ - contracts/CustodianInterface.sol
121
+ - contracts/CustodianRegistry.sol
122
+ - contracts/DigixConfiguration.sol
123
+ - contracts/Directory.sol
124
+ - contracts/Gold.sol
125
+ - contracts/GoldRegistry.sol
126
+ - contracts/GoldTokenLedger.sol
127
+ - contracts/Interface.sol
128
+ - contracts/Minter.sol
129
+ - contracts/Recaster.sol
118
130
  - contracts/Testing.sol
131
+ - contracts/VendorInterface.sol
132
+ - contracts/VendorRegistry.sol
133
+ - contracts/classic/Digixbot.sol
134
+ - contracts/classic/DigixbotConfiguration.sol
135
+ - contracts/classic/DigixbotEthereum.sol
136
+ - contracts/classic/DigixbotUsers.sol
137
+ - contracts/classic/Gold.sol
138
+ - contracts/classic/GoldRegistry.sol
139
+ - contracts/classic/GoldTokenLedger.sol
140
+ - contracts/classic/GoldTokenMinter.sol
141
+ - contracts/classic/ParticipantRegistry.sol
142
+ - contracts/classic/QueueSample.sol
119
143
  - ethereum.gemspec
120
144
  - lib/ethereum.rb
121
145
  - lib/ethereum/client.rb