@eluvio/elv-client-js 4.0.8 → 4.0.9

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.
Files changed (40) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +10 -11
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2069 -1548
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +323 -226
  10. package/dist/src/ElvClient.js +1118 -824
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +302 -160
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4198 -3272
  25. package/dist/src/client/ContentManagement.js +2284 -1812
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1491
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1766 -1350
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +124 -78
  36. package/dist/src/walletClient/index.js +1498 -1169
  37. package/package.json +1 -1
  38. package/src/client/ContentAccess.js +27 -10
  39. package/src/walletClient/ClientMethods.js +18 -10
  40. package/src/walletClient/index.js +7 -2
@@ -1,20 +1,32 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
+
2
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
+
3
5
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
6
+
4
7
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
8
+
5
9
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
10
+
6
11
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
12
+
7
13
  var _createClass = require("@babel/runtime/helpers/createClass");
14
+
8
15
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
16
+
9
17
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+
11
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
+
12
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
+
13
25
  // NOTE: Querying Ethereum requires CORS enabled
14
26
  // Use --rpccorsdomain "http[s]://hostname:port" or set up proxy
15
27
  var Ethers = require("ethers");
16
- var HttpClient = require("./HttpClient");
17
28
 
29
+ var HttpClient = require("./HttpClient");
18
30
  /*
19
31
  // -- Contract javascript files built using build/BuildContracts.js
20
32
  const ContentSpaceContract = require("./contracts/BaseContentSpace");
@@ -22,41 +34,46 @@ const ContentLibraryContract = require("./contracts/BaseLibrary");
22
34
  const ContentContract = require("./contracts/BaseContent");
23
35
  */
24
36
 
37
+
25
38
  var AccessibleContract = require("./contracts/v3/Accessible");
39
+
26
40
  var Utils = require("./Utils");
41
+
27
42
  var _require = require("./LogMessage"),
28
- LogMessage = _require.LogMessage;
43
+ LogMessage = _require.LogMessage;
44
+
29
45
  var Topics = require("./events/Topics");
46
+
30
47
  var EthClient = /*#__PURE__*/function () {
31
48
  "use strict";
32
49
 
33
50
  function EthClient(_ref) {
34
51
  var client = _ref.client,
35
- uris = _ref.uris,
36
- networkId = _ref.networkId,
37
- debug = _ref.debug,
38
- _ref$timeout = _ref.timeout,
39
- timeout = _ref$timeout === void 0 ? 10 : _ref$timeout;
52
+ uris = _ref.uris,
53
+ networkId = _ref.networkId,
54
+ debug = _ref.debug,
55
+ _ref$timeout = _ref.timeout,
56
+ timeout = _ref$timeout === void 0 ? 10 : _ref$timeout;
57
+
40
58
  _classCallCheck(this, EthClient);
59
+
41
60
  this.client = client;
42
61
  this.networkId = networkId;
43
62
  this.ethereumURIs = uris;
44
63
  this.ethereumURIIndex = 0;
45
64
  this.locked = false;
46
- this.debug = debug;
47
- // convert to milliseconds
65
+ this.debug = debug; // convert to milliseconds
66
+
48
67
  this.timeout = Math.floor(timeout * 1000);
49
68
  this.cachedContracts = {};
50
- this.contractNames = {};
69
+ this.contractNames = {}; // HTTP client for making misc calls to elv-master
51
70
 
52
- // HTTP client for making misc calls to elv-master
53
71
  this.HttpClient = new HttpClient({
54
72
  uris: this.ethereumURIs,
55
73
  debug: this.debug
56
- });
57
-
58
- //Ethers.errors.setLogLevel("error");
74
+ }); //Ethers.errors.setLogLevel("error");
59
75
  }
76
+
60
77
  _createClass(EthClient, [{
61
78
  key: "Log",
62
79
  value: function Log(message) {
@@ -77,24 +94,27 @@ var EthClient = /*#__PURE__*/function () {
77
94
  key: "Provider",
78
95
  value: function Provider() {
79
96
  if (!this.provider) {
80
- this.provider = new Ethers.providers.JsonRpcProvider(this.ethereumURIs[this.ethereumURIIndex], this.networkId);
81
-
82
- // Ethers.js uses eth_getCode to ensure a contract is deployed and nothing else - this pulls a large chunk of pointless
97
+ this.provider = new Ethers.providers.JsonRpcProvider(this.ethereumURIs[this.ethereumURIIndex], this.networkId); // Ethers.js uses eth_getCode to ensure a contract is deployed and nothing else - this pulls a large chunk of pointless
83
98
  // data every time a contract is initialized in the client (often). Ethers.js just checks that the code isn't == "0x", so
84
99
  // we can give it some dummy string instead and assume the contract is fine
100
+
85
101
  this.provider.getCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
86
102
  return _regeneratorRuntime.wrap(function _callee$(_context) {
87
- while (1) switch (_context.prev = _context.next) {
88
- case 0:
89
- return _context.abrupt("return", "0x123");
90
- case 1:
91
- case "end":
92
- return _context.stop();
103
+ while (1) {
104
+ switch (_context.prev = _context.next) {
105
+ case 0:
106
+ return _context.abrupt("return", "0x123");
107
+
108
+ case 1:
109
+ case "end":
110
+ return _context.stop();
111
+ }
93
112
  }
94
113
  }, _callee);
95
114
  }));
96
115
  this.provider.pollingInterval = 500;
97
116
  }
117
+
98
118
  return this.provider;
99
119
  }
100
120
  }, {
@@ -102,96 +122,119 @@ var EthClient = /*#__PURE__*/function () {
102
122
  value: function () {
103
123
  var _ContractName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(contractAddress) {
104
124
  var _this = this;
125
+
105
126
  var full,
106
- versionContract,
107
- version,
108
- _args3 = arguments;
127
+ versionContract,
128
+ version,
129
+ _args3 = arguments;
109
130
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
110
- while (1) switch (_context3.prev = _context3.next) {
111
- case 0:
112
- full = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
113
- versionContract = new Ethers.Contract(contractAddress, AccessibleContract.abi, this.Provider());
114
- if (!this.contractNames[contractAddress]) {
115
- this.contractNames[contractAddress] = new Promise( /*#__PURE__*/function () {
116
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve) {
117
- var versionBytes32, _version;
118
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
119
- while (1) switch (_context2.prev = _context2.next) {
120
- case 0:
121
- _context2.prev = 0;
122
- _context2.next = 3;
123
- return _this.CallContractMethod({
124
- contract: versionContract,
125
- abi: AccessibleContract.abi,
126
- methodName: "version",
127
- cacheContract: false
128
- });
129
- case 3:
130
- versionBytes32 = _context2.sent;
131
- _version = Ethers.utils.parseBytes32String(
132
- // Ensure bytes32 string is null terminated
133
- versionBytes32.slice(0, -2) + "00");
134
- resolve(_version);
135
- _context2.next = 11;
136
- break;
137
- case 8:
138
- _context2.prev = 8;
139
- _context2.t0 = _context2["catch"](0);
140
- resolve("Unknown");
141
- case 11:
142
- case "end":
143
- return _context2.stop();
144
- }
145
- }, _callee2, null, [[0, 8]]);
146
- }));
147
- return function (_x2) {
148
- return _ref3.apply(this, arguments);
149
- };
150
- }());
151
- }
152
- _context3.next = 5;
153
- return this.contractNames[contractAddress];
154
- case 5:
155
- version = _context3.sent;
156
- if (!full) {
157
- _context3.next = 10;
158
- break;
159
- }
160
- return _context3.abrupt("return", version);
161
- case 10:
162
- return _context3.abrupt("return", version.split(/\d+/)[0]);
163
- case 11:
164
- case "end":
165
- return _context3.stop();
131
+ while (1) {
132
+ switch (_context3.prev = _context3.next) {
133
+ case 0:
134
+ full = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
135
+ versionContract = new Ethers.Contract(contractAddress, AccessibleContract.abi, this.Provider());
136
+
137
+ if (!this.contractNames[contractAddress]) {
138
+ this.contractNames[contractAddress] = new Promise( /*#__PURE__*/function () {
139
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve) {
140
+ var versionBytes32, _version;
141
+
142
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
143
+ while (1) {
144
+ switch (_context2.prev = _context2.next) {
145
+ case 0:
146
+ _context2.prev = 0;
147
+ _context2.next = 3;
148
+ return _this.CallContractMethod({
149
+ contract: versionContract,
150
+ abi: AccessibleContract.abi,
151
+ methodName: "version",
152
+ cacheContract: false
153
+ });
154
+
155
+ case 3:
156
+ versionBytes32 = _context2.sent;
157
+ _version = Ethers.utils.parseBytes32String( // Ensure bytes32 string is null terminated
158
+ versionBytes32.slice(0, -2) + "00");
159
+ resolve(_version);
160
+ _context2.next = 11;
161
+ break;
162
+
163
+ case 8:
164
+ _context2.prev = 8;
165
+ _context2.t0 = _context2["catch"](0);
166
+ resolve("Unknown");
167
+
168
+ case 11:
169
+ case "end":
170
+ return _context2.stop();
171
+ }
172
+ }
173
+ }, _callee2, null, [[0, 8]]);
174
+ }));
175
+
176
+ return function (_x2) {
177
+ return _ref3.apply(this, arguments);
178
+ };
179
+ }());
180
+ }
181
+
182
+ _context3.next = 5;
183
+ return this.contractNames[contractAddress];
184
+
185
+ case 5:
186
+ version = _context3.sent;
187
+
188
+ if (!full) {
189
+ _context3.next = 10;
190
+ break;
191
+ }
192
+
193
+ return _context3.abrupt("return", version);
194
+
195
+ case 10:
196
+ return _context3.abrupt("return", version.split(/\d+/)[0]);
197
+
198
+ case 11:
199
+ case "end":
200
+ return _context3.stop();
201
+ }
166
202
  }
167
203
  }, _callee3, this);
168
204
  }));
205
+
169
206
  function ContractName(_x) {
170
207
  return _ContractName.apply(this, arguments);
171
208
  }
209
+
172
210
  return ContractName;
173
211
  }()
174
212
  }, {
175
213
  key: "Contract",
176
214
  value: function Contract(_ref4) {
177
215
  var contractAddress = _ref4.contractAddress,
178
- abi = _ref4.abi,
179
- cacheContract = _ref4.cacheContract,
180
- overrideCachedContract = _ref4.overrideCachedContract;
216
+ abi = _ref4.abi,
217
+ cacheContract = _ref4.cacheContract,
218
+ overrideCachedContract = _ref4.overrideCachedContract;
181
219
  var contract;
220
+
182
221
  if (!overrideCachedContract) {
183
222
  contract = this.cachedContracts[contractAddress];
184
223
  }
224
+
185
225
  if (!abi) {
186
226
  throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
187
227
  }
228
+
188
229
  if (!contract) {
189
230
  contract = new Ethers.Contract(contractAddress, abi, this.Provider());
190
231
  contract = contract.connect(this.client.signer);
232
+
191
233
  if (cacheContract) {
192
234
  this.cachedContracts[contractAddress] = contract;
193
235
  }
194
236
  }
237
+
195
238
  return contract;
196
239
  }
197
240
  }, {
@@ -199,66 +242,84 @@ var EthClient = /*#__PURE__*/function () {
199
242
  value: function () {
200
243
  var _MakeProviderCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
201
244
  var methodName, _ref5$args, args, _ref5$attempts, attempts, provider;
245
+
202
246
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
203
- while (1) switch (_context4.prev = _context4.next) {
204
- case 0:
205
- methodName = _ref5.methodName, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$attempts = _ref5.attempts, attempts = _ref5$attempts === void 0 ? 0 : _ref5$attempts;
206
- _context4.prev = 1;
207
- provider = this.Provider();
208
- _context4.next = 5;
209
- return this.provider.getNetwork();
210
- case 5:
211
- this.Log("ETH ".concat(provider.connection.url, " ").concat(methodName, " [").concat(args.join(", "), "]"));
212
- _context4.next = 8;
213
- return provider[methodName].apply(provider, _toConsumableArray(args));
214
- case 8:
215
- return _context4.abrupt("return", _context4.sent);
216
- case 11:
217
- _context4.prev = 11;
218
- _context4.t0 = _context4["catch"](1);
219
- // eslint-disable-next-line no-console
220
- console.error(_context4.t0);
221
- if (!(attempts < this.ethereumURIs.length)) {
222
- _context4.next = 19;
223
- break;
224
- }
225
- this.Log("EthClient failing over: ".concat(attempts + 1, " attempts"), true);
226
- this.provider = undefined;
227
- this.ethereumURIIndex = (this.ethereumURIIndex + 1) % this.ethereumURIs.length;
228
- return _context4.abrupt("return", this.MakeProviderCall({
229
- methodName: methodName,
230
- args: args,
231
- attempts: attempts + 1
232
- }));
233
- case 19:
234
- return _context4.abrupt("return", {});
235
- case 20:
236
- case "end":
237
- return _context4.stop();
247
+ while (1) {
248
+ switch (_context4.prev = _context4.next) {
249
+ case 0:
250
+ methodName = _ref5.methodName, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$attempts = _ref5.attempts, attempts = _ref5$attempts === void 0 ? 0 : _ref5$attempts;
251
+ _context4.prev = 1;
252
+ provider = this.Provider();
253
+ _context4.next = 5;
254
+ return this.provider.getNetwork();
255
+
256
+ case 5:
257
+ this.Log("ETH ".concat(provider.connection.url, " ").concat(methodName, " [").concat(args.join(", "), "]"));
258
+ _context4.next = 8;
259
+ return provider[methodName].apply(provider, _toConsumableArray(args));
260
+
261
+ case 8:
262
+ return _context4.abrupt("return", _context4.sent);
263
+
264
+ case 11:
265
+ _context4.prev = 11;
266
+ _context4.t0 = _context4["catch"](1);
267
+ // eslint-disable-next-line no-console
268
+ console.error(_context4.t0);
269
+
270
+ if (!(attempts < this.ethereumURIs.length)) {
271
+ _context4.next = 19;
272
+ break;
273
+ }
274
+
275
+ this.Log("EthClient failing over: ".concat(attempts + 1, " attempts"), true);
276
+ this.provider = undefined;
277
+ this.ethereumURIIndex = (this.ethereumURIIndex + 1) % this.ethereumURIs.length;
278
+ return _context4.abrupt("return", this.MakeProviderCall({
279
+ methodName: methodName,
280
+ args: args,
281
+ attempts: attempts + 1
282
+ }));
283
+
284
+ case 19:
285
+ return _context4.abrupt("return", {});
286
+
287
+ case 20:
288
+ case "end":
289
+ return _context4.stop();
290
+ }
238
291
  }
239
292
  }, _callee4, this, [[1, 11]]);
240
293
  }));
294
+
241
295
  function MakeProviderCall(_x3) {
242
296
  return _MakeProviderCall.apply(this, arguments);
243
297
  }
298
+
244
299
  return MakeProviderCall;
245
- }() /* General contract management */
300
+ }()
301
+ /* General contract management */
302
+
246
303
  }, {
247
304
  key: "FormatContractArgument",
248
305
  value: function FormatContractArgument(_ref6) {
249
306
  var _this2 = this;
307
+
250
308
  var type = _ref6.type,
251
- value = _ref6.value;
309
+ value = _ref6.value;
310
+
252
311
  // For array types, parse into array if necessary, then format each value.
253
312
  if (type.endsWith("[]")) {
254
313
  if (typeof value === "string") {
255
314
  if (value.trim() === "") {
256
315
  return [];
257
316
  }
317
+
258
318
  value = value.split(",").map(function (s) {
259
319
  return s.trim();
260
320
  });
261
321
  }
322
+
262
323
  var singleType = type.replace("[]", "");
263
324
  return value.map(function (element) {
264
325
  return _this2.FormatContractArgument({
@@ -267,44 +328,48 @@ var EthClient = /*#__PURE__*/function () {
267
328
  });
268
329
  });
269
330
  }
331
+
270
332
  switch (type.toLowerCase()) {
271
333
  case "bytes32":
272
334
  return Ethers.utils.formatBytes32String(value);
335
+
273
336
  case "bytes":
274
337
  return Ethers.utils.toUtf8Bytes(value);
338
+
275
339
  case "address":
276
340
  return Utils.FormatAddress(value);
341
+
277
342
  default:
278
343
  return value;
279
344
  }
280
- }
345
+ } // Apply any necessary formatting to contract arguments based on the ABI spec
281
346
 
282
- // Apply any necessary formatting to contract arguments based on the ABI spec
283
347
  }, {
284
348
  key: "FormatContractArguments",
285
349
  value: function FormatContractArguments(_ref7) {
286
350
  var _this3 = this;
351
+
287
352
  var abi = _ref7.abi,
288
- methodName = _ref7.methodName,
289
- args = _ref7.args;
353
+ methodName = _ref7.methodName,
354
+ args = _ref7.args;
290
355
  var method = abi.find(function (func) {
291
356
  // Constructor has type=constructor but no name
292
357
  return func.name === methodName || func.type === methodName;
293
358
  });
359
+
294
360
  if (method === undefined) {
295
361
  throw Error("Unknown method: " + methodName);
296
- }
362
+ } // Format each argument
363
+
297
364
 
298
- // Format each argument
299
365
  return args.map(function (arg, i) {
300
366
  return _this3.FormatContractArgument({
301
367
  type: method.inputs[i].type,
302
368
  value: arg
303
369
  });
304
370
  });
305
- }
371
+ } // Validate signer is set
306
372
 
307
- // Validate signer is set
308
373
  }, {
309
374
  key: "ValidateSigner",
310
375
  value: function ValidateSigner(signer) {
@@ -317,177 +382,221 @@ var EthClient = /*#__PURE__*/function () {
317
382
  value: function () {
318
383
  var _DeployContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
319
384
  var abi, bytecode, _ref8$constructorArgs, constructorArgs, _ref8$overrides, overrides, provider, signer, contractFactory, contract;
385
+
320
386
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
321
- while (1) switch (_context5.prev = _context5.next) {
322
- case 0:
323
- abi = _ref8.abi, bytecode = _ref8.bytecode, _ref8$constructorArgs = _ref8.constructorArgs, constructorArgs = _ref8$constructorArgs === void 0 ? [] : _ref8$constructorArgs, _ref8$overrides = _ref8.overrides, overrides = _ref8$overrides === void 0 ? {} : _ref8$overrides;
324
- this.Log("Deploying contract with args [".concat(constructorArgs.join(", "), "]"));
325
- provider = this.Provider();
326
- provider.getNetwork();
327
- signer = this.client.signer.connect(provider);
328
- this.ValidateSigner(signer);
329
- contractFactory = new Ethers.ContractFactory(abi, bytecode, signer);
330
- _context5.next = 9;
331
- return contractFactory.deploy.apply(contractFactory, _toConsumableArray(constructorArgs).concat([overrides]));
332
- case 9:
333
- contract = _context5.sent;
334
- _context5.next = 12;
335
- return contract.deployed();
336
- case 12:
337
- this.Log("Deployed: ".concat(contract.address));
338
- return _context5.abrupt("return", {
339
- contractAddress: Utils.FormatAddress(contract.address),
340
- transactionHash: contract.deployTransaction.hash
341
- });
342
- case 14:
343
- case "end":
344
- return _context5.stop();
387
+ while (1) {
388
+ switch (_context5.prev = _context5.next) {
389
+ case 0:
390
+ abi = _ref8.abi, bytecode = _ref8.bytecode, _ref8$constructorArgs = _ref8.constructorArgs, constructorArgs = _ref8$constructorArgs === void 0 ? [] : _ref8$constructorArgs, _ref8$overrides = _ref8.overrides, overrides = _ref8$overrides === void 0 ? {} : _ref8$overrides;
391
+ this.Log("Deploying contract with args [".concat(constructorArgs.join(", "), "]"));
392
+ provider = this.Provider();
393
+ provider.getNetwork();
394
+ signer = this.client.signer.connect(provider);
395
+ this.ValidateSigner(signer);
396
+ contractFactory = new Ethers.ContractFactory(abi, bytecode, signer);
397
+ _context5.next = 9;
398
+ return contractFactory.deploy.apply(contractFactory, _toConsumableArray(constructorArgs).concat([overrides]));
399
+
400
+ case 9:
401
+ contract = _context5.sent;
402
+ _context5.next = 12;
403
+ return contract.deployed();
404
+
405
+ case 12:
406
+ this.Log("Deployed: ".concat(contract.address));
407
+ return _context5.abrupt("return", {
408
+ contractAddress: Utils.FormatAddress(contract.address),
409
+ transactionHash: contract.deployTransaction.hash
410
+ });
411
+
412
+ case 14:
413
+ case "end":
414
+ return _context5.stop();
415
+ }
345
416
  }
346
417
  }, _callee5, this);
347
418
  }));
419
+
348
420
  function DeployContract(_x4) {
349
421
  return _DeployContract.apply(this, arguments);
350
422
  }
423
+
351
424
  return DeployContract;
352
425
  }() // Accepts either contract object or contract address
426
+
353
427
  }, {
354
428
  key: "CallContractMethod",
355
429
  value: function () {
356
430
  var _CallContractMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref9) {
357
431
  var contract, contractAddress, abi, methodName, _ref9$methodArgs, methodArgs, value, _ref9$overrides, overrides, _ref9$formatArguments, formatArguments, _ref9$cacheContract, cacheContract, _ref9$overrideCachedC, overrideCachedContract, methodAbi, result, success, _contract, latestBlock;
432
+
358
433
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
359
- while (1) switch (_context6.prev = _context6.next) {
360
- case 0:
361
- contract = _ref9.contract, contractAddress = _ref9.contractAddress, abi = _ref9.abi, methodName = _ref9.methodName, _ref9$methodArgs = _ref9.methodArgs, methodArgs = _ref9$methodArgs === void 0 ? [] : _ref9$methodArgs, value = _ref9.value, _ref9$overrides = _ref9.overrides, overrides = _ref9$overrides === void 0 ? {} : _ref9$overrides, _ref9$formatArguments = _ref9.formatArguments, formatArguments = _ref9$formatArguments === void 0 ? true : _ref9$formatArguments, _ref9$cacheContract = _ref9.cacheContract, cacheContract = _ref9$cacheContract === void 0 ? true : _ref9$cacheContract, _ref9$overrideCachedC = _ref9.overrideCachedContract, overrideCachedContract = _ref9$overrideCachedC === void 0 ? false : _ref9$overrideCachedC;
362
- if (abi) {
363
- _context6.next = 5;
364
- break;
365
- }
366
- _context6.next = 4;
367
- return this.client.ContractAbi({
368
- contractAddress: contractAddress
369
- });
370
- case 4:
371
- abi = _context6.sent;
372
- case 5:
373
- contract = contract || this.Contract({
374
- contractAddress: contractAddress,
375
- abi: abi,
376
- cacheContract: cacheContract,
377
- overrideCachedContract: overrideCachedContract
378
- });
379
- abi = contract["interface"].fragments;
380
-
381
- // Automatically format contract arguments
382
- if (formatArguments) {
383
- methodArgs = this.FormatContractArguments({
434
+ while (1) {
435
+ switch (_context6.prev = _context6.next) {
436
+ case 0:
437
+ contract = _ref9.contract, contractAddress = _ref9.contractAddress, abi = _ref9.abi, methodName = _ref9.methodName, _ref9$methodArgs = _ref9.methodArgs, methodArgs = _ref9$methodArgs === void 0 ? [] : _ref9$methodArgs, value = _ref9.value, _ref9$overrides = _ref9.overrides, overrides = _ref9$overrides === void 0 ? {} : _ref9$overrides, _ref9$formatArguments = _ref9.formatArguments, formatArguments = _ref9$formatArguments === void 0 ? true : _ref9$formatArguments, _ref9$cacheContract = _ref9.cacheContract, cacheContract = _ref9$cacheContract === void 0 ? true : _ref9$cacheContract, _ref9$overrideCachedC = _ref9.overrideCachedContract, overrideCachedContract = _ref9$overrideCachedC === void 0 ? false : _ref9$overrideCachedC;
438
+
439
+ if (abi) {
440
+ _context6.next = 5;
441
+ break;
442
+ }
443
+
444
+ _context6.next = 4;
445
+ return this.client.ContractAbi({
446
+ contractAddress: contractAddress
447
+ });
448
+
449
+ case 4:
450
+ abi = _context6.sent;
451
+
452
+ case 5:
453
+ contract = contract || this.Contract({
454
+ contractAddress: contractAddress,
384
455
  abi: abi,
385
- methodName: methodName,
386
- args: methodArgs
456
+ cacheContract: cacheContract,
457
+ overrideCachedContract: overrideCachedContract
387
458
  });
388
- }
389
- if (value) {
390
- // Convert Ether to Wei
391
- overrides.value = "0x" + Utils.EtherToWei(value.toString()).toString(16);
392
- }
393
- if (!(contract.functions[methodName] === undefined)) {
394
- _context6.next = 11;
395
- break;
396
- }
397
- throw Error("Unknown method: " + methodName);
398
- case 11:
399
- this.Log("Calling contract method:\n Provider: ".concat(this.Provider().connection.url, "\n Address: ").concat(contract.address, "\n Method: ").concat(methodName, "\n Args: [").concat(methodArgs.join(", "), "]"));
400
- methodAbi = contract["interface"].fragments.find(function (method) {
401
- return method.name === methodName;
402
- }); // Lock if performing a transaction
403
- if (!(!methodAbi || !methodAbi.constant)) {
404
- _context6.next = 20;
405
- break;
406
- }
407
- case 14:
408
- if (!this.locked) {
409
- _context6.next = 19;
410
- break;
411
- }
412
- _context6.next = 17;
413
- return new Promise(function (resolve) {
414
- return setTimeout(resolve, 100);
415
- });
416
- case 17:
417
- _context6.next = 14;
418
- break;
419
- case 19:
420
- this.locked = true;
421
- case 20:
422
- _context6.prev = 20;
423
- success = false;
424
- case 22:
425
- if (success) {
426
- _context6.next = 49;
459
+ abi = contract["interface"].fragments; // Automatically format contract arguments
460
+
461
+ if (formatArguments) {
462
+ methodArgs = this.FormatContractArguments({
463
+ abi: abi,
464
+ methodName: methodName,
465
+ args: methodArgs
466
+ });
467
+ }
468
+
469
+ if (value) {
470
+ // Convert Ether to Wei
471
+ overrides.value = "0x" + Utils.EtherToWei(value.toString()).toString(16);
472
+ }
473
+
474
+ if (!(contract.functions[methodName] === undefined)) {
475
+ _context6.next = 11;
476
+ break;
477
+ }
478
+
479
+ throw Error("Unknown method: " + methodName);
480
+
481
+ case 11:
482
+ this.Log("Calling contract method:\n Provider: ".concat(this.Provider().connection.url, "\n Address: ").concat(contract.address, "\n Method: ").concat(methodName, "\n Args: [").concat(methodArgs.join(", "), "]"));
483
+ methodAbi = contract["interface"].fragments.find(function (method) {
484
+ return method.name === methodName;
485
+ }); // Lock if performing a transaction
486
+
487
+ if (!(!methodAbi || !methodAbi.constant)) {
488
+ _context6.next = 20;
489
+ break;
490
+ }
491
+
492
+ case 14:
493
+ if (!this.locked) {
494
+ _context6.next = 19;
495
+ break;
496
+ }
497
+
498
+ _context6.next = 17;
499
+ return new Promise(function (resolve) {
500
+ return setTimeout(resolve, 100);
501
+ });
502
+
503
+ case 17:
504
+ _context6.next = 14;
427
505
  break;
428
- }
429
- _context6.prev = 23;
430
- _context6.next = 26;
431
- return (_contract = contract)[methodName].apply(_contract, _toConsumableArray(methodArgs).concat([overrides]));
432
- case 26:
433
- result = _context6.sent;
434
- success = true;
435
- _context6.next = 47;
436
- break;
437
- case 30:
438
- _context6.prev = 30;
439
- _context6.t0 = _context6["catch"](23);
440
- if (!(_context6.t0.code === -32000 || _context6.t0.code === "REPLACEMENT_UNDERPRICED")) {
441
- _context6.next = 40;
506
+
507
+ case 19:
508
+ this.locked = true;
509
+
510
+ case 20:
511
+ _context6.prev = 20;
512
+ success = false;
513
+
514
+ case 22:
515
+ if (success) {
516
+ _context6.next = 49;
517
+ break;
518
+ }
519
+
520
+ _context6.prev = 23;
521
+ _context6.next = 26;
522
+ return (_contract = contract)[methodName].apply(_contract, _toConsumableArray(methodArgs).concat([overrides]));
523
+
524
+ case 26:
525
+ result = _context6.sent;
526
+ success = true;
527
+ _context6.next = 47;
442
528
  break;
443
- }
444
- _context6.next = 35;
445
- return this.MakeProviderCall({
446
- methodName: "getBlock",
447
- args: ["latest"]
448
- });
449
- case 35:
450
- latestBlock = _context6.sent;
451
- overrides.gasLimit = latestBlock.gasLimit;
452
- overrides.gasPrice = overrides.gasPrice ? overrides.gasPrice * 1.50 : 8000000000;
453
- _context6.next = 47;
454
- break;
455
- case 40:
456
- if (!(_context6.t0.code === "NONCE_EXPIRED" && _context6.t0.reason === "nonce has already been used")) {
457
- _context6.next = 44;
529
+
530
+ case 30:
531
+ _context6.prev = 30;
532
+ _context6.t0 = _context6["catch"](23);
533
+
534
+ if (!(_context6.t0.code === -32000 || _context6.t0.code === "REPLACEMENT_UNDERPRICED")) {
535
+ _context6.next = 40;
536
+ break;
537
+ }
538
+
539
+ _context6.next = 35;
540
+ return this.MakeProviderCall({
541
+ methodName: "getBlock",
542
+ args: ["latest"]
543
+ });
544
+
545
+ case 35:
546
+ latestBlock = _context6.sent;
547
+ overrides.gasLimit = latestBlock.gasLimit;
548
+ overrides.gasPrice = overrides.gasPrice ? overrides.gasPrice * 1.50 : 8000000000;
549
+ _context6.next = 47;
458
550
  break;
459
- }
460
- this.Log("Retrying method call ".concat(methodName));
461
- _context6.next = 47;
462
- break;
463
- case 44:
464
- if ((_context6.t0.message || _context6.t0).includes("invalid response")) {
551
+
552
+ case 40:
553
+ if (!(_context6.t0.code === "NONCE_EXPIRED" && _context6.t0.reason === "nonce has already been used")) {
554
+ _context6.next = 44;
555
+ break;
556
+ }
557
+
558
+ this.Log("Retrying method call ".concat(methodName));
465
559
  _context6.next = 47;
466
560
  break;
467
- }
468
- this.Log(_typeof(_context6.t0) === "object" ? JSON.stringify(_context6.t0, null, 2) : _context6.t0, true);
469
- throw _context6.t0;
470
- case 47:
471
- _context6.next = 22;
472
- break;
473
- case 49:
474
- return _context6.abrupt("return", result);
475
- case 50:
476
- _context6.prev = 50;
477
- // Unlock if performing a transaction
478
- if (!methodAbi || !methodAbi.constant) {
479
- this.locked = false;
480
- }
481
- return _context6.finish(50);
482
- case 53:
483
- case "end":
484
- return _context6.stop();
561
+
562
+ case 44:
563
+ if ((_context6.t0.message || _context6.t0).includes("invalid response")) {
564
+ _context6.next = 47;
565
+ break;
566
+ }
567
+
568
+ this.Log(_typeof(_context6.t0) === "object" ? JSON.stringify(_context6.t0, null, 2) : _context6.t0, true);
569
+ throw _context6.t0;
570
+
571
+ case 47:
572
+ _context6.next = 22;
573
+ break;
574
+
575
+ case 49:
576
+ return _context6.abrupt("return", result);
577
+
578
+ case 50:
579
+ _context6.prev = 50;
580
+
581
+ // Unlock if performing a transaction
582
+ if (!methodAbi || !methodAbi.constant) {
583
+ this.locked = false;
584
+ }
585
+
586
+ return _context6.finish(50);
587
+
588
+ case 53:
589
+ case "end":
590
+ return _context6.stop();
591
+ }
485
592
  }
486
593
  }, _callee6, this, [[20,, 50, 53], [23, 30]]);
487
594
  }));
595
+
488
596
  function CallContractMethod(_x5) {
489
597
  return _CallContractMethod.apply(this, arguments);
490
598
  }
599
+
491
600
  return CallContractMethod;
492
601
  }()
493
602
  }, {
@@ -495,96 +604,118 @@ var EthClient = /*#__PURE__*/function () {
495
604
  value: function () {
496
605
  var _CallContractMethodAndWait = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
497
606
  var contractAddress, abi, methodName, methodArgs, value, timeout, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract, contract, createMethodCall, interval, elapsed, methodEvent;
607
+
498
608
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
499
- while (1) switch (_context7.prev = _context7.next) {
500
- case 0:
501
- contractAddress = _ref10.contractAddress, abi = _ref10.abi, methodName = _ref10.methodName, methodArgs = _ref10.methodArgs, value = _ref10.value, timeout = _ref10.timeout, _ref10$formatArgument = _ref10.formatArguments, formatArguments = _ref10$formatArgument === void 0 ? true : _ref10$formatArgument, _ref10$cacheContract = _ref10.cacheContract, cacheContract = _ref10$cacheContract === void 0 ? true : _ref10$cacheContract, _ref10$overrideCached = _ref10.overrideCachedContract, overrideCachedContract = _ref10$overrideCached === void 0 ? false : _ref10$overrideCached;
502
- timeout = timeout || this.timeout || 10000;
503
- if (abi) {
504
- _context7.next = 6;
505
- break;
506
- }
507
- _context7.next = 5;
508
- return this.client.ContractAbi({
509
- contractAddress: contractAddress
510
- });
511
- case 5:
512
- abi = _context7.sent;
513
- case 6:
514
- contract = this.Contract({
515
- contractAddress: contractAddress,
516
- abi: abi,
517
- cacheContract: cacheContract,
518
- overrideCachedContract: overrideCachedContract
519
- }); // Make method call
520
- _context7.next = 9;
521
- return this.CallContractMethod({
522
- contract: contract,
523
- abi: abi,
524
- methodName: methodName,
525
- methodArgs: methodArgs,
526
- value: value,
527
- formatArguments: formatArguments,
528
- cacheContract: cacheContract
529
- });
530
- case 9:
531
- createMethodCall = _context7.sent;
532
- this.Log("Awaiting transaction completion: ".concat(createMethodCall.hash));
533
-
534
- // Poll for transaction completion
535
- interval = this.Provider().pollingInterval;
536
- elapsed = 0;
537
- case 13:
538
- if (!(elapsed < timeout)) {
539
- _context7.next = 25;
540
- break;
541
- }
542
- _context7.next = 16;
543
- return this.MakeProviderCall({
544
- methodName: "getTransactionReceipt",
545
- args: [createMethodCall.hash]
546
- });
547
- case 16:
548
- methodEvent = _context7.sent;
549
- if (!methodEvent) {
550
- _context7.next = 20;
551
- break;
552
- }
553
- methodEvent.logs = methodEvent.logs.map(function (log) {
554
- var parsedLogs = {};
555
- try {
556
- parsedLogs = contract["interface"].parseLog(log);
557
- // eslint-disable-next-line no-empty
558
- } catch (error) {}
559
- return _objectSpread(_objectSpread({}, log), parsedLogs);
560
- });
561
- return _context7.abrupt("break", 25);
562
- case 20:
563
- elapsed += interval;
564
- _context7.next = 23;
565
- return new Promise(function (resolve) {
566
- return setTimeout(resolve, interval);
567
- });
568
- case 23:
569
- _context7.next = 13;
570
- break;
571
- case 25:
572
- if (methodEvent) {
573
- _context7.next = 27;
609
+ while (1) {
610
+ switch (_context7.prev = _context7.next) {
611
+ case 0:
612
+ contractAddress = _ref10.contractAddress, abi = _ref10.abi, methodName = _ref10.methodName, methodArgs = _ref10.methodArgs, value = _ref10.value, timeout = _ref10.timeout, _ref10$formatArgument = _ref10.formatArguments, formatArguments = _ref10$formatArgument === void 0 ? true : _ref10$formatArgument, _ref10$cacheContract = _ref10.cacheContract, cacheContract = _ref10$cacheContract === void 0 ? true : _ref10$cacheContract, _ref10$overrideCached = _ref10.overrideCachedContract, overrideCachedContract = _ref10$overrideCached === void 0 ? false : _ref10$overrideCached;
613
+ timeout = timeout || this.timeout || 10000;
614
+
615
+ if (abi) {
616
+ _context7.next = 6;
617
+ break;
618
+ }
619
+
620
+ _context7.next = 5;
621
+ return this.client.ContractAbi({
622
+ contractAddress: contractAddress
623
+ });
624
+
625
+ case 5:
626
+ abi = _context7.sent;
627
+
628
+ case 6:
629
+ contract = this.Contract({
630
+ contractAddress: contractAddress,
631
+ abi: abi,
632
+ cacheContract: cacheContract,
633
+ overrideCachedContract: overrideCachedContract
634
+ }); // Make method call
635
+
636
+ _context7.next = 9;
637
+ return this.CallContractMethod({
638
+ contract: contract,
639
+ abi: abi,
640
+ methodName: methodName,
641
+ methodArgs: methodArgs,
642
+ value: value,
643
+ formatArguments: formatArguments,
644
+ cacheContract: cacheContract
645
+ });
646
+
647
+ case 9:
648
+ createMethodCall = _context7.sent;
649
+ this.Log("Awaiting transaction completion: ".concat(createMethodCall.hash)); // Poll for transaction completion
650
+
651
+ interval = this.Provider().pollingInterval;
652
+ elapsed = 0;
653
+
654
+ case 13:
655
+ if (!(elapsed < timeout)) {
656
+ _context7.next = 25;
657
+ break;
658
+ }
659
+
660
+ _context7.next = 16;
661
+ return this.MakeProviderCall({
662
+ methodName: "getTransactionReceipt",
663
+ args: [createMethodCall.hash]
664
+ });
665
+
666
+ case 16:
667
+ methodEvent = _context7.sent;
668
+
669
+ if (!methodEvent) {
670
+ _context7.next = 20;
671
+ break;
672
+ }
673
+
674
+ methodEvent.logs = methodEvent.logs.map(function (log) {
675
+ var parsedLogs = {};
676
+
677
+ try {
678
+ parsedLogs = contract["interface"].parseLog(log); // eslint-disable-next-line no-empty
679
+ } catch (error) {}
680
+
681
+ return _objectSpread(_objectSpread({}, log), parsedLogs);
682
+ });
683
+ return _context7.abrupt("break", 25);
684
+
685
+ case 20:
686
+ elapsed += interval;
687
+ _context7.next = 23;
688
+ return new Promise(function (resolve) {
689
+ return setTimeout(resolve, interval);
690
+ });
691
+
692
+ case 23:
693
+ _context7.next = 13;
574
694
  break;
575
- }
576
- throw Error("Timed out waiting for completion of ".concat(methodName, ". TXID: ").concat(createMethodCall.hash));
577
- case 27:
578
- return _context7.abrupt("return", methodEvent);
579
- case 28:
580
- case "end":
581
- return _context7.stop();
695
+
696
+ case 25:
697
+ if (methodEvent) {
698
+ _context7.next = 27;
699
+ break;
700
+ }
701
+
702
+ throw Error("Timed out waiting for completion of ".concat(methodName, ". TXID: ").concat(createMethodCall.hash));
703
+
704
+ case 27:
705
+ return _context7.abrupt("return", methodEvent);
706
+
707
+ case 28:
708
+ case "end":
709
+ return _context7.stop();
710
+ }
582
711
  }
583
712
  }, _callee7, this);
584
713
  }));
714
+
585
715
  function CallContractMethodAndWait(_x6) {
586
716
  return _CallContractMethodAndWait.apply(this, arguments);
587
717
  }
718
+
588
719
  return CallContractMethodAndWait;
589
720
  }()
590
721
  }, {
@@ -593,52 +724,61 @@ var EthClient = /*#__PURE__*/function () {
593
724
  var _AwaitEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref11) {
594
725
  var contractAddress, abi, eventName, contract;
595
726
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
596
- while (1) switch (_context8.prev = _context8.next) {
597
- case 0:
598
- contractAddress = _ref11.contractAddress, abi = _ref11.abi, eventName = _ref11.eventName;
599
- contract = this.Contract({
600
- contractAddress: contractAddress,
601
- abi: abi
602
- });
603
- _context8.next = 4;
604
- return new Promise(function (resolve) {
605
- contract.on(eventName, function (_, __, event) {
606
- contract.removeAllListeners(eventName);
607
- resolve(event);
727
+ while (1) {
728
+ switch (_context8.prev = _context8.next) {
729
+ case 0:
730
+ contractAddress = _ref11.contractAddress, abi = _ref11.abi, eventName = _ref11.eventName;
731
+ contract = this.Contract({
732
+ contractAddress: contractAddress,
733
+ abi: abi
734
+ });
735
+ _context8.next = 4;
736
+ return new Promise(function (resolve) {
737
+ contract.on(eventName, function (_, __, event) {
738
+ contract.removeAllListeners(eventName);
739
+ resolve(event);
740
+ });
608
741
  });
609
- });
610
- case 4:
611
- return _context8.abrupt("return", _context8.sent);
612
- case 5:
613
- case "end":
614
- return _context8.stop();
742
+
743
+ case 4:
744
+ return _context8.abrupt("return", _context8.sent);
745
+
746
+ case 5:
747
+ case "end":
748
+ return _context8.stop();
749
+ }
615
750
  }
616
751
  }, _callee8, this);
617
752
  }));
753
+
618
754
  function AwaitEvent(_x7) {
619
755
  return _AwaitEvent.apply(this, arguments);
620
756
  }
757
+
621
758
  return AwaitEvent;
622
759
  }()
623
760
  }, {
624
761
  key: "ExtractEventFromLogs",
625
762
  value: function ExtractEventFromLogs(_ref12) {
626
763
  var abi = _ref12.abi,
627
- event = _ref12.event,
628
- eventName = _ref12.eventName;
629
- var contractInterface = new Ethers.utils.Interface(abi);
630
- // Loop through logs to find the desired log
764
+ event = _ref12.event,
765
+ eventName = _ref12.eventName;
766
+ var contractInterface = new Ethers.utils.Interface(abi); // Loop through logs to find the desired log
767
+
631
768
  var _iterator = _createForOfIteratorHelper(event.logs),
632
- _step;
769
+ _step;
770
+
633
771
  try {
634
772
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
635
773
  var log = _step.value;
774
+
636
775
  try {
637
776
  var parsedLog = contractInterface.parseLog(log);
777
+
638
778
  if (parsedLog && parsedLog.name === eventName) {
639
779
  return parsedLog;
640
- }
641
- // eslint-disable-next-line no-empty
780
+ } // eslint-disable-next-line no-empty
781
+
642
782
  } catch (error) {}
643
783
  }
644
784
  } catch (err) {
@@ -652,78 +792,96 @@ var EthClient = /*#__PURE__*/function () {
652
792
  value: function () {
653
793
  var _DeployDependentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
654
794
  var contractAddress, methodName, _ref13$args, args, eventName, eventValue, abi, event, eventLog, newContractAddress;
795
+
655
796
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
656
- while (1) switch (_context9.prev = _context9.next) {
657
- case 0:
658
- contractAddress = _ref13.contractAddress, methodName = _ref13.methodName, _ref13$args = _ref13.args, args = _ref13$args === void 0 ? [] : _ref13$args, eventName = _ref13.eventName, eventValue = _ref13.eventValue;
659
- _context9.next = 3;
660
- return this.client.ContractAbi({
661
- contractAddress: contractAddress
662
- });
663
- case 3:
664
- abi = _context9.sent;
665
- _context9.next = 6;
666
- return this.CallContractMethodAndWait({
667
- contractAddress: contractAddress,
668
- abi: abi,
669
- methodName: methodName,
670
- methodArgs: args
671
- });
672
- case 6:
673
- event = _context9.sent;
674
- eventLog = this.ExtractEventFromLogs({
675
- abi: abi,
676
- event: event,
677
- eventName: eventName,
678
- eventValue: eventValue
679
- });
680
- if (eventLog) {
681
- _context9.next = 10;
682
- break;
683
- }
684
- throw Error("".concat(methodName, " failed - Log not present in transaction"));
685
- case 10:
686
- newContractAddress = eventLog.args[eventValue];
687
- return _context9.abrupt("return", {
688
- contractAddress: Utils.FormatAddress(newContractAddress),
689
- transactionHash: event.transactionHash
690
- });
691
- case 12:
692
- case "end":
693
- return _context9.stop();
797
+ while (1) {
798
+ switch (_context9.prev = _context9.next) {
799
+ case 0:
800
+ contractAddress = _ref13.contractAddress, methodName = _ref13.methodName, _ref13$args = _ref13.args, args = _ref13$args === void 0 ? [] : _ref13$args, eventName = _ref13.eventName, eventValue = _ref13.eventValue;
801
+ _context9.next = 3;
802
+ return this.client.ContractAbi({
803
+ contractAddress: contractAddress
804
+ });
805
+
806
+ case 3:
807
+ abi = _context9.sent;
808
+ _context9.next = 6;
809
+ return this.CallContractMethodAndWait({
810
+ contractAddress: contractAddress,
811
+ abi: abi,
812
+ methodName: methodName,
813
+ methodArgs: args
814
+ });
815
+
816
+ case 6:
817
+ event = _context9.sent;
818
+ eventLog = this.ExtractEventFromLogs({
819
+ abi: abi,
820
+ event: event,
821
+ eventName: eventName,
822
+ eventValue: eventValue
823
+ });
824
+
825
+ if (eventLog) {
826
+ _context9.next = 10;
827
+ break;
828
+ }
829
+
830
+ throw Error("".concat(methodName, " failed - Log not present in transaction"));
831
+
832
+ case 10:
833
+ newContractAddress = eventLog.args[eventValue];
834
+ return _context9.abrupt("return", {
835
+ contractAddress: Utils.FormatAddress(newContractAddress),
836
+ transactionHash: event.transactionHash
837
+ });
838
+
839
+ case 12:
840
+ case "end":
841
+ return _context9.stop();
842
+ }
694
843
  }
695
844
  }, _callee9, this);
696
845
  }));
846
+
697
847
  function DeployDependentContract(_x8) {
698
848
  return _DeployDependentContract.apply(this, arguments);
699
849
  }
850
+
700
851
  return DeployDependentContract;
701
- }() /* Specific contract management */
852
+ }()
853
+ /* Specific contract management */
854
+
702
855
  }, {
703
856
  key: "DeployAccessGroupContract",
704
857
  value: function () {
705
858
  var _DeployAccessGroupContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
706
859
  var contentSpaceAddress;
707
860
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
708
- while (1) switch (_context10.prev = _context10.next) {
709
- case 0:
710
- contentSpaceAddress = _ref14.contentSpaceAddress;
711
- return _context10.abrupt("return", this.DeployDependentContract({
712
- contractAddress: contentSpaceAddress,
713
- methodName: "createGroup",
714
- args: [],
715
- eventName: "CreateGroup",
716
- eventValue: "groupAddress"
717
- }));
718
- case 2:
719
- case "end":
720
- return _context10.stop();
861
+ while (1) {
862
+ switch (_context10.prev = _context10.next) {
863
+ case 0:
864
+ contentSpaceAddress = _ref14.contentSpaceAddress;
865
+ return _context10.abrupt("return", this.DeployDependentContract({
866
+ contractAddress: contentSpaceAddress,
867
+ methodName: "createGroup",
868
+ args: [],
869
+ eventName: "CreateGroup",
870
+ eventValue: "groupAddress"
871
+ }));
872
+
873
+ case 2:
874
+ case "end":
875
+ return _context10.stop();
876
+ }
721
877
  }
722
878
  }, _callee10, this);
723
879
  }));
880
+
724
881
  function DeployAccessGroupContract(_x9) {
725
882
  return _DeployAccessGroupContract.apply(this, arguments);
726
883
  }
884
+
727
885
  return DeployAccessGroupContract;
728
886
  }()
729
887
  }, {
@@ -732,25 +890,30 @@ var EthClient = /*#__PURE__*/function () {
732
890
  var _DeployTypeContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref15) {
733
891
  var contentSpaceAddress;
734
892
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
735
- while (1) switch (_context11.prev = _context11.next) {
736
- case 0:
737
- contentSpaceAddress = _ref15.contentSpaceAddress;
738
- return _context11.abrupt("return", this.DeployDependentContract({
739
- contractAddress: contentSpaceAddress,
740
- methodName: "createContentType",
741
- args: [],
742
- eventName: "CreateContentType",
743
- eventValue: "contentTypeAddress"
744
- }));
745
- case 2:
746
- case "end":
747
- return _context11.stop();
893
+ while (1) {
894
+ switch (_context11.prev = _context11.next) {
895
+ case 0:
896
+ contentSpaceAddress = _ref15.contentSpaceAddress;
897
+ return _context11.abrupt("return", this.DeployDependentContract({
898
+ contractAddress: contentSpaceAddress,
899
+ methodName: "createContentType",
900
+ args: [],
901
+ eventName: "CreateContentType",
902
+ eventValue: "contentTypeAddress"
903
+ }));
904
+
905
+ case 2:
906
+ case "end":
907
+ return _context11.stop();
908
+ }
748
909
  }
749
910
  }, _callee11, this);
750
911
  }));
912
+
751
913
  function DeployTypeContract(_x10) {
752
914
  return _DeployTypeContract.apply(this, arguments);
753
915
  }
916
+
754
917
  return DeployTypeContract;
755
918
  }()
756
919
  }, {
@@ -759,26 +922,31 @@ var EthClient = /*#__PURE__*/function () {
759
922
  var _DeployLibraryContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref16) {
760
923
  var contentSpaceAddress, kmsId, kmsAddress;
761
924
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
762
- while (1) switch (_context12.prev = _context12.next) {
763
- case 0:
764
- contentSpaceAddress = _ref16.contentSpaceAddress, kmsId = _ref16.kmsId;
765
- kmsAddress = Utils.HashToAddress(kmsId);
766
- return _context12.abrupt("return", this.DeployDependentContract({
767
- contractAddress: contentSpaceAddress,
768
- methodName: "createLibrary",
769
- args: [kmsAddress],
770
- eventName: "CreateLibrary",
771
- eventValue: "libraryAddress"
772
- }));
773
- case 3:
774
- case "end":
775
- return _context12.stop();
925
+ while (1) {
926
+ switch (_context12.prev = _context12.next) {
927
+ case 0:
928
+ contentSpaceAddress = _ref16.contentSpaceAddress, kmsId = _ref16.kmsId;
929
+ kmsAddress = Utils.HashToAddress(kmsId);
930
+ return _context12.abrupt("return", this.DeployDependentContract({
931
+ contractAddress: contentSpaceAddress,
932
+ methodName: "createLibrary",
933
+ args: [kmsAddress],
934
+ eventName: "CreateLibrary",
935
+ eventValue: "libraryAddress"
936
+ }));
937
+
938
+ case 3:
939
+ case "end":
940
+ return _context12.stop();
941
+ }
776
942
  }
777
943
  }, _callee12, this);
778
944
  }));
945
+
779
946
  function DeployLibraryContract(_x11) {
780
947
  return _DeployLibraryContract.apply(this, arguments);
781
948
  }
949
+
782
950
  return DeployLibraryContract;
783
951
  }()
784
952
  }, {
@@ -787,27 +955,32 @@ var EthClient = /*#__PURE__*/function () {
787
955
  var _DeployContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
788
956
  var contentLibraryAddress, typeAddress;
789
957
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
790
- while (1) switch (_context13.prev = _context13.next) {
791
- case 0:
792
- contentLibraryAddress = _ref17.contentLibraryAddress, typeAddress = _ref17.typeAddress;
793
- // If type is not specified, use null address
794
- typeAddress = typeAddress || Utils.nullAddress;
795
- return _context13.abrupt("return", this.DeployDependentContract({
796
- contractAddress: contentLibraryAddress,
797
- methodName: "createContent",
798
- args: [typeAddress],
799
- eventName: "ContentObjectCreated",
800
- eventValue: "contentAddress"
801
- }));
802
- case 3:
803
- case "end":
804
- return _context13.stop();
958
+ while (1) {
959
+ switch (_context13.prev = _context13.next) {
960
+ case 0:
961
+ contentLibraryAddress = _ref17.contentLibraryAddress, typeAddress = _ref17.typeAddress;
962
+ // If type is not specified, use null address
963
+ typeAddress = typeAddress || Utils.nullAddress;
964
+ return _context13.abrupt("return", this.DeployDependentContract({
965
+ contractAddress: contentLibraryAddress,
966
+ methodName: "createContent",
967
+ args: [typeAddress],
968
+ eventName: "ContentObjectCreated",
969
+ eventValue: "contentAddress"
970
+ }));
971
+
972
+ case 3:
973
+ case "end":
974
+ return _context13.stop();
975
+ }
805
976
  }
806
977
  }, _callee13, this);
807
978
  }));
979
+
808
980
  function DeployContentContract(_x12) {
809
981
  return _DeployContentContract.apply(this, arguments);
810
982
  }
983
+
811
984
  return DeployContentContract;
812
985
  }()
813
986
  }, {
@@ -816,27 +989,33 @@ var EthClient = /*#__PURE__*/function () {
816
989
  var _CommitContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
817
990
  var contentObjectAddress, versionHash;
818
991
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
819
- while (1) switch (_context14.prev = _context14.next) {
820
- case 0:
821
- contentObjectAddress = _ref18.contentObjectAddress, versionHash = _ref18.versionHash;
822
- _context14.next = 3;
823
- return this.CallContractMethodAndWait({
824
- contractAddress: contentObjectAddress,
825
- methodName: "commit",
826
- methodArgs: [versionHash],
827
- eventName: "CommitPending"
828
- });
829
- case 3:
830
- return _context14.abrupt("return", _context14.sent);
831
- case 4:
832
- case "end":
833
- return _context14.stop();
992
+ while (1) {
993
+ switch (_context14.prev = _context14.next) {
994
+ case 0:
995
+ contentObjectAddress = _ref18.contentObjectAddress, versionHash = _ref18.versionHash;
996
+ _context14.next = 3;
997
+ return this.CallContractMethodAndWait({
998
+ contractAddress: contentObjectAddress,
999
+ methodName: "commit",
1000
+ methodArgs: [versionHash],
1001
+ eventName: "CommitPending"
1002
+ });
1003
+
1004
+ case 3:
1005
+ return _context14.abrupt("return", _context14.sent);
1006
+
1007
+ case 4:
1008
+ case "end":
1009
+ return _context14.stop();
1010
+ }
834
1011
  }
835
1012
  }, _callee14, this);
836
1013
  }));
1014
+
837
1015
  function CommitContent(_x13) {
838
1016
  return _CommitContent.apply(this, arguments);
839
1017
  }
1018
+
840
1019
  return CommitContent;
841
1020
  }()
842
1021
  }, {
@@ -845,23 +1024,28 @@ var EthClient = /*#__PURE__*/function () {
845
1024
  var _EngageAccountLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
846
1025
  var contentSpaceAddress;
847
1026
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
848
- while (1) switch (_context15.prev = _context15.next) {
849
- case 0:
850
- contentSpaceAddress = _ref19.contentSpaceAddress;
851
- return _context15.abrupt("return", this.CallContractMethodAndWait({
852
- contractAddress: contentSpaceAddress,
853
- methodName: "engageAccountLibrary",
854
- args: []
855
- }));
856
- case 2:
857
- case "end":
858
- return _context15.stop();
1027
+ while (1) {
1028
+ switch (_context15.prev = _context15.next) {
1029
+ case 0:
1030
+ contentSpaceAddress = _ref19.contentSpaceAddress;
1031
+ return _context15.abrupt("return", this.CallContractMethodAndWait({
1032
+ contractAddress: contentSpaceAddress,
1033
+ methodName: "engageAccountLibrary",
1034
+ args: []
1035
+ }));
1036
+
1037
+ case 2:
1038
+ case "end":
1039
+ return _context15.stop();
1040
+ }
859
1041
  }
860
1042
  }, _callee15, this);
861
1043
  }));
1044
+
862
1045
  function EngageAccountLibrary(_x14) {
863
1046
  return _EngageAccountLibrary.apply(this, arguments);
864
1047
  }
1048
+
865
1049
  return EngageAccountLibrary;
866
1050
  }()
867
1051
  }, {
@@ -869,128 +1053,165 @@ var EthClient = /*#__PURE__*/function () {
869
1053
  value: function () {
870
1054
  var _SetCustomContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
871
1055
  var contentContractAddress, customContractAddress, _ref20$overrides, overrides;
1056
+
872
1057
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
873
- while (1) switch (_context16.prev = _context16.next) {
874
- case 0:
875
- contentContractAddress = _ref20.contentContractAddress, customContractAddress = _ref20.customContractAddress, _ref20$overrides = _ref20.overrides, overrides = _ref20$overrides === void 0 ? {} : _ref20$overrides;
876
- _context16.next = 3;
877
- return this.CallContractMethodAndWait({
878
- contractAddress: contentContractAddress,
879
- methodName: "setContentContractAddress",
880
- methodArgs: [customContractAddress],
881
- overrides: overrides
882
- });
883
- case 3:
884
- return _context16.abrupt("return", _context16.sent);
885
- case 4:
886
- case "end":
887
- return _context16.stop();
1058
+ while (1) {
1059
+ switch (_context16.prev = _context16.next) {
1060
+ case 0:
1061
+ contentContractAddress = _ref20.contentContractAddress, customContractAddress = _ref20.customContractAddress, _ref20$overrides = _ref20.overrides, overrides = _ref20$overrides === void 0 ? {} : _ref20$overrides;
1062
+ _context16.next = 3;
1063
+ return this.CallContractMethodAndWait({
1064
+ contractAddress: contentContractAddress,
1065
+ methodName: "setContentContractAddress",
1066
+ methodArgs: [customContractAddress],
1067
+ overrides: overrides
1068
+ });
1069
+
1070
+ case 3:
1071
+ return _context16.abrupt("return", _context16.sent);
1072
+
1073
+ case 4:
1074
+ case "end":
1075
+ return _context16.stop();
1076
+ }
888
1077
  }
889
1078
  }, _callee16, this);
890
1079
  }));
1080
+
891
1081
  function SetCustomContentContract(_x15) {
892
1082
  return _SetCustomContentContract.apply(this, arguments);
893
1083
  }
1084
+
894
1085
  return SetCustomContentContract;
895
1086
  }() // Get all logs for the specified contract in the specified range
1087
+
896
1088
  }, {
897
1089
  key: "ContractEvents",
898
1090
  value: function () {
899
1091
  var _ContractEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
900
1092
  var _this4 = this;
1093
+
901
1094
  var contractAddress, abi, _ref21$fromBlock, fromBlock, toBlock, topics, _ref21$includeTransac, includeTransaction, filter, contractLogs, blocks;
1095
+
902
1096
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
903
- while (1) switch (_context18.prev = _context18.next) {
904
- case 0:
905
- contractAddress = _ref21.contractAddress, abi = _ref21.abi, _ref21$fromBlock = _ref21.fromBlock, fromBlock = _ref21$fromBlock === void 0 ? 0 : _ref21$fromBlock, toBlock = _ref21.toBlock, topics = _ref21.topics, _ref21$includeTransac = _ref21.includeTransaction, includeTransaction = _ref21$includeTransac === void 0 ? false : _ref21$includeTransac;
906
- filter = {
907
- address: contractAddress,
908
- fromBlock: fromBlock,
909
- toBlock: toBlock
910
- };
911
- if (topics) {
912
- filter.topics = topics;
913
- }
914
- _context18.next = 5;
915
- return this.MakeProviderCall({
916
- methodName: "getLogs",
917
- args: [filter]
918
- });
919
- case 5:
920
- _context18.t0 = _context18.sent;
921
- if (_context18.t0) {
922
- _context18.next = 8;
923
- break;
924
- }
925
- _context18.t0 = [];
926
- case 8:
927
- contractLogs = _context18.t0;
928
- if (Array.isArray(contractLogs)) {
929
- _context18.next = 11;
930
- break;
931
- }
932
- return _context18.abrupt("return", []);
933
- case 11:
934
- blocks = {};
935
- _context18.next = 14;
936
- return Utils.LimitedMap(5, contractLogs, /*#__PURE__*/function () {
937
- var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(log) {
938
- var eventInterface, parsedLog;
939
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
940
- while (1) switch (_context17.prev = _context17.next) {
941
- case 0:
942
- eventInterface = new Ethers.utils.Interface(abi);
943
- parsedLog = _objectSpread(_objectSpread({}, log), eventInterface.parseLog(log));
944
- if (!includeTransaction) {
945
- _context17.next = 9;
946
- break;
1097
+ while (1) {
1098
+ switch (_context18.prev = _context18.next) {
1099
+ case 0:
1100
+ contractAddress = _ref21.contractAddress, abi = _ref21.abi, _ref21$fromBlock = _ref21.fromBlock, fromBlock = _ref21$fromBlock === void 0 ? 0 : _ref21$fromBlock, toBlock = _ref21.toBlock, topics = _ref21.topics, _ref21$includeTransac = _ref21.includeTransaction, includeTransaction = _ref21$includeTransac === void 0 ? false : _ref21$includeTransac;
1101
+ filter = {
1102
+ address: contractAddress,
1103
+ fromBlock: fromBlock,
1104
+ toBlock: toBlock
1105
+ };
1106
+
1107
+ if (topics) {
1108
+ filter.topics = topics;
1109
+ }
1110
+
1111
+ _context18.next = 5;
1112
+ return this.MakeProviderCall({
1113
+ methodName: "getLogs",
1114
+ args: [filter]
1115
+ });
1116
+
1117
+ case 5:
1118
+ _context18.t0 = _context18.sent;
1119
+
1120
+ if (_context18.t0) {
1121
+ _context18.next = 8;
1122
+ break;
1123
+ }
1124
+
1125
+ _context18.t0 = [];
1126
+
1127
+ case 8:
1128
+ contractLogs = _context18.t0;
1129
+
1130
+ if (Array.isArray(contractLogs)) {
1131
+ _context18.next = 11;
1132
+ break;
1133
+ }
1134
+
1135
+ return _context18.abrupt("return", []);
1136
+
1137
+ case 11:
1138
+ blocks = {};
1139
+ _context18.next = 14;
1140
+ return Utils.LimitedMap(5, contractLogs, /*#__PURE__*/function () {
1141
+ var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(log) {
1142
+ var eventInterface, parsedLog;
1143
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1144
+ while (1) {
1145
+ switch (_context17.prev = _context17.next) {
1146
+ case 0:
1147
+ eventInterface = new Ethers.utils.Interface(abi);
1148
+ parsedLog = _objectSpread(_objectSpread({}, log), eventInterface.parseLog(log));
1149
+
1150
+ if (!includeTransaction) {
1151
+ _context17.next = 9;
1152
+ break;
1153
+ }
1154
+
1155
+ _context17.t0 = _objectSpread;
1156
+ _context17.t1 = _objectSpread({}, parsedLog);
1157
+ _context17.next = 7;
1158
+ return _this4.MakeProviderCall({
1159
+ methodName: "getTransaction",
1160
+ args: [log.transactionHash]
1161
+ });
1162
+
1163
+ case 7:
1164
+ _context17.t2 = _context17.sent;
1165
+ parsedLog = (0, _context17.t0)(_context17.t1, _context17.t2);
1166
+
1167
+ case 9:
1168
+ blocks[log.blockNumber] = [parsedLog].concat(blocks[log.blockNumber] || []);
1169
+
1170
+ case 10:
1171
+ case "end":
1172
+ return _context17.stop();
947
1173
  }
948
- _context17.t0 = _objectSpread;
949
- _context17.t1 = _objectSpread({}, parsedLog);
950
- _context17.next = 7;
951
- return _this4.MakeProviderCall({
952
- methodName: "getTransaction",
953
- args: [log.transactionHash]
954
- });
955
- case 7:
956
- _context17.t2 = _context17.sent;
957
- parsedLog = (0, _context17.t0)(_context17.t1, _context17.t2);
958
- case 9:
959
- blocks[log.blockNumber] = [parsedLog].concat(blocks[log.blockNumber] || []);
960
- case 10:
961
- case "end":
962
- return _context17.stop();
963
- }
964
- }, _callee17);
1174
+ }
1175
+ }, _callee17);
1176
+ }));
1177
+
1178
+ return function (_x17) {
1179
+ return _ref22.apply(this, arguments);
1180
+ };
1181
+ }());
1182
+
1183
+ case 14:
1184
+ return _context18.abrupt("return", Object.values(blocks).sort(function (a, b) {
1185
+ return a[0].blockNumber < b[0].blockNumber ? 1 : -1;
965
1186
  }));
966
- return function (_x17) {
967
- return _ref22.apply(this, arguments);
968
- };
969
- }());
970
- case 14:
971
- return _context18.abrupt("return", Object.values(blocks).sort(function (a, b) {
972
- return a[0].blockNumber < b[0].blockNumber ? 1 : -1;
973
- }));
974
- case 15:
975
- case "end":
976
- return _context18.stop();
1187
+
1188
+ case 15:
1189
+ case "end":
1190
+ return _context18.stop();
1191
+ }
977
1192
  }
978
1193
  }, _callee18, this);
979
1194
  }));
1195
+
980
1196
  function ContractEvents(_x16) {
981
1197
  return _ContractEvents.apply(this, arguments);
982
1198
  }
1199
+
983
1200
  return ContractEvents;
984
1201
  }() // Look up the log topic and see if it is known. If so, parse it and inject it into the log
1202
+
985
1203
  }, {
986
1204
  key: "ParseUnknownLog",
987
1205
  value: function ParseUnknownLog(_ref23) {
988
1206
  var log = _ref23.log;
1207
+
989
1208
  if (log.topics && log.topics.length > 0) {
990
1209
  var topicHash = log.topics[0];
991
1210
  var topicInfo = Topics[topicHash];
1211
+
992
1212
  if (topicInfo) {
993
1213
  var eventInterface = new Ethers.utils.Interface(topicInfo.abi);
1214
+
994
1215
  if (eventInterface) {
995
1216
  log = _objectSpread(_objectSpread(_objectSpread({}, log), eventInterface.parseLog(log)), {}, {
996
1217
  contract: topicInfo.contract
@@ -998,157 +1219,191 @@ var EthClient = /*#__PURE__*/function () {
998
1219
  }
999
1220
  }
1000
1221
  }
1001
- return log;
1002
- }
1003
1222
 
1004
- // Get logs for all blocks in the specified range
1223
+ return log;
1224
+ } // Get logs for all blocks in the specified range
1005
1225
  // Returns a list, sorted in descending block order, with each entry containing all logs or transactions in that block
1226
+
1006
1227
  }, {
1007
1228
  key: "Events",
1008
1229
  value: function () {
1009
1230
  var _Events = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref24) {
1010
1231
  var _this5 = this;
1232
+
1011
1233
  var toBlock, fromBlock, _ref24$includeTransac, includeTransaction, logs, i, newLogs, blocks, output;
1234
+
1012
1235
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1013
- while (1) switch (_context21.prev = _context21.next) {
1014
- case 0:
1015
- toBlock = _ref24.toBlock, fromBlock = _ref24.fromBlock, _ref24$includeTransac = _ref24.includeTransaction, includeTransaction = _ref24$includeTransac === void 0 ? false : _ref24$includeTransac;
1016
- // Pull logs in batches of 100
1017
- logs = [];
1018
- i = fromBlock;
1019
- case 3:
1020
- if (!(i < toBlock)) {
1021
- _context21.next = 11;
1236
+ while (1) {
1237
+ switch (_context21.prev = _context21.next) {
1238
+ case 0:
1239
+ toBlock = _ref24.toBlock, fromBlock = _ref24.fromBlock, _ref24$includeTransac = _ref24.includeTransaction, includeTransaction = _ref24$includeTransac === void 0 ? false : _ref24$includeTransac;
1240
+ // Pull logs in batches of 100
1241
+ logs = [];
1242
+ i = fromBlock;
1243
+
1244
+ case 3:
1245
+ if (!(i < toBlock)) {
1246
+ _context21.next = 11;
1247
+ break;
1248
+ }
1249
+
1250
+ _context21.next = 6;
1251
+ return this.MakeProviderCall({
1252
+ methodName: "getLogs",
1253
+ args: [{
1254
+ fromBlock: i,
1255
+ toBlock: Math.min(toBlock, i + 100)
1256
+ }]
1257
+ });
1258
+
1259
+ case 6:
1260
+ newLogs = _context21.sent;
1261
+ logs = logs.concat(newLogs || []);
1262
+
1263
+ case 8:
1264
+ i += 101;
1265
+ _context21.next = 3;
1022
1266
  break;
1023
- }
1024
- _context21.next = 6;
1025
- return this.MakeProviderCall({
1026
- methodName: "getLogs",
1027
- args: [{
1028
- fromBlock: i,
1029
- toBlock: Math.min(toBlock, i + 100)
1030
- }]
1031
- });
1032
- case 6:
1033
- newLogs = _context21.sent;
1034
- logs = logs.concat(newLogs || []);
1035
- case 8:
1036
- i += 101;
1037
- _context21.next = 3;
1038
- break;
1039
- case 11:
1040
- // Group logs by blocknumber
1041
- blocks = {};
1042
- logs.forEach(function (log) {
1043
- blocks[log.blockNumber] = [_this5.ParseUnknownLog({
1044
- log: log
1045
- })].concat(blocks[log.blockNumber] || []);
1046
- });
1047
- output = [];
1048
- _context21.next = 16;
1049
- return Utils.LimitedMap(3, _toConsumableArray(Array(toBlock - fromBlock + 1).keys()), /*#__PURE__*/function () {
1050
- var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(i) {
1051
- var blockNumber, blockInfo, transactionInfo;
1052
- return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1053
- while (1) switch (_context20.prev = _context20.next) {
1054
- case 0:
1055
- blockNumber = toBlock - i;
1056
- blockInfo = blocks[blockNumber];
1057
- if (blockInfo) {
1058
- _context20.next = 8;
1059
- break;
1060
- }
1061
- _context20.next = 5;
1062
- return _this5.MakeProviderCall({
1063
- methodName: "getBlock",
1064
- args: [blockNumber]
1065
- });
1066
- case 5:
1067
- blockInfo = _context20.sent;
1068
- blockInfo = blockInfo.transactions.map(function (transactionHash) {
1069
- return _objectSpread(_objectSpread({
1070
- blockNumber: blockInfo.number,
1071
- blockHash: blockInfo.hash
1072
- }, blockInfo), {}, {
1073
- transactionHash: transactionHash
1074
- });
1075
- });
1076
- blocks[blockNumber] = blockInfo;
1077
- case 8:
1078
- if (!includeTransaction) {
1079
- _context20.next = 13;
1080
- break;
1081
- }
1082
- transactionInfo = {};
1083
- _context20.next = 12;
1084
- return Promise.all(blockInfo.map( /*#__PURE__*/function () {
1085
- var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(block) {
1086
- return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1087
- while (1) switch (_context19.prev = _context19.next) {
1088
- case 0:
1089
- if (transactionInfo[block.transactionHash]) {
1090
- _context19.next = 12;
1091
- break;
1267
+
1268
+ case 11:
1269
+ // Group logs by blocknumber
1270
+ blocks = {};
1271
+ logs.forEach(function (log) {
1272
+ blocks[log.blockNumber] = [_this5.ParseUnknownLog({
1273
+ log: log
1274
+ })].concat(blocks[log.blockNumber] || []);
1275
+ });
1276
+ output = [];
1277
+ _context21.next = 16;
1278
+ return Utils.LimitedMap(3, _toConsumableArray(Array(toBlock - fromBlock + 1).keys()), /*#__PURE__*/function () {
1279
+ var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(i) {
1280
+ var blockNumber, blockInfo, transactionInfo;
1281
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1282
+ while (1) {
1283
+ switch (_context20.prev = _context20.next) {
1284
+ case 0:
1285
+ blockNumber = toBlock - i;
1286
+ blockInfo = blocks[blockNumber];
1287
+
1288
+ if (blockInfo) {
1289
+ _context20.next = 8;
1290
+ break;
1291
+ }
1292
+
1293
+ _context20.next = 5;
1294
+ return _this5.MakeProviderCall({
1295
+ methodName: "getBlock",
1296
+ args: [blockNumber]
1297
+ });
1298
+
1299
+ case 5:
1300
+ blockInfo = _context20.sent;
1301
+ blockInfo = blockInfo.transactions.map(function (transactionHash) {
1302
+ return _objectSpread(_objectSpread({
1303
+ blockNumber: blockInfo.number,
1304
+ blockHash: blockInfo.hash
1305
+ }, blockInfo), {}, {
1306
+ transactionHash: transactionHash
1307
+ });
1308
+ });
1309
+ blocks[blockNumber] = blockInfo;
1310
+
1311
+ case 8:
1312
+ if (!includeTransaction) {
1313
+ _context20.next = 13;
1314
+ break;
1315
+ }
1316
+
1317
+ transactionInfo = {};
1318
+ _context20.next = 12;
1319
+ return Promise.all(blockInfo.map( /*#__PURE__*/function () {
1320
+ var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(block) {
1321
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1322
+ while (1) {
1323
+ switch (_context19.prev = _context19.next) {
1324
+ case 0:
1325
+ if (transactionInfo[block.transactionHash]) {
1326
+ _context19.next = 12;
1327
+ break;
1328
+ }
1329
+
1330
+ _context19.t0 = _objectSpread;
1331
+ _context19.t1 = _objectSpread;
1332
+ _context19.t2 = {};
1333
+ _context19.next = 6;
1334
+ return _this5.MakeProviderCall({
1335
+ methodName: "getTransaction",
1336
+ args: [block.transactionHash]
1337
+ });
1338
+
1339
+ case 6:
1340
+ _context19.t3 = _context19.sent;
1341
+ _context19.t4 = (0, _context19.t1)(_context19.t2, _context19.t3);
1342
+ _context19.next = 10;
1343
+ return _this5.MakeProviderCall({
1344
+ methodName: "getTransactionReceipt",
1345
+ args: [block.transactionHash]
1346
+ });
1347
+
1348
+ case 10:
1349
+ _context19.t5 = _context19.sent;
1350
+ transactionInfo[block.transactionHash] = (0, _context19.t0)(_context19.t4, _context19.t5);
1351
+
1352
+ case 12:
1353
+ return _context19.abrupt("return", _objectSpread(_objectSpread({}, block), transactionInfo[block.transactionHash]));
1354
+
1355
+ case 13:
1356
+ case "end":
1357
+ return _context19.stop();
1358
+ }
1092
1359
  }
1093
- _context19.t0 = _objectSpread;
1094
- _context19.t1 = _objectSpread;
1095
- _context19.t2 = {};
1096
- _context19.next = 6;
1097
- return _this5.MakeProviderCall({
1098
- methodName: "getTransaction",
1099
- args: [block.transactionHash]
1100
- });
1101
- case 6:
1102
- _context19.t3 = _context19.sent;
1103
- _context19.t4 = (0, _context19.t1)(_context19.t2, _context19.t3);
1104
- _context19.next = 10;
1105
- return _this5.MakeProviderCall({
1106
- methodName: "getTransactionReceipt",
1107
- args: [block.transactionHash]
1108
- });
1109
- case 10:
1110
- _context19.t5 = _context19.sent;
1111
- transactionInfo[block.transactionHash] = (0, _context19.t0)(_context19.t4, _context19.t5);
1112
- case 12:
1113
- return _context19.abrupt("return", _objectSpread(_objectSpread({}, block), transactionInfo[block.transactionHash]));
1114
- case 13:
1115
- case "end":
1116
- return _context19.stop();
1117
- }
1118
- }, _callee19);
1119
- }));
1120
- return function (_x20) {
1121
- return _ref26.apply(this, arguments);
1122
- };
1123
- }()));
1124
- case 12:
1125
- blocks[blockNumber] = _context20.sent;
1126
- case 13:
1127
- output.push(blocks[blockNumber]);
1128
- case 14:
1129
- case "end":
1130
- return _context20.stop();
1131
- }
1132
- }, _callee20);
1133
- }));
1134
- return function (_x19) {
1135
- return _ref25.apply(this, arguments);
1136
- };
1137
- }());
1138
- case 16:
1139
- return _context21.abrupt("return", output);
1140
- case 17:
1141
- case "end":
1142
- return _context21.stop();
1360
+ }, _callee19);
1361
+ }));
1362
+
1363
+ return function (_x20) {
1364
+ return _ref26.apply(this, arguments);
1365
+ };
1366
+ }()));
1367
+
1368
+ case 12:
1369
+ blocks[blockNumber] = _context20.sent;
1370
+
1371
+ case 13:
1372
+ output.push(blocks[blockNumber]);
1373
+
1374
+ case 14:
1375
+ case "end":
1376
+ return _context20.stop();
1377
+ }
1378
+ }
1379
+ }, _callee20);
1380
+ }));
1381
+
1382
+ return function (_x19) {
1383
+ return _ref25.apply(this, arguments);
1384
+ };
1385
+ }());
1386
+
1387
+ case 16:
1388
+ return _context21.abrupt("return", output);
1389
+
1390
+ case 17:
1391
+ case "end":
1392
+ return _context21.stop();
1393
+ }
1143
1394
  }
1144
1395
  }, _callee21, this);
1145
1396
  }));
1397
+
1146
1398
  function Events(_x18) {
1147
1399
  return _Events.apply(this, arguments);
1148
1400
  }
1401
+
1149
1402
  return Events;
1150
1403
  }()
1151
1404
  }]);
1405
+
1152
1406
  return EthClient;
1153
1407
  }();
1408
+
1154
1409
  module.exports = EthClient;