evm_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/.ruby-gemset +1 -0
  6. data/.travis.yml +32 -0
  7. data/CODE_OF_CONDUCT.md +13 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE +22 -0
  10. data/LICENSE.txt +21 -0
  11. data/PREREQUISITES.md +75 -0
  12. data/README.md +665 -0
  13. data/Rakefile +11 -0
  14. data/bin/console +14 -0
  15. data/bin/install_parity +22 -0
  16. data/bin/setup +7 -0
  17. data/contracts/AccountingLib.sol +112 -0
  18. data/contracts/AuditorInterface.sol +4 -0
  19. data/contracts/AuditorRegistry.sol +14 -0
  20. data/contracts/CustodianInterface.sol +27 -0
  21. data/contracts/CustodianRegistry.sol +40 -0
  22. data/contracts/DigixConfiguration.sol +68 -0
  23. data/contracts/Directory.sol +67 -0
  24. data/contracts/DoublyLinked.sol +54 -0
  25. data/contracts/GenericInterface.sol +56 -0
  26. data/contracts/GenericRegistry.sol +15 -0
  27. data/contracts/Gold.sol +105 -0
  28. data/contracts/GoldRegistry.sol +82 -0
  29. data/contracts/GoldTokenLedger.sol +3 -0
  30. data/contracts/Interface.sol +27 -0
  31. data/contracts/Minter.sol +3 -0
  32. data/contracts/Recaster.sol +3 -0
  33. data/contracts/Testing.sol +59 -0
  34. data/contracts/VendorInterface.sol +82 -0
  35. data/contracts/VendorRegistry.sol +39 -0
  36. data/contracts/classic/Digixbot.sol +106 -0
  37. data/contracts/classic/DigixbotConfiguration.sol +62 -0
  38. data/contracts/classic/DigixbotEthereum.sol +86 -0
  39. data/contracts/classic/DigixbotUsers.sol +103 -0
  40. data/contracts/classic/Gold.sol +497 -0
  41. data/contracts/classic/GoldRegistry.sol +503 -0
  42. data/contracts/classic/GoldTokenLedger.sol +560 -0
  43. data/contracts/classic/GoldTokenMinter.sol +607 -0
  44. data/contracts/classic/ParticipantRegistry.sol +94 -0
  45. data/contracts/classic/QueueSample.sol +54 -0
  46. data/evm_client.gemspec +36 -0
  47. data/lib/evm_client.rb +15 -0
  48. data/lib/evm_client/abi.rb +32 -0
  49. data/lib/evm_client/client.rb +146 -0
  50. data/lib/evm_client/contract.rb +341 -0
  51. data/lib/evm_client/contract_event.rb +32 -0
  52. data/lib/evm_client/contract_initializer.rb +54 -0
  53. data/lib/evm_client/decoder.rb +99 -0
  54. data/lib/evm_client/deployment.rb +49 -0
  55. data/lib/evm_client/encoder.rb +118 -0
  56. data/lib/evm_client/event_log.rb +88 -0
  57. data/lib/evm_client/explorer_url_helper.rb +25 -0
  58. data/lib/evm_client/formatter.rb +146 -0
  59. data/lib/evm_client/function.rb +40 -0
  60. data/lib/evm_client/function_input.rb +14 -0
  61. data/lib/evm_client/function_output.rb +14 -0
  62. data/lib/evm_client/http_client.rb +44 -0
  63. data/lib/evm_client/initializer.rb +27 -0
  64. data/lib/evm_client/ipc_client.rb +57 -0
  65. data/lib/evm_client/project_initializer.rb +28 -0
  66. data/lib/evm_client/railtie.rb +12 -0
  67. data/lib/evm_client/singleton.rb +39 -0
  68. data/lib/evm_client/solidity.rb +40 -0
  69. data/lib/evm_client/transaction.rb +41 -0
  70. data/lib/evm_client/version.rb +3 -0
  71. data/lib/tasks/ethereum_contract.rake +27 -0
  72. data/lib/tasks/ethereum_node.rake +52 -0
  73. data/lib/tasks/ethereum_test.rake +32 -0
  74. data/lib/tasks/ethereum_transaction.rake +24 -0
  75. metadata +219 -0
@@ -0,0 +1,503 @@
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
+ contract Gold {
93
+
94
+ struct GoldData {
95
+ bool initialized;
96
+ bool minted;
97
+ uint weight;
98
+ bytes32 serial;
99
+ bytes32 sku;
100
+ bytes32 documentation;
101
+ }
102
+
103
+ struct RegistryData {
104
+ bool initialized;
105
+ bool registered;
106
+ address registry;
107
+ address vendor;
108
+ address custodian;
109
+ address minter;
110
+ }
111
+
112
+ address owner;
113
+ GoldData golddata;
114
+ RegistryData registrydata;
115
+
116
+ event SendGoldEvent(address indexed gold, address indexed recipient);
117
+
118
+ modifier ifowner { if (msg.sender == owner) _ }
119
+
120
+ function Gold() {
121
+ owner = msg.sender;
122
+ golddata.minted = false;
123
+ golddata.initialized = false;
124
+ registrydata.initialized = false;
125
+ }
126
+
127
+ function getOwner() returns (address oaddr) {
128
+ oaddr = owner;
129
+ }
130
+
131
+ function initGoldData(uint wt, bytes32 sn, bytes32 sk, bytes32 doc) ifowner {
132
+ if (golddata.initialized == true) return;
133
+ golddata = GoldData({initialized: true, minted: false, weight: wt, serial: sn, sku: sk, documentation: doc});
134
+ }
135
+
136
+ function initRegistryData(address raddr, address vaddr, address caddr) ifowner {
137
+ if (registrydata.initialized == true) return;
138
+ registrydata = RegistryData({initialized: true, registered: false, registry: raddr, vendor: vaddr, custodian: caddr, minter: address(this)});
139
+ GoldRegistry goldregistry = GoldRegistry(raddr);
140
+ }
141
+
142
+ function sendRegistration() {
143
+ if ((registrydata.initialized == true) && (golddata.initialized == true)) {
144
+ GoldRegistry gr = goldRegistry();
145
+ gr.registerGold();
146
+ registrydata.registered = true;
147
+ }
148
+ }
149
+
150
+ function registryRequestCustodian() public returns (address caddr) {
151
+ caddr = registrydata.custodian;
152
+ }
153
+
154
+ function registryRequestVendor() public returns (address vaddr) {
155
+ vaddr = registrydata.vendor;
156
+ }
157
+
158
+ function registryRequestWeight() public returns (uint wt) {
159
+ wt = golddata.weight;
160
+ }
161
+
162
+ function registryRequestSerialNumber() public returns (bytes32 sn) {
163
+ sn = golddata.serial;
164
+ }
165
+
166
+ function registryRequestSku() public returns (bytes32 sk) {
167
+ sk = golddata.sku;
168
+ }
169
+
170
+ function registryRequestDocumentation() public returns (bytes32 doc) {
171
+ doc = golddata.documentation;
172
+ }
173
+
174
+ function getGoldDataInitialized() returns (bool gdis) {
175
+ gdis = golddata.initialized;
176
+ }
177
+
178
+ function getGoldDataMinted() returns (bool gdms) {
179
+ gdms = golddata.minted;
180
+ }
181
+
182
+ function getGoldDataWeight() returns (uint gdwt) {
183
+ gdwt = golddata.weight;
184
+ }
185
+
186
+ function getGoldDataSerial() returns (bytes32 gdsn) {
187
+ gdsn = golddata.serial;
188
+ }
189
+
190
+ function getGoldDataSku() returns (bytes32 gdsk) {
191
+ gdsk = golddata.sku;
192
+ }
193
+
194
+ function getGoldDataDocumentation() returns (bytes32 gddc) {
195
+ gddc = golddata.documentation;
196
+ }
197
+
198
+ function getRegistryDataInitialized() returns (bool rdis) {
199
+ rdis = registrydata.initialized;
200
+ }
201
+
202
+ function getRegistryDataRegistered() returns (bool rdrs) {
203
+ rdrs = registrydata.registered;
204
+ }
205
+
206
+ function getRegistryDataRegistry() returns (address rdrg) {
207
+ rdrg = registrydata.registry;
208
+ }
209
+
210
+ function getRegistryDataVendor() returns (address rdva) {
211
+ rdva = registrydata.vendor;
212
+ }
213
+
214
+ function getRegistryDataCustodian() returns (address rdca) {
215
+ rdca = registrydata.custodian;
216
+ }
217
+
218
+ function getRegistryDataMinter() returns (address rdma) {
219
+ rdma = registrydata.minter;
220
+ }
221
+
222
+ function sendToMinter(uint minttype) ifowner {
223
+ owner = registrydata.minter;
224
+ golddata.minted = true;
225
+ // Notifiy minter contract
226
+ }
227
+
228
+ function goldRegistry() returns (GoldRegistry gr) {
229
+ gr = GoldRegistry(registrydata.registry);
230
+ }
231
+
232
+
233
+ }
234
+
235
+
236
+ contract GoldRegistry {
237
+
238
+ address owner;
239
+ address participantregistry;
240
+
241
+ enum GoldStatusCodes { PendingVerification, Active, RedemptionQueue, Redeemed, Minted }
242
+
243
+ struct Audit {
244
+ uint id;
245
+ uint time;
246
+ bool pass;
247
+ address auditor;
248
+ bytes32 extradata;
249
+ bytes32 documentation;
250
+ }
251
+
252
+ struct GoldStatus {
253
+ uint code;
254
+ bool vendorverify;
255
+ bool custodianverify;
256
+ bool minted;
257
+ uint auditcount;
258
+ bool registered;
259
+ uint lastauditid;
260
+ Audit lastaudit;
261
+ mapping (uint => Audit) audits;
262
+ }
263
+
264
+ struct GoldInfo {
265
+ address vendor;
266
+ address custodian;
267
+ uint weight;
268
+ bytes32 serial;
269
+ bytes32 sku;
270
+ bytes32 documentation;
271
+ }
272
+
273
+ struct GoldData {
274
+ bool initialized;
275
+ bool minted;
276
+ uint weight;
277
+ bytes32 serial;
278
+ bytes32 sku;
279
+ bytes32 documentation;
280
+ }
281
+
282
+ struct RegistryData {
283
+ bool initialized;
284
+ bool registered;
285
+ address registry;
286
+ address vendor;
287
+ address custodian;
288
+ address minter;
289
+ }
290
+
291
+ mapping (address => GoldStatus) goldstatusdb;
292
+ mapping (address => GoldInfo) goldinfodb;
293
+
294
+ modifier ifowner { if (msg.sender == owner) _ }
295
+
296
+ event GoldPurchase(address indexed gold, address indexed buyer, uint weight);
297
+ event GoldRedemption(address indexed gold);
298
+ event VendorVerification(address indexed gold, address indexed vendor, uint indexed time);
299
+ event CustodianVerification(address indexed gold, address indexed custodian, uint indexed time);
300
+ event CustodianTransfer(address indexed gold, address indexed oldcustodian, address indexed newcustodian);
301
+ event AuditEvent(address indexed gold, address indexed auditor, uint indexed lastauditid);
302
+
303
+ function GoldRegistry() {
304
+ owner = msg.sender;
305
+ }
306
+
307
+ function setConfiguration(address pr) ifowner {
308
+ participantregistry = pr;
309
+ }
310
+
311
+ function getOwner() returns (address o) {
312
+ o = owner;
313
+ }
314
+
315
+ function setOwner(address nown) ifowner {
316
+ owner = nown;
317
+ }
318
+
319
+ function getParticipantRegistry() returns (address pr) {
320
+ pr = participantregistry;
321
+ }
322
+
323
+ function checkCustodian() returns (bool ccheck) {
324
+ ParticipantRegistry prg = ParticipantRegistry(participantregistry);
325
+ ccheck = prg.isCustodian(tx.origin);
326
+ }
327
+
328
+ function checkVendor() returns (bool vcheck) {
329
+ ParticipantRegistry prg = ParticipantRegistry(participantregistry);
330
+ vcheck = prg.isVendor(tx.origin);
331
+ }
332
+
333
+ function checkAuditor() returns (bool acheck) {
334
+ ParticipantRegistry prg = ParticipantRegistry(participantregistry);
335
+ acheck = prg.isAuditor(tx.origin);
336
+ }
337
+
338
+ function checkRegistrar() returns (bool rcheck) {
339
+ ParticipantRegistry prg = ParticipantRegistry(participantregistry);
340
+ rcheck = prg.isRegistrar(tx.origin);
341
+ }
342
+
343
+ modifier ifregistrar { if (checkRegistrar() == true) _ }
344
+ modifier ifvendor { if (checkVendor() == true) _ }
345
+ modifier ifcustodian { if (checkCustodian() == true) _ }
346
+ modifier ifauditor { if (checkAuditor() == true) _ }
347
+
348
+ function registerGold() ifregistrar {
349
+ GoldInfo gidb = goldinfodb[msg.sender];
350
+ GoldStatus gsdb = goldstatusdb[msg.sender];
351
+ Gold gld = Gold(msg.sender);
352
+ if (gsdb.registered == true) return;
353
+ gidb.vendor = gld.registryRequestVendor();
354
+ gidb.custodian = gld.registryRequestCustodian();
355
+ gidb.weight = gld.registryRequestWeight();
356
+ gidb.serial = gld.registryRequestSerialNumber();
357
+ gidb.sku = gld.registryRequestSku();
358
+ gidb.documentation = gld.registryRequestDocumentation();
359
+ gsdb.vendorverify = false;
360
+ gsdb.custodianverify = false;
361
+ gsdb.minted = false;
362
+ gsdb.registered = true;
363
+ }
364
+
365
+ function getGoldStatusCode(address gaddr) returns (uint gsc) {
366
+ GoldStatus gsdb = goldstatusdb[gaddr];
367
+ gsc = gsdb.code;
368
+ }
369
+
370
+ function getGoldStatusVendorverify(address gaddr) returns (bool gsvv) {
371
+ GoldStatus gsdb = goldstatusdb[gaddr];
372
+ gsvv = gsdb.vendorverify;
373
+ }
374
+
375
+ function getGoldStatusCustodianverify(address gaddr) returns (bool gscv) {
376
+ GoldStatus gsdb = goldstatusdb[gaddr];
377
+ gscv = gsdb.custodianverify;
378
+ }
379
+
380
+ function getGoldStatusMinted(address gaddr) returns (bool gsms) {
381
+ GoldStatus gsdb = goldstatusdb[gaddr];
382
+ gsms = gsdb.minted;
383
+ }
384
+
385
+ function getGoldStatusAuditcount(address gaddr) returns (uint gsac) {
386
+ GoldStatus gsdb = goldstatusdb[gaddr];
387
+ gsac = gsdb.auditcount;
388
+ }
389
+
390
+ function getGoldStatusRegistered(address gaddr) returns (bool gsrs) {
391
+ GoldStatus gsdb = goldstatusdb[gaddr];
392
+ gsrs = gsdb.registered;
393
+ }
394
+
395
+ function getGoldStatusLastauditid(address gaddr) returns (uint gsla) {
396
+ GoldStatus gsdb = goldstatusdb[gaddr];
397
+ gsla = gsdb.lastauditid;
398
+ }
399
+
400
+ function getGoldInfoVendor(address gaddr) returns (address giva) {
401
+ GoldInfo gidb = goldinfodb[gaddr];
402
+ giva = gidb.vendor;
403
+ }
404
+
405
+ function getGoldInfoCustodian(address gaddr) returns (address gica) {
406
+ GoldInfo gidb = goldinfodb[gaddr];
407
+ gica = gidb.custodian;
408
+ }
409
+
410
+ function getGoldInfoWeight(address gaddr) returns (uint giwt) {
411
+ GoldInfo gidb = goldinfodb[gaddr];
412
+ giwt = gidb.weight;
413
+ }
414
+
415
+ function getGoldInfoSerial(address gaddr) returns (bytes32 gisn) {
416
+ GoldInfo gidb = goldinfodb[gaddr];
417
+ gisn = gidb.serial;
418
+ }
419
+
420
+ function getGoldInfoSku(address gaddr) returns (bytes32 gisk) {
421
+ GoldInfo gidb = goldinfodb[gaddr];
422
+ gisk = gidb.sku;
423
+ }
424
+
425
+ function getGoldInfoDocumentation(address gaddr) returns (bytes32 gidc) {
426
+ GoldInfo gidb = goldinfodb[gaddr];
427
+ gidc = gidb.documentation;
428
+ }
429
+
430
+ function getLastAuditId(address gaddr) returns (uint ai) {
431
+ GoldStatus gsdb = goldstatusdb[gaddr];
432
+ Audit laud = gsdb.lastaudit;
433
+ ai = laud.id;
434
+ }
435
+
436
+ function getLastAuditTime(address gaddr) returns (uint at) {
437
+ GoldStatus gsdb = goldstatusdb[gaddr];
438
+ Audit laud = gsdb.lastaudit;
439
+ at = laud.time;
440
+ }
441
+
442
+ function getLastAuditPass(address gaddr) returns (bool ap) {
443
+ GoldStatus gsdb = goldstatusdb[gaddr];
444
+ Audit laud = gsdb.lastaudit;
445
+ ap = laud.pass;
446
+ }
447
+
448
+ function getLastAuditAuditor(address gaddr) returns (address aa) {
449
+ GoldStatus gsdb = goldstatusdb[gaddr];
450
+ Audit laud = gsdb.lastaudit;
451
+ aa = laud.auditor;
452
+ }
453
+
454
+ function getLastAuditExtradata(address gaddr) returns (bytes32 ae) {
455
+ GoldStatus gsdb = goldstatusdb[gaddr];
456
+ Audit laud = gsdb.lastaudit;
457
+ ae = laud.extradata;
458
+ }
459
+
460
+ function getLastAuditDocumentation(address gaddr) returns (bytes32 ad) {
461
+ GoldStatus gsdb = goldstatusdb[gaddr];
462
+ Audit laud = gsdb.lastaudit;
463
+ ad = laud.documentation;
464
+ }
465
+
466
+ function custodianVerify(address gaddr) ifcustodian {
467
+ GoldStatus gsdb = goldstatusdb[gaddr];
468
+ gsdb.custodianverify = true;
469
+ CustodianVerification(gaddr, tx.origin, block.timestamp);
470
+ }
471
+
472
+ function vendorVerify(address gaddr) ifvendor {
473
+ GoldStatus gsdb = goldstatusdb[gaddr];
474
+ gsdb.vendorverify = true;
475
+ VendorVerification(gaddr, tx.origin, block.timestamp);
476
+ }
477
+
478
+ function custodianTransfer(address gaddr, address ncaddr) ifcustodian {
479
+ GoldInfo gidb = goldinfodb[gaddr];
480
+ GoldStatus gsdb = goldstatusdb[gaddr];
481
+ gidb.custodian = ncaddr;
482
+ gsdb.custodianverify = false;
483
+ CustodianTransfer(gaddr, tx.origin, ncaddr);
484
+ }
485
+
486
+ function auditReport(address gaddr, bool ares, bytes32 ed, bytes32 doc) ifauditor {
487
+ GoldInfo gidb = goldinfodb[gaddr];
488
+ GoldStatus gsdb = goldstatusdb[gaddr];
489
+ gsdb.auditcount++;
490
+ uint auditcount = gsdb.auditcount;
491
+ Audit adt = gsdb.audits[auditcount];
492
+ gsdb.lastaudit = Audit({id: auditcount, time: block.timestamp, pass: ares, auditor: tx.origin, extradata: ed, documentation: doc});
493
+ adt = gsdb.lastaudit;
494
+ AuditEvent(gaddr, tx.origin, auditcount);
495
+ }
496
+
497
+ }
498
+
499
+
500
+
501
+ //#include [ParticipantRegistry]
502
+ //#include [Gold]
503
+ //#include [GoldRegistry]