@eluvio/elv-client-js 4.0.112 → 4.0.113

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 (124) hide show
  1. package/package.json +1 -1
  2. package/dist/ElvClient-min.js +0 -67
  3. package/dist/ElvClient-node-min.js +0 -66
  4. package/dist/ElvFrameClient-min.js +0 -60
  5. package/dist/ElvPermissionsClient-min.js +0 -60
  6. package/dist/ElvWalletClient-min.js +0 -67
  7. package/dist/ElvWalletClient-node-min.js +0 -66
  8. package/dist/src/AuthorizationClient.js +0 -2157
  9. package/dist/src/ContentObjectAudit.js +0 -175
  10. package/dist/src/ContentObjectVerification.js +0 -281
  11. package/dist/src/Crypto.js +0 -412
  12. package/dist/src/ElvClient.js +0 -2022
  13. package/dist/src/ElvWallet.js +0 -245
  14. package/dist/src/EthClient.js +0 -1154
  15. package/dist/src/FrameClient.js +0 -485
  16. package/dist/src/HttpClient.js +0 -315
  17. package/dist/src/Id.js +0 -21
  18. package/dist/src/LogMessage.js +0 -25
  19. package/dist/src/PermissionsClient.js +0 -1544
  20. package/dist/src/RemoteSigner.js +0 -385
  21. package/dist/src/UserProfileClient.js +0 -1450
  22. package/dist/src/Utils.js +0 -894
  23. package/dist/src/Validation.js +0 -121
  24. package/dist/src/abr_profiles/abr_profile_live_drm.js +0 -1661
  25. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +0 -1606
  26. package/dist/src/client/ABRPublishing.js +0 -1018
  27. package/dist/src/client/AccessGroups.js +0 -1503
  28. package/dist/src/client/ContentAccess.js +0 -5173
  29. package/dist/src/client/ContentManagement.js +0 -2680
  30. package/dist/src/client/Contracts.js +0 -1520
  31. package/dist/src/client/Files.js +0 -2181
  32. package/dist/src/client/LiveConf.js +0 -567
  33. package/dist/src/client/LiveStream.js +0 -2638
  34. package/dist/src/client/NFT.js +0 -162
  35. package/dist/src/client/NTP.js +0 -581
  36. package/dist/src/contracts/v2/AccessIndexor.js +0 -831
  37. package/dist/src/contracts/v2/Accessible.js +0 -31
  38. package/dist/src/contracts/v2/BaseAccessControlGroup.js +0 -1263
  39. package/dist/src/contracts/v2/BaseAccessWallet.js +0 -1609
  40. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +0 -93
  41. package/dist/src/contracts/v2/BaseContent.js +0 -1076
  42. package/dist/src/contracts/v2/BaseContentFactory.js +0 -219
  43. package/dist/src/contracts/v2/BaseContentSpace.js +0 -1352
  44. package/dist/src/contracts/v2/BaseContentType.js +0 -364
  45. package/dist/src/contracts/v2/BaseFactory.js +0 -107
  46. package/dist/src/contracts/v2/BaseGroupFactory.js +0 -93
  47. package/dist/src/contracts/v2/BaseLibrary.js +0 -1041
  48. package/dist/src/contracts/v2/BaseLibraryFactory.js +0 -96
  49. package/dist/src/contracts/v2/Certifyer.js +0 -86
  50. package/dist/src/contracts/v2/Container.js +0 -540
  51. package/dist/src/contracts/v2/Content.js +0 -443
  52. package/dist/src/contracts/v2/Editable.js +0 -306
  53. package/dist/src/contracts/v2/ExternalUserWallet.js +0 -379
  54. package/dist/src/contracts/v2/IFactorySpace.js +0 -57
  55. package/dist/src/contracts/v2/IKmsSpace.js +0 -52
  56. package/dist/src/contracts/v2/INodeSpace.js +0 -18
  57. package/dist/src/contracts/v2/IUserSpace.js +0 -18
  58. package/dist/src/contracts/v2/LvRecordableStream.js +0 -1037
  59. package/dist/src/contracts/v2/LvRecording.js +0 -627
  60. package/dist/src/contracts/v2/LvStreamRightsHolder.js +0 -562
  61. package/dist/src/contracts/v2/MetaObject.js +0 -119
  62. package/dist/src/contracts/v2/Node.js +0 -167
  63. package/dist/src/contracts/v2/NodeSpace.js +0 -273
  64. package/dist/src/contracts/v2/Ownable.js +0 -87
  65. package/dist/src/contracts/v2/PaymentService.js +0 -627
  66. package/dist/src/contracts/v2/Precompile.js +0 -15
  67. package/dist/src/contracts/v2/Transactable.js +0 -82
  68. package/dist/src/contracts/v2/UserSpace.js +0 -29
  69. package/dist/src/contracts/v2/Utils.js +0 -18
  70. package/dist/src/contracts/v2/Verifier.js +0 -53
  71. package/dist/src/contracts/v2/strings.js +0 -4
  72. package/dist/src/contracts/v3/AccessIndexor.js +0 -774
  73. package/dist/src/contracts/v3/Accessible.js +0 -232
  74. package/dist/src/contracts/v3/Adminable.js +0 -107
  75. package/dist/src/contracts/v3/AvailsDelivery.js +0 -586
  76. package/dist/src/contracts/v3/BaseAccessControlGroup.js +0 -1603
  77. package/dist/src/contracts/v3/BaseAccessWallet.js +0 -1628
  78. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +0 -112
  79. package/dist/src/contracts/v3/BaseContent.js +0 -1312
  80. package/dist/src/contracts/v3/BaseContentFactory.js +0 -183
  81. package/dist/src/contracts/v3/BaseContentFactoryExt.js +0 -175
  82. package/dist/src/contracts/v3/BaseContentSpace.js +0 -1515
  83. package/dist/src/contracts/v3/BaseContentType.js +0 -527
  84. package/dist/src/contracts/v3/BaseFactory.js +0 -126
  85. package/dist/src/contracts/v3/BaseGroupFactory.js +0 -112
  86. package/dist/src/contracts/v3/BaseLibrary.js +0 -1204
  87. package/dist/src/contracts/v3/BaseLibraryFactory.js +0 -115
  88. package/dist/src/contracts/v3/BaseTenantSpace.js +0 -1587
  89. package/dist/src/contracts/v3/Certifyer.js +0 -86
  90. package/dist/src/contracts/v3/Container.js +0 -739
  91. package/dist/src/contracts/v3/Content.js +0 -438
  92. package/dist/src/contracts/v3/CounterObject.js +0 -243
  93. package/dist/src/contracts/v3/Editable.js +0 -519
  94. package/dist/src/contracts/v3/EncToken.js +0 -4
  95. package/dist/src/contracts/v3/ExternalUserWallet.js +0 -587
  96. package/dist/src/contracts/v3/IAdmin.js +0 -18
  97. package/dist/src/contracts/v3/IFactorySpace.js +0 -57
  98. package/dist/src/contracts/v3/IKmsSpace.js +0 -52
  99. package/dist/src/contracts/v3/INodeSpace.js +0 -18
  100. package/dist/src/contracts/v3/IUserSpace.js +0 -32
  101. package/dist/src/contracts/v3/LvRecordableStream.js +0 -1032
  102. package/dist/src/contracts/v3/LvRecording.js +0 -650
  103. package/dist/src/contracts/v3/LvStreamRightsHolder.js +0 -557
  104. package/dist/src/contracts/v3/MetaObject.js +0 -144
  105. package/dist/src/contracts/v3/Node.js +0 -178
  106. package/dist/src/contracts/v3/NodeSpace.js +0 -284
  107. package/dist/src/contracts/v3/Ownable.js +0 -98
  108. package/dist/src/contracts/v3/PaymentService.js +0 -622
  109. package/dist/src/contracts/v3/Precompile.js +0 -26
  110. package/dist/src/contracts/v3/TenantFuncsBase.js +0 -351
  111. package/dist/src/contracts/v3/Transactable.js +0 -82
  112. package/dist/src/contracts/v3/UserSpace.js +0 -43
  113. package/dist/src/contracts/v3/Utils.js +0 -18
  114. package/dist/src/contracts/v3/Verifier.js +0 -53
  115. package/dist/src/contracts/v3/strings.js +0 -4
  116. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +0 -1704
  117. package/dist/src/events/Topics.js +0 -1793
  118. package/dist/src/index.js +0 -8
  119. package/dist/src/walletClient/ClientMethods.js +0 -3102
  120. package/dist/src/walletClient/Configuration.js +0 -38
  121. package/dist/src/walletClient/Notifications.js +0 -168
  122. package/dist/src/walletClient/Profile.js +0 -332
  123. package/dist/src/walletClient/Utils.js +0 -281
  124. package/dist/src/walletClient/index.js +0 -2106
@@ -1,1154 +0,0 @@
1
- var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
- var _typeof = require("@babel/runtime/helpers/typeof");
3
- var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
4
- var _regeneratorRuntime = require("@babel/runtime/regenerator");
5
- var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
6
- var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
7
- var _createClass = require("@babel/runtime/helpers/createClass");
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; } } }; }
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); }
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; }
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; }
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; }
13
- // NOTE: Querying Ethereum requires CORS enabled
14
- // Use --rpccorsdomain "http[s]://hostname:port" or set up proxy
15
- var Ethers = require("ethers");
16
- var HttpClient = require("./HttpClient");
17
-
18
- /*
19
- // -- Contract javascript files built using build/BuildContracts.js
20
- const ContentSpaceContract = require("./contracts/BaseContentSpace");
21
- const ContentLibraryContract = require("./contracts/BaseLibrary");
22
- const ContentContract = require("./contracts/BaseContent");
23
- */
24
-
25
- var AccessibleContract = require("./contracts/v3/Accessible");
26
- var Utils = require("./Utils");
27
- var _require = require("./LogMessage"),
28
- LogMessage = _require.LogMessage;
29
- var Topics = require("./events/Topics");
30
- var EthClient = /*#__PURE__*/function () {
31
- "use strict";
32
-
33
- function EthClient(_ref) {
34
- 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;
40
- _classCallCheck(this, EthClient);
41
- this.client = client;
42
- this.networkId = networkId;
43
- this.ethereumURIs = uris;
44
- this.ethereumURIIndex = 0;
45
- this.locked = false;
46
- this.debug = debug;
47
- // convert to milliseconds
48
- this.timeout = Math.floor(timeout * 1000);
49
- this.cachedContracts = {};
50
- this.contractNames = {};
51
-
52
- // HTTP client for making misc calls to elv-master
53
- this.HttpClient = new HttpClient({
54
- uris: this.ethereumURIs,
55
- debug: this.debug
56
- });
57
-
58
- //Ethers.errors.setLogLevel("error");
59
- }
60
- _createClass(EthClient, [{
61
- key: "Log",
62
- value: function Log(message) {
63
- var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
64
- LogMessage(this, message, error);
65
- }
66
- }, {
67
- key: "SetEthereumURIs",
68
- value: function SetEthereumURIs(uris) {
69
- this.ethereumURIs = uris;
70
- this.ethereumURIIndex = 0;
71
- this.HttpClient = new HttpClient({
72
- uris: this.ethereumURIs,
73
- debug: this.debug
74
- });
75
- }
76
- }, {
77
- key: "Provider",
78
- value: function Provider() {
79
- 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
83
- // data every time a contract is initialized in the client (often). Ethers.js just checks that the code isn't == "0x", so
84
- // we can give it some dummy string instead and assume the contract is fine
85
- this.provider.getCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
86
- 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();
93
- }
94
- }, _callee);
95
- }));
96
- this.provider.pollingInterval = 500;
97
- }
98
- return this.provider;
99
- }
100
- }, {
101
- key: "ContractName",
102
- value: function () {
103
- var _ContractName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(contractAddress) {
104
- var _this = this;
105
- var full,
106
- versionContract,
107
- version,
108
- _args3 = arguments;
109
- 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();
166
- }
167
- }, _callee3, this);
168
- }));
169
- function ContractName(_x) {
170
- return _ContractName.apply(this, arguments);
171
- }
172
- return ContractName;
173
- }()
174
- }, {
175
- key: "Contract",
176
- value: function Contract(_ref4) {
177
- var contractAddress = _ref4.contractAddress,
178
- abi = _ref4.abi,
179
- cacheContract = _ref4.cacheContract,
180
- overrideCachedContract = _ref4.overrideCachedContract;
181
- var contract;
182
- if (!overrideCachedContract) {
183
- contract = this.cachedContracts[contractAddress];
184
- }
185
- if (!abi) {
186
- throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
187
- }
188
- if (!contract) {
189
- contract = new Ethers.Contract(contractAddress, abi, this.Provider());
190
- contract = contract.connect(this.client.signer);
191
- if (cacheContract) {
192
- this.cachedContracts[contractAddress] = contract;
193
- }
194
- }
195
- return contract;
196
- }
197
- }, {
198
- key: "MakeProviderCall",
199
- value: function () {
200
- var _MakeProviderCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
201
- var methodName, _ref5$args, args, _ref5$attempts, attempts, provider;
202
- 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();
238
- }
239
- }, _callee4, this, [[1, 11]]);
240
- }));
241
- function MakeProviderCall(_x3) {
242
- return _MakeProviderCall.apply(this, arguments);
243
- }
244
- return MakeProviderCall;
245
- }() /* General contract management */
246
- }, {
247
- key: "FormatContractArgument",
248
- value: function FormatContractArgument(_ref6) {
249
- var _this2 = this;
250
- var type = _ref6.type,
251
- value = _ref6.value;
252
- // For array types, parse into array if necessary, then format each value.
253
- if (type.endsWith("[]")) {
254
- if (typeof value === "string") {
255
- if (value.trim() === "") {
256
- return [];
257
- }
258
- value = value.split(",").map(function (s) {
259
- return s.trim();
260
- });
261
- }
262
- var singleType = type.replace("[]", "");
263
- return value.map(function (element) {
264
- return _this2.FormatContractArgument({
265
- type: singleType,
266
- value: element
267
- });
268
- });
269
- }
270
- switch (type.toLowerCase()) {
271
- case "bytes32":
272
- return Ethers.utils.formatBytes32String(value);
273
- case "bytes":
274
- return Ethers.utils.toUtf8Bytes(value);
275
- case "address":
276
- return Utils.FormatAddress(value);
277
- default:
278
- return value;
279
- }
280
- }
281
-
282
- // Apply any necessary formatting to contract arguments based on the ABI spec
283
- }, {
284
- key: "FormatContractArguments",
285
- value: function FormatContractArguments(_ref7) {
286
- var _this3 = this;
287
- var abi = _ref7.abi,
288
- methodName = _ref7.methodName,
289
- args = _ref7.args;
290
- var method = abi.find(function (func) {
291
- // Constructor has type=constructor but no name
292
- return func.name === methodName || func.type === methodName;
293
- });
294
- if (method === undefined) {
295
- throw Error("Unknown method: " + methodName);
296
- }
297
-
298
- // Format each argument
299
- return args.map(function (arg, i) {
300
- return _this3.FormatContractArgument({
301
- type: method.inputs[i].type,
302
- value: arg
303
- });
304
- });
305
- }
306
-
307
- // Validate signer is set
308
- }, {
309
- key: "ValidateSigner",
310
- value: function ValidateSigner(signer) {
311
- if (!signer) {
312
- throw Error("Signer not set");
313
- }
314
- }
315
- }, {
316
- key: "DeployContract",
317
- value: function () {
318
- var _DeployContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
319
- var abi, bytecode, _ref8$constructorArgs, constructorArgs, _ref8$overrides, overrides, provider, signer, contractFactory, contract;
320
- 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();
345
- }
346
- }, _callee5, this);
347
- }));
348
- function DeployContract(_x4) {
349
- return _DeployContract.apply(this, arguments);
350
- }
351
- return DeployContract;
352
- }() // Accepts either contract object or contract address
353
- }, {
354
- key: "CallContractMethod",
355
- value: function () {
356
- var _CallContractMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref9) {
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;
358
- 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({
384
- abi: abi,
385
- methodName: methodName,
386
- args: methodArgs
387
- });
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;
427
- 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;
442
- 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;
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();
485
- }
486
- }, _callee6, this, [[20,, 50, 53], [23, 30]]);
487
- }));
488
- function CallContractMethod(_x5) {
489
- return _CallContractMethod.apply(this, arguments);
490
- }
491
- return CallContractMethod;
492
- }()
493
- }, {
494
- key: "CallContractMethodAndWait",
495
- value: function () {
496
- var _CallContractMethodAndWait = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
497
- var contractAddress, abi, methodName, methodArgs, value, timeout, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract, contract, createMethodCall, interval, elapsed, methodEvent;
498
- 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;
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();
582
- }
583
- }, _callee7, this);
584
- }));
585
- function CallContractMethodAndWait(_x6) {
586
- return _CallContractMethodAndWait.apply(this, arguments);
587
- }
588
- return CallContractMethodAndWait;
589
- }()
590
- }, {
591
- key: "AwaitEvent",
592
- value: function () {
593
- var _AwaitEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref11) {
594
- var contractAddress, abi, eventName, contract;
595
- 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);
608
- });
609
- });
610
- case 4:
611
- return _context8.abrupt("return", _context8.sent);
612
- case 5:
613
- case "end":
614
- return _context8.stop();
615
- }
616
- }, _callee8, this);
617
- }));
618
- function AwaitEvent(_x7) {
619
- return _AwaitEvent.apply(this, arguments);
620
- }
621
- return AwaitEvent;
622
- }()
623
- }, {
624
- key: "ExtractEventFromLogs",
625
- value: function ExtractEventFromLogs(_ref12) {
626
- 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
631
- var _iterator = _createForOfIteratorHelper(event.logs),
632
- _step;
633
- try {
634
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
635
- var log = _step.value;
636
- try {
637
- var parsedLog = contractInterface.parseLog(log);
638
- if (parsedLog && parsedLog.name === eventName) {
639
- return parsedLog;
640
- }
641
- // eslint-disable-next-line no-empty
642
- } catch (error) {}
643
- }
644
- } catch (err) {
645
- _iterator.e(err);
646
- } finally {
647
- _iterator.f();
648
- }
649
- }
650
- }, {
651
- key: "DeployDependentContract",
652
- value: function () {
653
- var _DeployDependentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
654
- var contractAddress, methodName, _ref13$args, args, eventName, eventValue, abi, event, eventLog, newContractAddress;
655
- 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();
694
- }
695
- }, _callee9, this);
696
- }));
697
- function DeployDependentContract(_x8) {
698
- return _DeployDependentContract.apply(this, arguments);
699
- }
700
- return DeployDependentContract;
701
- }() /* Specific contract management */
702
- }, {
703
- key: "DeployAccessGroupContract",
704
- value: function () {
705
- var _DeployAccessGroupContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
706
- var contentSpaceAddress;
707
- 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();
721
- }
722
- }, _callee10, this);
723
- }));
724
- function DeployAccessGroupContract(_x9) {
725
- return _DeployAccessGroupContract.apply(this, arguments);
726
- }
727
- return DeployAccessGroupContract;
728
- }()
729
- }, {
730
- key: "DeployTypeContract",
731
- value: function () {
732
- var _DeployTypeContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref15) {
733
- var contentSpaceAddress;
734
- 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();
748
- }
749
- }, _callee11, this);
750
- }));
751
- function DeployTypeContract(_x10) {
752
- return _DeployTypeContract.apply(this, arguments);
753
- }
754
- return DeployTypeContract;
755
- }()
756
- }, {
757
- key: "DeployLibraryContract",
758
- value: function () {
759
- var _DeployLibraryContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref16) {
760
- var contentSpaceAddress, kmsId, kmsAddress;
761
- 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();
776
- }
777
- }, _callee12, this);
778
- }));
779
- function DeployLibraryContract(_x11) {
780
- return _DeployLibraryContract.apply(this, arguments);
781
- }
782
- return DeployLibraryContract;
783
- }()
784
- }, {
785
- key: "DeployContentContract",
786
- value: function () {
787
- var _DeployContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
788
- var contentLibraryAddress, typeAddress;
789
- 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();
805
- }
806
- }, _callee13, this);
807
- }));
808
- function DeployContentContract(_x12) {
809
- return _DeployContentContract.apply(this, arguments);
810
- }
811
- return DeployContentContract;
812
- }()
813
- }, {
814
- key: "CommitContent",
815
- value: function () {
816
- var _CommitContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
817
- var contentObjectAddress, versionHash;
818
- 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();
834
- }
835
- }, _callee14, this);
836
- }));
837
- function CommitContent(_x13) {
838
- return _CommitContent.apply(this, arguments);
839
- }
840
- return CommitContent;
841
- }()
842
- }, {
843
- key: "EngageAccountLibrary",
844
- value: function () {
845
- var _EngageAccountLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
846
- var contentSpaceAddress;
847
- 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();
859
- }
860
- }, _callee15, this);
861
- }));
862
- function EngageAccountLibrary(_x14) {
863
- return _EngageAccountLibrary.apply(this, arguments);
864
- }
865
- return EngageAccountLibrary;
866
- }()
867
- }, {
868
- key: "SetCustomContentContract",
869
- value: function () {
870
- var _SetCustomContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
871
- var contentContractAddress, customContractAddress, _ref20$overrides, overrides;
872
- 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();
888
- }
889
- }, _callee16, this);
890
- }));
891
- function SetCustomContentContract(_x15) {
892
- return _SetCustomContentContract.apply(this, arguments);
893
- }
894
- return SetCustomContentContract;
895
- }() // Get all logs for the specified contract in the specified range
896
- }, {
897
- key: "ContractEvents",
898
- value: function () {
899
- var _ContractEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
900
- var _this4 = this;
901
- var contractAddress, abi, _ref21$fromBlock, fromBlock, toBlock, topics, _ref21$includeTransac, includeTransaction, filter, contractLogs, blocks;
902
- 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;
947
- }
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);
965
- }));
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();
977
- }
978
- }, _callee18, this);
979
- }));
980
- function ContractEvents(_x16) {
981
- return _ContractEvents.apply(this, arguments);
982
- }
983
- return ContractEvents;
984
- }() // Look up the log topic and see if it is known. If so, parse it and inject it into the log
985
- }, {
986
- key: "ParseUnknownLog",
987
- value: function ParseUnknownLog(_ref23) {
988
- var log = _ref23.log;
989
- if (log.topics && log.topics.length > 0) {
990
- var topicHash = log.topics[0];
991
- var topicInfo = Topics[topicHash];
992
- if (topicInfo) {
993
- var eventInterface = new Ethers.utils.Interface(topicInfo.abi);
994
- if (eventInterface) {
995
- log = _objectSpread(_objectSpread(_objectSpread({}, log), eventInterface.parseLog(log)), {}, {
996
- contract: topicInfo.contract
997
- });
998
- }
999
- }
1000
- }
1001
- return log;
1002
- }
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
1006
- }, {
1007
- key: "Events",
1008
- value: function () {
1009
- var _Events = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref24) {
1010
- var _this5 = this;
1011
- var toBlock, fromBlock, _ref24$includeTransac, includeTransaction, logs, i, newLogs, blocks, output;
1012
- 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;
1022
- 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;
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();
1143
- }
1144
- }, _callee21, this);
1145
- }));
1146
- function Events(_x18) {
1147
- return _Events.apply(this, arguments);
1148
- }
1149
- return Events;
1150
- }()
1151
- }]);
1152
- return EthClient;
1153
- }();
1154
- module.exports = EthClient;