@eluvio/elv-client-js 4.0.11 → 4.0.13

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 (111) hide show
  1. package/dist/.keep +0 -0
  2. package/dist/ElvClient-min.js +11 -10
  3. package/dist/ElvClient-node-min.js +11 -10
  4. package/dist/ElvFrameClient-min.js +11 -10
  5. package/dist/ElvPermissionsClient-min.js +10 -9
  6. package/dist/ElvWalletClient-min.js +10 -9
  7. package/dist/ElvWalletClient-node-min.js +10 -9
  8. package/dist/src/AuthorizationClient.js +1555 -2076
  9. package/dist/src/ContentObjectVerification.js +134 -185
  10. package/dist/src/Crypto.js +224 -319
  11. package/dist/src/ElvClient.js +822 -1114
  12. package/dist/src/ElvWallet.js +64 -106
  13. package/dist/src/EthClient.js +719 -974
  14. package/dist/src/FrameClient.js +223 -319
  15. package/dist/src/HttpClient.js +117 -156
  16. package/dist/src/Id.js +1 -6
  17. package/dist/src/LogMessage.js +4 -8
  18. package/dist/src/PermissionsClient.js +973 -1271
  19. package/dist/src/RemoteSigner.js +161 -232
  20. package/dist/src/UserProfileClient.js +781 -1038
  21. package/dist/src/Utils.js +159 -299
  22. package/dist/src/Validation.js +2 -17
  23. package/dist/src/client/ABRPublishing.js +828 -958
  24. package/dist/src/client/AccessGroups.js +849 -1095
  25. package/dist/src/client/ContentAccess.js +3323 -4195
  26. package/dist/src/client/ContentManagement.js +1818 -2290
  27. package/dist/src/client/Contracts.js +468 -614
  28. package/dist/src/client/Files.js +1506 -1846
  29. package/dist/src/client/NFT.js +94 -116
  30. package/dist/src/client/NTP.js +326 -425
  31. package/dist/src/index.js +2 -5
  32. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  33. package/dist/src/walletClient/Configuration.js +5 -3
  34. package/dist/src/walletClient/Notifications.js +98 -127
  35. package/dist/src/walletClient/Profile.js +184 -246
  36. package/dist/src/walletClient/Utils.js +76 -122
  37. package/dist/src/walletClient/index.js +1171 -1496
  38. package/package.json +4 -21
  39. package/src/FrameClient.js +1 -0
  40. package/src/HttpClient.js +4 -2
  41. package/src/client/ABRPublishing.js +126 -105
  42. package/src/client/ContentAccess.js +1 -0
  43. package/src/client/ContentManagement.js +4 -2
  44. package/src/walletClient/Configuration.js +3 -2
  45. package/dist/AccessClient-min.js +0 -54
  46. package/dist/AccessClient-node-min.js +0 -74
  47. package/dist/src/AccessClient.js +0 -798
  48. package/dist/src/LimitedMap.js +0 -120
  49. package/dist/src/client/Access.js +0 -1
  50. package/dist/src/client/Management.js +0 -1606
  51. package/dist/src/contracts/AccessIndexor.js +0 -831
  52. package/dist/src/contracts/Accessible.js +0 -31
  53. package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
  54. package/dist/src/contracts/AdmgrCampaign.js +0 -648
  55. package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
  56. package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
  57. package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
  58. package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
  59. package/dist/src/contracts/AvailsDelivery.js +0 -535
  60. package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
  61. package/dist/src/contracts/BaseAccessWallet.js +0 -1575
  62. package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
  63. package/dist/src/contracts/BaseContent.js +0 -1104
  64. package/dist/src/contracts/BaseContentFactory.js +0 -99
  65. package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
  66. package/dist/src/contracts/BaseContentSpace.js +0 -1346
  67. package/dist/src/contracts/BaseContentType.js +0 -353
  68. package/dist/src/contracts/BaseFactory.js +0 -107
  69. package/dist/src/contracts/BaseGroupFactory.js +0 -93
  70. package/dist/src/contracts/BaseLibrary.js +0 -1035
  71. package/dist/src/contracts/BaseLibraryFactory.js +0 -96
  72. package/dist/src/contracts/Certifyer.js +0 -87
  73. package/dist/src/contracts/Container.js +0 -543
  74. package/dist/src/contracts/Content.js +0 -432
  75. package/dist/src/contracts/Editable.js +0 -295
  76. package/dist/src/contracts/FactorySpace.js +0 -57
  77. package/dist/src/contracts/KmsSpace.js +0 -52
  78. package/dist/src/contracts/LvProvider.js +0 -512
  79. package/dist/src/contracts/LvRecordableStream.js +0 -1026
  80. package/dist/src/contracts/LvRecording.js +0 -627
  81. package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
  82. package/dist/src/contracts/MetaObject.js +0 -110
  83. package/dist/src/contracts/Node.js +0 -167
  84. package/dist/src/contracts/NodeSpace.js +0 -18
  85. package/dist/src/contracts/NodeSpaceImpl.js +0 -273
  86. package/dist/src/contracts/Ownable.js +0 -87
  87. package/dist/src/contracts/PaymentService.js +0 -616
  88. package/dist/src/contracts/Precompile.js +0 -15
  89. package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
  90. package/dist/src/contracts/SampleContentAdvertising.js +0 -444
  91. package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
  92. package/dist/src/contracts/SampleContentLicensing.js +0 -618
  93. package/dist/src/contracts/SampleContentSigned.js +0 -447
  94. package/dist/src/contracts/SampleInstance.js +0 -438
  95. package/dist/src/contracts/SampleInstanceFactory.js +0 -451
  96. package/dist/src/contracts/Transactable.js +0 -82
  97. package/dist/src/contracts/UserSpace.js +0 -18
  98. package/dist/src/contracts/UserSpaceImpl.js +0 -43
  99. package/dist/src/contracts/Utils.js +0 -18
  100. package/dist/src/contracts/Verifier.js +0 -53
  101. package/dist/src/contracts/strings.js +0 -4
  102. package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
  103. package/dist/src/contracts/v2/FactorySpace.js +0 -57
  104. package/dist/src/contracts/v2/KmsSpace.js +0 -52
  105. package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
  106. package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
  107. package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
  108. package/dist/src/marketplaceClient/Configuration.js +0 -29
  109. package/dist/src/marketplaceClient/Utils.js +0 -304
  110. package/dist/src/marketplaceClient/index.js +0 -1553
  111. package/utilities/ListAccessGroups.js +0 -34
@@ -1,32 +1,20 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
-
3
2
  var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
3
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
6
-
7
4
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
8
-
9
5
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
10
-
11
6
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
12
-
13
7
  var _createClass = require("@babel/runtime/helpers/createClass");
14
-
15
8
  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
-
17
9
  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); }
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
-
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; }
21
11
  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
-
23
12
  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
-
25
13
  // NOTE: Querying Ethereum requires CORS enabled
26
14
  // Use --rpccorsdomain "http[s]://hostname:port" or set up proxy
27
15
  var Ethers = require("ethers");
28
-
29
16
  var HttpClient = require("./HttpClient");
17
+
30
18
  /*
31
19
  // -- Contract javascript files built using build/BuildContracts.js
32
20
  const ContentSpaceContract = require("./contracts/BaseContentSpace");
@@ -34,46 +22,41 @@ const ContentLibraryContract = require("./contracts/BaseLibrary");
34
22
  const ContentContract = require("./contracts/BaseContent");
35
23
  */
36
24
 
37
-
38
25
  var AccessibleContract = require("./contracts/v3/Accessible");
39
-
40
26
  var Utils = require("./Utils");
41
-
42
27
  var _require = require("./LogMessage"),
43
- LogMessage = _require.LogMessage;
44
-
28
+ LogMessage = _require.LogMessage;
45
29
  var Topics = require("./events/Topics");
46
-
47
30
  var EthClient = /*#__PURE__*/function () {
48
31
  "use strict";
49
32
 
50
33
  function EthClient(_ref) {
51
34
  var client = _ref.client,
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
-
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;
58
40
  _classCallCheck(this, EthClient);
59
-
60
41
  this.client = client;
61
42
  this.networkId = networkId;
62
43
  this.ethereumURIs = uris;
63
44
  this.ethereumURIIndex = 0;
64
45
  this.locked = false;
65
- this.debug = debug; // convert to milliseconds
66
-
46
+ this.debug = debug;
47
+ // convert to milliseconds
67
48
  this.timeout = Math.floor(timeout * 1000);
68
49
  this.cachedContracts = {};
69
- this.contractNames = {}; // HTTP client for making misc calls to elv-master
50
+ this.contractNames = {};
70
51
 
52
+ // HTTP client for making misc calls to elv-master
71
53
  this.HttpClient = new HttpClient({
72
54
  uris: this.ethereumURIs,
73
55
  debug: this.debug
74
- }); //Ethers.errors.setLogLevel("error");
75
- }
56
+ });
76
57
 
58
+ //Ethers.errors.setLogLevel("error");
59
+ }
77
60
  _createClass(EthClient, [{
78
61
  key: "Log",
79
62
  value: function Log(message) {
@@ -94,27 +77,24 @@ var EthClient = /*#__PURE__*/function () {
94
77
  key: "Provider",
95
78
  value: function Provider() {
96
79
  if (!this.provider) {
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
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
98
83
  // data every time a contract is initialized in the client (often). Ethers.js just checks that the code isn't == "0x", so
99
84
  // we can give it some dummy string instead and assume the contract is fine
100
-
101
85
  this.provider.getCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
102
86
  return _regeneratorRuntime.wrap(function _callee$(_context) {
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
- }
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();
112
93
  }
113
94
  }, _callee);
114
95
  }));
115
96
  this.provider.pollingInterval = 500;
116
97
  }
117
-
118
98
  return this.provider;
119
99
  }
120
100
  }, {
@@ -122,119 +102,96 @@ var EthClient = /*#__PURE__*/function () {
122
102
  value: function () {
123
103
  var _ContractName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(contractAddress) {
124
104
  var _this = this;
125
-
126
105
  var full,
127
- versionContract,
128
- version,
129
- _args3 = arguments;
106
+ versionContract,
107
+ version,
108
+ _args3 = arguments;
130
109
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
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
- }
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();
202
166
  }
203
167
  }, _callee3, this);
204
168
  }));
205
-
206
169
  function ContractName(_x) {
207
170
  return _ContractName.apply(this, arguments);
208
171
  }
209
-
210
172
  return ContractName;
211
173
  }()
212
174
  }, {
213
175
  key: "Contract",
214
176
  value: function Contract(_ref4) {
215
177
  var contractAddress = _ref4.contractAddress,
216
- abi = _ref4.abi,
217
- cacheContract = _ref4.cacheContract,
218
- overrideCachedContract = _ref4.overrideCachedContract;
178
+ abi = _ref4.abi,
179
+ cacheContract = _ref4.cacheContract,
180
+ overrideCachedContract = _ref4.overrideCachedContract;
219
181
  var contract;
220
-
221
182
  if (!overrideCachedContract) {
222
183
  contract = this.cachedContracts[contractAddress];
223
184
  }
224
-
225
185
  if (!abi) {
226
186
  throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
227
187
  }
228
-
229
188
  if (!contract) {
230
189
  contract = new Ethers.Contract(contractAddress, abi, this.Provider());
231
190
  contract = contract.connect(this.client.signer);
232
-
233
191
  if (cacheContract) {
234
192
  this.cachedContracts[contractAddress] = contract;
235
193
  }
236
194
  }
237
-
238
195
  return contract;
239
196
  }
240
197
  }, {
@@ -242,84 +199,66 @@ var EthClient = /*#__PURE__*/function () {
242
199
  value: function () {
243
200
  var _MakeProviderCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
244
201
  var methodName, _ref5$args, args, _ref5$attempts, attempts, provider;
245
-
246
202
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
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
- }
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();
291
238
  }
292
239
  }, _callee4, this, [[1, 11]]);
293
240
  }));
294
-
295
241
  function MakeProviderCall(_x3) {
296
242
  return _MakeProviderCall.apply(this, arguments);
297
243
  }
298
-
299
244
  return MakeProviderCall;
300
- }()
301
- /* General contract management */
302
-
245
+ }() /* General contract management */
303
246
  }, {
304
247
  key: "FormatContractArgument",
305
248
  value: function FormatContractArgument(_ref6) {
306
249
  var _this2 = this;
307
-
308
250
  var type = _ref6.type,
309
- value = _ref6.value;
310
-
251
+ value = _ref6.value;
311
252
  // For array types, parse into array if necessary, then format each value.
312
253
  if (type.endsWith("[]")) {
313
254
  if (typeof value === "string") {
314
255
  if (value.trim() === "") {
315
256
  return [];
316
257
  }
317
-
318
258
  value = value.split(",").map(function (s) {
319
259
  return s.trim();
320
260
  });
321
261
  }
322
-
323
262
  var singleType = type.replace("[]", "");
324
263
  return value.map(function (element) {
325
264
  return _this2.FormatContractArgument({
@@ -328,48 +267,44 @@ var EthClient = /*#__PURE__*/function () {
328
267
  });
329
268
  });
330
269
  }
331
-
332
270
  switch (type.toLowerCase()) {
333
271
  case "bytes32":
334
272
  return Ethers.utils.formatBytes32String(value);
335
-
336
273
  case "bytes":
337
274
  return Ethers.utils.toUtf8Bytes(value);
338
-
339
275
  case "address":
340
276
  return Utils.FormatAddress(value);
341
-
342
277
  default:
343
278
  return value;
344
279
  }
345
- } // Apply any necessary formatting to contract arguments based on the ABI spec
280
+ }
346
281
 
282
+ // Apply any necessary formatting to contract arguments based on the ABI spec
347
283
  }, {
348
284
  key: "FormatContractArguments",
349
285
  value: function FormatContractArguments(_ref7) {
350
286
  var _this3 = this;
351
-
352
287
  var abi = _ref7.abi,
353
- methodName = _ref7.methodName,
354
- args = _ref7.args;
288
+ methodName = _ref7.methodName,
289
+ args = _ref7.args;
355
290
  var method = abi.find(function (func) {
356
291
  // Constructor has type=constructor but no name
357
292
  return func.name === methodName || func.type === methodName;
358
293
  });
359
-
360
294
  if (method === undefined) {
361
295
  throw Error("Unknown method: " + methodName);
362
- } // Format each argument
363
-
296
+ }
364
297
 
298
+ // Format each argument
365
299
  return args.map(function (arg, i) {
366
300
  return _this3.FormatContractArgument({
367
301
  type: method.inputs[i].type,
368
302
  value: arg
369
303
  });
370
304
  });
371
- } // Validate signer is set
305
+ }
372
306
 
307
+ // Validate signer is set
373
308
  }, {
374
309
  key: "ValidateSigner",
375
310
  value: function ValidateSigner(signer) {
@@ -382,221 +317,177 @@ var EthClient = /*#__PURE__*/function () {
382
317
  value: function () {
383
318
  var _DeployContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
384
319
  var abi, bytecode, _ref8$constructorArgs, constructorArgs, _ref8$overrides, overrides, provider, signer, contractFactory, contract;
385
-
386
320
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
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
- }
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();
416
345
  }
417
346
  }, _callee5, this);
418
347
  }));
419
-
420
348
  function DeployContract(_x4) {
421
349
  return _DeployContract.apply(this, arguments);
422
350
  }
423
-
424
351
  return DeployContract;
425
352
  }() // Accepts either contract object or contract address
426
-
427
353
  }, {
428
354
  key: "CallContractMethod",
429
355
  value: function () {
430
356
  var _CallContractMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref9) {
431
357
  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
-
433
358
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
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,
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({
455
384
  abi: abi,
456
- cacheContract: cacheContract,
457
- overrideCachedContract: overrideCachedContract
458
- });
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);
385
+ methodName: methodName,
386
+ args: methodArgs
501
387
  });
502
-
503
- case 17:
504
- _context6.next = 14;
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;
505
395
  break;
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;
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;
528
405
  break;
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;
406
+ }
407
+ case 14:
408
+ if (!this.locked) {
409
+ _context6.next = 19;
550
410
  break;
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));
559
- _context6.next = 47;
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;
560
427
  break;
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;
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;
573
442
  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
- }
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;
458
+ 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")) {
465
+ _context6.next = 47;
466
+ 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();
592
485
  }
593
486
  }, _callee6, this, [[20,, 50, 53], [23, 30]]);
594
487
  }));
595
-
596
488
  function CallContractMethod(_x5) {
597
489
  return _CallContractMethod.apply(this, arguments);
598
490
  }
599
-
600
491
  return CallContractMethod;
601
492
  }()
602
493
  }, {
@@ -604,118 +495,96 @@ var EthClient = /*#__PURE__*/function () {
604
495
  value: function () {
605
496
  var _CallContractMethodAndWait = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
606
497
  var contractAddress, abi, methodName, methodArgs, value, timeout, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract, contract, createMethodCall, interval, elapsed, methodEvent;
607
-
608
498
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
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;
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;
694
505
  break;
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
- }
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;
574
+ 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();
711
582
  }
712
583
  }, _callee7, this);
713
584
  }));
714
-
715
585
  function CallContractMethodAndWait(_x6) {
716
586
  return _CallContractMethodAndWait.apply(this, arguments);
717
587
  }
718
-
719
588
  return CallContractMethodAndWait;
720
589
  }()
721
590
  }, {
@@ -724,61 +593,52 @@ var EthClient = /*#__PURE__*/function () {
724
593
  var _AwaitEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref11) {
725
594
  var contractAddress, abi, eventName, contract;
726
595
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
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
- });
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);
741
608
  });
742
-
743
- case 4:
744
- return _context8.abrupt("return", _context8.sent);
745
-
746
- case 5:
747
- case "end":
748
- return _context8.stop();
749
- }
609
+ });
610
+ case 4:
611
+ return _context8.abrupt("return", _context8.sent);
612
+ case 5:
613
+ case "end":
614
+ return _context8.stop();
750
615
  }
751
616
  }, _callee8, this);
752
617
  }));
753
-
754
618
  function AwaitEvent(_x7) {
755
619
  return _AwaitEvent.apply(this, arguments);
756
620
  }
757
-
758
621
  return AwaitEvent;
759
622
  }()
760
623
  }, {
761
624
  key: "ExtractEventFromLogs",
762
625
  value: function ExtractEventFromLogs(_ref12) {
763
626
  var abi = _ref12.abi,
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
-
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
768
631
  var _iterator = _createForOfIteratorHelper(event.logs),
769
- _step;
770
-
632
+ _step;
771
633
  try {
772
634
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
773
635
  var log = _step.value;
774
-
775
636
  try {
776
637
  var parsedLog = contractInterface.parseLog(log);
777
-
778
638
  if (parsedLog && parsedLog.name === eventName) {
779
639
  return parsedLog;
780
- } // eslint-disable-next-line no-empty
781
-
640
+ }
641
+ // eslint-disable-next-line no-empty
782
642
  } catch (error) {}
783
643
  }
784
644
  } catch (err) {
@@ -792,96 +652,78 @@ var EthClient = /*#__PURE__*/function () {
792
652
  value: function () {
793
653
  var _DeployDependentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
794
654
  var contractAddress, methodName, _ref13$args, args, eventName, eventValue, abi, event, eventLog, newContractAddress;
795
-
796
655
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
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
- }
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();
843
694
  }
844
695
  }, _callee9, this);
845
696
  }));
846
-
847
697
  function DeployDependentContract(_x8) {
848
698
  return _DeployDependentContract.apply(this, arguments);
849
699
  }
850
-
851
700
  return DeployDependentContract;
852
- }()
853
- /* Specific contract management */
854
-
701
+ }() /* Specific contract management */
855
702
  }, {
856
703
  key: "DeployAccessGroupContract",
857
704
  value: function () {
858
705
  var _DeployAccessGroupContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
859
706
  var contentSpaceAddress;
860
707
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
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
- }
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();
877
721
  }
878
722
  }, _callee10, this);
879
723
  }));
880
-
881
724
  function DeployAccessGroupContract(_x9) {
882
725
  return _DeployAccessGroupContract.apply(this, arguments);
883
726
  }
884
-
885
727
  return DeployAccessGroupContract;
886
728
  }()
887
729
  }, {
@@ -890,30 +732,25 @@ var EthClient = /*#__PURE__*/function () {
890
732
  var _DeployTypeContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref15) {
891
733
  var contentSpaceAddress;
892
734
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
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
- }
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();
909
748
  }
910
749
  }, _callee11, this);
911
750
  }));
912
-
913
751
  function DeployTypeContract(_x10) {
914
752
  return _DeployTypeContract.apply(this, arguments);
915
753
  }
916
-
917
754
  return DeployTypeContract;
918
755
  }()
919
756
  }, {
@@ -922,31 +759,26 @@ var EthClient = /*#__PURE__*/function () {
922
759
  var _DeployLibraryContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref16) {
923
760
  var contentSpaceAddress, kmsId, kmsAddress;
924
761
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
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
- }
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();
942
776
  }
943
777
  }, _callee12, this);
944
778
  }));
945
-
946
779
  function DeployLibraryContract(_x11) {
947
780
  return _DeployLibraryContract.apply(this, arguments);
948
781
  }
949
-
950
782
  return DeployLibraryContract;
951
783
  }()
952
784
  }, {
@@ -955,32 +787,27 @@ var EthClient = /*#__PURE__*/function () {
955
787
  var _DeployContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
956
788
  var contentLibraryAddress, typeAddress;
957
789
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
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
- }
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();
976
805
  }
977
806
  }, _callee13, this);
978
807
  }));
979
-
980
808
  function DeployContentContract(_x12) {
981
809
  return _DeployContentContract.apply(this, arguments);
982
810
  }
983
-
984
811
  return DeployContentContract;
985
812
  }()
986
813
  }, {
@@ -989,33 +816,27 @@ var EthClient = /*#__PURE__*/function () {
989
816
  var _CommitContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
990
817
  var contentObjectAddress, versionHash;
991
818
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
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
- }
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();
1011
834
  }
1012
835
  }, _callee14, this);
1013
836
  }));
1014
-
1015
837
  function CommitContent(_x13) {
1016
838
  return _CommitContent.apply(this, arguments);
1017
839
  }
1018
-
1019
840
  return CommitContent;
1020
841
  }()
1021
842
  }, {
@@ -1024,28 +845,23 @@ var EthClient = /*#__PURE__*/function () {
1024
845
  var _EngageAccountLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
1025
846
  var contentSpaceAddress;
1026
847
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
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
- }
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();
1041
859
  }
1042
860
  }, _callee15, this);
1043
861
  }));
1044
-
1045
862
  function EngageAccountLibrary(_x14) {
1046
863
  return _EngageAccountLibrary.apply(this, arguments);
1047
864
  }
1048
-
1049
865
  return EngageAccountLibrary;
1050
866
  }()
1051
867
  }, {
@@ -1053,165 +869,128 @@ var EthClient = /*#__PURE__*/function () {
1053
869
  value: function () {
1054
870
  var _SetCustomContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
1055
871
  var contentContractAddress, customContractAddress, _ref20$overrides, overrides;
1056
-
1057
872
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
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
- }
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();
1077
888
  }
1078
889
  }, _callee16, this);
1079
890
  }));
1080
-
1081
891
  function SetCustomContentContract(_x15) {
1082
892
  return _SetCustomContentContract.apply(this, arguments);
1083
893
  }
1084
-
1085
894
  return SetCustomContentContract;
1086
895
  }() // Get all logs for the specified contract in the specified range
1087
-
1088
896
  }, {
1089
897
  key: "ContractEvents",
1090
898
  value: function () {
1091
899
  var _ContractEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
1092
900
  var _this4 = this;
1093
-
1094
901
  var contractAddress, abi, _ref21$fromBlock, fromBlock, toBlock, topics, _ref21$includeTransac, includeTransaction, filter, contractLogs, blocks;
1095
-
1096
902
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
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();
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;
1173
947
  }
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;
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);
1186
965
  }));
1187
-
1188
- case 15:
1189
- case "end":
1190
- return _context18.stop();
1191
- }
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();
1192
977
  }
1193
978
  }, _callee18, this);
1194
979
  }));
1195
-
1196
980
  function ContractEvents(_x16) {
1197
981
  return _ContractEvents.apply(this, arguments);
1198
982
  }
1199
-
1200
983
  return ContractEvents;
1201
984
  }() // Look up the log topic and see if it is known. If so, parse it and inject it into the log
1202
-
1203
985
  }, {
1204
986
  key: "ParseUnknownLog",
1205
987
  value: function ParseUnknownLog(_ref23) {
1206
988
  var log = _ref23.log;
1207
-
1208
989
  if (log.topics && log.topics.length > 0) {
1209
990
  var topicHash = log.topics[0];
1210
991
  var topicInfo = Topics[topicHash];
1211
-
1212
992
  if (topicInfo) {
1213
993
  var eventInterface = new Ethers.utils.Interface(topicInfo.abi);
1214
-
1215
994
  if (eventInterface) {
1216
995
  log = _objectSpread(_objectSpread(_objectSpread({}, log), eventInterface.parseLog(log)), {}, {
1217
996
  contract: topicInfo.contract
@@ -1219,191 +998,157 @@ var EthClient = /*#__PURE__*/function () {
1219
998
  }
1220
999
  }
1221
1000
  }
1222
-
1223
1001
  return log;
1224
- } // Get logs for all blocks in the specified range
1225
- // Returns a list, sorted in descending block order, with each entry containing all logs or transactions in that block
1002
+ }
1226
1003
 
1004
+ // Get logs for all blocks in the specified range
1005
+ // Returns a list, sorted in descending block order, with each entry containing all logs or transactions in that block
1227
1006
  }, {
1228
1007
  key: "Events",
1229
1008
  value: function () {
1230
1009
  var _Events = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref24) {
1231
1010
  var _this5 = this;
1232
-
1233
1011
  var toBlock, fromBlock, _ref24$includeTransac, includeTransaction, logs, i, newLogs, blocks, output;
1234
-
1235
1012
  return _regeneratorRuntime.wrap(function _callee21$(_context21) {
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;
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;
1266
1022
  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
- }
1359
- }
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();
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;
1377
1060
  }
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
- }
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;
1092
+ }
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();
1394
1143
  }
1395
1144
  }, _callee21, this);
1396
1145
  }));
1397
-
1398
1146
  function Events(_x18) {
1399
1147
  return _Events.apply(this, arguments);
1400
1148
  }
1401
-
1402
1149
  return Events;
1403
1150
  }()
1404
1151
  }]);
1405
-
1406
1152
  return EthClient;
1407
1153
  }();
1408
-
1409
1154
  module.exports = EthClient;