@eluvio/elv-client-js 4.0.7 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +10 -11
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2069 -1548
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +323 -226
  10. package/dist/src/ElvClient.js +1118 -824
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +302 -160
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4198 -3272
  25. package/dist/src/client/ContentManagement.js +2284 -1812
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1491
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1766 -1350
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +124 -78
  36. package/dist/src/walletClient/index.js +1498 -1169
  37. package/package.json +1 -1
  38. package/src/Crypto.js +2 -2
  39. package/src/ElvClient.js +2 -2
  40. package/src/Utils.js +1 -1
  41. package/src/client/ContentAccess.js +27 -10
  42. package/src/client/Files.js +1 -1
  43. package/src/walletClient/ClientMethods.js +18 -10
  44. package/src/walletClient/Utils.js +2 -2
  45. package/src/walletClient/index.js +7 -2
@@ -1,23 +1,27 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
+
2
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
+
3
5
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
+
4
7
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
8
+
5
9
  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; }
10
+
6
11
  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; }
12
+
7
13
  /**
8
14
  * Methods for deploying and interacting with contracts
9
15
  *
10
16
  * @module ElvClient/Contracts
11
17
  */
18
+ var Ethers = require("ethers"); //const ContentContract = require("../contracts/BaseContent");
12
19
 
13
- var Ethers = require("ethers");
14
- //const ContentContract = require("../contracts/BaseContent");
15
20
 
16
21
  var _require = require("../Validation"),
17
- ValidateAddress = _require.ValidateAddress,
18
- ValidateParameters = _require.ValidateParameters,
19
- ValidatePresence = _require.ValidatePresence;
20
-
22
+ ValidateAddress = _require.ValidateAddress,
23
+ ValidateParameters = _require.ValidateParameters,
24
+ ValidatePresence = _require.ValidatePresence;
21
25
  /**
22
26
  * Return the name of the contract, as specified in the contracts "version" string
23
27
  *
@@ -28,29 +32,35 @@ var _require = require("../Validation"),
28
32
  *
29
33
  * @return {Promise<string>} - Name of the contract
30
34
  */
35
+
36
+
31
37
  exports.ContractName = /*#__PURE__*/function () {
32
38
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
33
39
  var contractAddress;
34
40
  return _regeneratorRuntime.wrap(function _callee$(_context) {
35
- while (1) switch (_context.prev = _context.next) {
36
- case 0:
37
- contractAddress = _ref.contractAddress;
38
- contractAddress = ValidateAddress(contractAddress);
39
- _context.next = 4;
40
- return this.ethClient.ContractName(contractAddress);
41
- case 4:
42
- return _context.abrupt("return", _context.sent);
43
- case 5:
44
- case "end":
45
- return _context.stop();
41
+ while (1) {
42
+ switch (_context.prev = _context.next) {
43
+ case 0:
44
+ contractAddress = _ref.contractAddress;
45
+ contractAddress = ValidateAddress(contractAddress);
46
+ _context.next = 4;
47
+ return this.ethClient.ContractName(contractAddress);
48
+
49
+ case 4:
50
+ return _context.abrupt("return", _context.sent);
51
+
52
+ case 5:
53
+ case "end":
54
+ return _context.stop();
55
+ }
46
56
  }
47
57
  }, _callee, this);
48
58
  }));
59
+
49
60
  return function (_x) {
50
61
  return _ref2.apply(this, arguments);
51
62
  };
52
63
  }();
53
-
54
64
  /**
55
65
  * Retrieve the ABI for the given contract via its address or a Fabric ID. Contract must be a standard Eluvio contract
56
66
  *
@@ -63,38 +73,47 @@ exports.ContractName = /*#__PURE__*/function () {
63
73
  *
64
74
  * @throws If ABI is not able to be determined, throws an error
65
75
  */
76
+
77
+
66
78
  exports.ContractAbi = /*#__PURE__*/function () {
67
79
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
68
80
  var contractAddress, id, contractInfo;
69
81
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
70
- while (1) switch (_context2.prev = _context2.next) {
71
- case 0:
72
- contractAddress = _ref3.contractAddress, id = _ref3.id;
73
- _context2.next = 3;
74
- return this.authClient.ContractInfo({
75
- address: contractAddress,
76
- id: id
77
- });
78
- case 3:
79
- contractInfo = _context2.sent;
80
- if (contractInfo) {
81
- _context2.next = 6;
82
- break;
83
- }
84
- throw Error("Unable to determine contract info for ".concat(contractAddress));
85
- case 6:
86
- return _context2.abrupt("return", contractInfo.abi);
87
- case 7:
88
- case "end":
89
- return _context2.stop();
82
+ while (1) {
83
+ switch (_context2.prev = _context2.next) {
84
+ case 0:
85
+ contractAddress = _ref3.contractAddress, id = _ref3.id;
86
+ _context2.next = 3;
87
+ return this.authClient.ContractInfo({
88
+ address: contractAddress,
89
+ id: id
90
+ });
91
+
92
+ case 3:
93
+ contractInfo = _context2.sent;
94
+
95
+ if (contractInfo) {
96
+ _context2.next = 6;
97
+ break;
98
+ }
99
+
100
+ throw Error("Unable to determine contract info for ".concat(contractAddress));
101
+
102
+ case 6:
103
+ return _context2.abrupt("return", contractInfo.abi);
104
+
105
+ case 7:
106
+ case "end":
107
+ return _context2.stop();
108
+ }
90
109
  }
91
110
  }, _callee2, this);
92
111
  }));
112
+
93
113
  return function (_x2) {
94
114
  return _ref4.apply(this, arguments);
95
115
  };
96
116
  }();
97
-
98
117
  /**
99
118
  * Format the arguments to be used for the specified method of the contract
100
119
  *
@@ -106,17 +125,18 @@ exports.ContractAbi = /*#__PURE__*/function () {
106
125
  *
107
126
  * @returns {Array<string>} - List of formatted arguments
108
127
  */
128
+
129
+
109
130
  exports.FormatContractArguments = function (_ref5) {
110
131
  var abi = _ref5.abi,
111
- methodName = _ref5.methodName,
112
- args = _ref5.args;
132
+ methodName = _ref5.methodName,
133
+ args = _ref5.args;
113
134
  return this.ethClient.FormatContractArguments({
114
135
  abi: abi,
115
136
  methodName: methodName,
116
137
  args: args
117
138
  });
118
139
  };
119
-
120
140
  /**
121
141
  * Deploy a contract from ABI and bytecode. This client's signer will be the owner of the contract.
122
142
  *
@@ -129,34 +149,41 @@ exports.FormatContractArguments = function (_ref5) {
129
149
  *
130
150
  * @returns {Promise<Object>} - Response containing the deployed contract address and the transaction hash of the deployment
131
151
  */
152
+
153
+
132
154
  exports.DeployContract = /*#__PURE__*/function () {
133
155
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
134
156
  var abi, bytecode, constructorArgs, _ref6$overrides, overrides;
157
+
135
158
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
136
- while (1) switch (_context3.prev = _context3.next) {
137
- case 0:
138
- abi = _ref6.abi, bytecode = _ref6.bytecode, constructorArgs = _ref6.constructorArgs, _ref6$overrides = _ref6.overrides, overrides = _ref6$overrides === void 0 ? {} : _ref6$overrides;
139
- _context3.next = 3;
140
- return this.ethClient.DeployContract({
141
- abi: abi,
142
- bytecode: bytecode,
143
- constructorArgs: constructorArgs,
144
- overrides: overrides,
145
- signer: this.signer
146
- });
147
- case 3:
148
- return _context3.abrupt("return", _context3.sent);
149
- case 4:
150
- case "end":
151
- return _context3.stop();
159
+ while (1) {
160
+ switch (_context3.prev = _context3.next) {
161
+ case 0:
162
+ abi = _ref6.abi, bytecode = _ref6.bytecode, constructorArgs = _ref6.constructorArgs, _ref6$overrides = _ref6.overrides, overrides = _ref6$overrides === void 0 ? {} : _ref6$overrides;
163
+ _context3.next = 3;
164
+ return this.ethClient.DeployContract({
165
+ abi: abi,
166
+ bytecode: bytecode,
167
+ constructorArgs: constructorArgs,
168
+ overrides: overrides,
169
+ signer: this.signer
170
+ });
171
+
172
+ case 3:
173
+ return _context3.abrupt("return", _context3.sent);
174
+
175
+ case 4:
176
+ case "end":
177
+ return _context3.stop();
178
+ }
152
179
  }
153
180
  }, _callee3, this);
154
181
  }));
182
+
155
183
  return function (_x3) {
156
184
  return _ref7.apply(this, arguments);
157
185
  };
158
186
  }();
159
-
160
187
  /**
161
188
  * Get all events on the specified contract
162
189
  *
@@ -171,56 +198,68 @@ exports.DeployContract = /*#__PURE__*/function () {
171
198
  * Note: This requires one extra network call per block, so it should not be used for very large ranges
172
199
  * @returns {Promise<Array<Array<Object>>>} - List of blocks, in ascending order by block number, each containing a list of the events in the block.
173
200
  */
201
+
202
+
174
203
  exports.ContractEvents = /*#__PURE__*/function () {
175
204
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref8) {
176
205
  var contractAddress, abi, _ref8$fromBlock, fromBlock, toBlock, _ref8$count, count, topics, _ref8$includeTransact, includeTransaction, blocks;
206
+
177
207
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
178
- while (1) switch (_context4.prev = _context4.next) {
179
- case 0:
180
- contractAddress = _ref8.contractAddress, abi = _ref8.abi, _ref8$fromBlock = _ref8.fromBlock, fromBlock = _ref8$fromBlock === void 0 ? 0 : _ref8$fromBlock, toBlock = _ref8.toBlock, _ref8$count = _ref8.count, count = _ref8$count === void 0 ? 1000 : _ref8$count, topics = _ref8.topics, _ref8$includeTransact = _ref8.includeTransaction, includeTransaction = _ref8$includeTransact === void 0 ? false : _ref8$includeTransact;
181
- contractAddress = ValidateAddress(contractAddress);
182
- if (abi) {
183
- _context4.next = 6;
184
- break;
185
- }
186
- _context4.next = 5;
187
- return this.ContractAbi({
188
- contractAddress: contractAddress
189
- });
190
- case 5:
191
- abi = _context4.sent;
192
- case 6:
193
- _context4.next = 8;
194
- return this.FormatBlockNumbers({
195
- fromBlock: fromBlock,
196
- toBlock: toBlock,
197
- count: count
198
- });
199
- case 8:
200
- blocks = _context4.sent;
201
- this.Log("Querying contract events ".concat(contractAddress, " - Blocks ").concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
202
- _context4.next = 12;
203
- return this.ethClient.ContractEvents({
204
- contractAddress: contractAddress,
205
- abi: abi,
206
- fromBlock: blocks.fromBlock,
207
- toBlock: blocks.toBlock,
208
- topics: topics,
209
- includeTransaction: includeTransaction
210
- });
211
- case 12:
212
- return _context4.abrupt("return", _context4.sent);
213
- case 13:
214
- case "end":
215
- return _context4.stop();
208
+ while (1) {
209
+ switch (_context4.prev = _context4.next) {
210
+ case 0:
211
+ contractAddress = _ref8.contractAddress, abi = _ref8.abi, _ref8$fromBlock = _ref8.fromBlock, fromBlock = _ref8$fromBlock === void 0 ? 0 : _ref8$fromBlock, toBlock = _ref8.toBlock, _ref8$count = _ref8.count, count = _ref8$count === void 0 ? 1000 : _ref8$count, topics = _ref8.topics, _ref8$includeTransact = _ref8.includeTransaction, includeTransaction = _ref8$includeTransact === void 0 ? false : _ref8$includeTransact;
212
+ contractAddress = ValidateAddress(contractAddress);
213
+
214
+ if (abi) {
215
+ _context4.next = 6;
216
+ break;
217
+ }
218
+
219
+ _context4.next = 5;
220
+ return this.ContractAbi({
221
+ contractAddress: contractAddress
222
+ });
223
+
224
+ case 5:
225
+ abi = _context4.sent;
226
+
227
+ case 6:
228
+ _context4.next = 8;
229
+ return this.FormatBlockNumbers({
230
+ fromBlock: fromBlock,
231
+ toBlock: toBlock,
232
+ count: count
233
+ });
234
+
235
+ case 8:
236
+ blocks = _context4.sent;
237
+ this.Log("Querying contract events ".concat(contractAddress, " - Blocks ").concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
238
+ _context4.next = 12;
239
+ return this.ethClient.ContractEvents({
240
+ contractAddress: contractAddress,
241
+ abi: abi,
242
+ fromBlock: blocks.fromBlock,
243
+ toBlock: blocks.toBlock,
244
+ topics: topics,
245
+ includeTransaction: includeTransaction
246
+ });
247
+
248
+ case 12:
249
+ return _context4.abrupt("return", _context4.sent);
250
+
251
+ case 13:
252
+ case "end":
253
+ return _context4.stop();
254
+ }
216
255
  }
217
256
  }, _callee4, this);
218
257
  }));
258
+
219
259
  return function (_x4) {
220
260
  return _ref9.apply(this, arguments);
221
261
  };
222
262
  }();
223
-
224
263
  /**
225
264
  * Call the specified method on a deployed contract. This action will be performed by this client's signer.
226
265
  *
@@ -239,56 +278,67 @@ exports.ContractEvents = /*#__PURE__*/function () {
239
278
  *
240
279
  * @returns {Promise<*>} - Response containing information about the transaction
241
280
  */
281
+
282
+
242
283
  exports.CallContractMethod = /*#__PURE__*/function () {
243
284
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref10) {
244
285
  var contractAddress, abi, methodName, _ref10$methodArgs, methodArgs, value, _ref10$overrides, overrides, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract;
286
+
245
287
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
246
- while (1) switch (_context5.prev = _context5.next) {
247
- case 0:
248
- contractAddress = _ref10.contractAddress, abi = _ref10.abi, methodName = _ref10.methodName, _ref10$methodArgs = _ref10.methodArgs, methodArgs = _ref10$methodArgs === void 0 ? [] : _ref10$methodArgs, value = _ref10.value, _ref10$overrides = _ref10.overrides, overrides = _ref10$overrides === void 0 ? {} : _ref10$overrides, _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;
249
- contractAddress = ValidateAddress(contractAddress);
250
-
251
- // Delete cached visibility value if it is being changed
252
- contractAddress = this.utils.FormatAddress(contractAddress);
253
- if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
254
- delete this.visibilityInfo[contractAddress];
255
- }
256
- if (abi) {
257
- _context5.next = 8;
258
- break;
259
- }
260
- _context5.next = 7;
261
- return this.ContractAbi({
262
- contractAddress: contractAddress
263
- });
264
- case 7:
265
- abi = _context5.sent;
266
- case 8:
267
- _context5.next = 10;
268
- return this.ethClient.CallContractMethod({
269
- contractAddress: contractAddress,
270
- abi: abi,
271
- methodName: methodName,
272
- methodArgs: methodArgs,
273
- value: value,
274
- overrides: overrides,
275
- formatArguments: formatArguments,
276
- cacheContract: cacheContract,
277
- overrideCachedContract: overrideCachedContract
278
- });
279
- case 10:
280
- return _context5.abrupt("return", _context5.sent);
281
- case 11:
282
- case "end":
283
- return _context5.stop();
288
+ while (1) {
289
+ switch (_context5.prev = _context5.next) {
290
+ case 0:
291
+ contractAddress = _ref10.contractAddress, abi = _ref10.abi, methodName = _ref10.methodName, _ref10$methodArgs = _ref10.methodArgs, methodArgs = _ref10$methodArgs === void 0 ? [] : _ref10$methodArgs, value = _ref10.value, _ref10$overrides = _ref10.overrides, overrides = _ref10$overrides === void 0 ? {} : _ref10$overrides, _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;
292
+ contractAddress = ValidateAddress(contractAddress); // Delete cached visibility value if it is being changed
293
+
294
+ contractAddress = this.utils.FormatAddress(contractAddress);
295
+
296
+ if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
297
+ delete this.visibilityInfo[contractAddress];
298
+ }
299
+
300
+ if (abi) {
301
+ _context5.next = 8;
302
+ break;
303
+ }
304
+
305
+ _context5.next = 7;
306
+ return this.ContractAbi({
307
+ contractAddress: contractAddress
308
+ });
309
+
310
+ case 7:
311
+ abi = _context5.sent;
312
+
313
+ case 8:
314
+ _context5.next = 10;
315
+ return this.ethClient.CallContractMethod({
316
+ contractAddress: contractAddress,
317
+ abi: abi,
318
+ methodName: methodName,
319
+ methodArgs: methodArgs,
320
+ value: value,
321
+ overrides: overrides,
322
+ formatArguments: formatArguments,
323
+ cacheContract: cacheContract,
324
+ overrideCachedContract: overrideCachedContract
325
+ });
326
+
327
+ case 10:
328
+ return _context5.abrupt("return", _context5.sent);
329
+
330
+ case 11:
331
+ case "end":
332
+ return _context5.stop();
333
+ }
284
334
  }
285
335
  }, _callee5, this);
286
336
  }));
337
+
287
338
  return function (_x5) {
288
339
  return _ref11.apply(this, arguments);
289
340
  };
290
341
  }();
291
-
292
342
  /**
293
343
  * Call the specified method on a deployed contract and wait for the transaction to be mined.
294
344
  * This action will be performed by this client's signer.
@@ -310,56 +360,67 @@ exports.CallContractMethod = /*#__PURE__*/function () {
310
360
  * @returns {Promise<*>} - The event object of this transaction. See the ExtractEventFromLogs method for parsing
311
361
  * the resulting event(s)
312
362
  */
363
+
364
+
313
365
  exports.CallContractMethodAndWait = /*#__PURE__*/function () {
314
366
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref12) {
315
367
  var contractAddress, abi, methodName, methodArgs, value, _ref12$overrides, overrides, _ref12$formatArgument, formatArguments, _ref12$cacheContract, cacheContract, _ref12$overrideCached, overrideCachedContract;
368
+
316
369
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
317
- while (1) switch (_context6.prev = _context6.next) {
318
- case 0:
319
- contractAddress = _ref12.contractAddress, abi = _ref12.abi, methodName = _ref12.methodName, methodArgs = _ref12.methodArgs, value = _ref12.value, _ref12$overrides = _ref12.overrides, overrides = _ref12$overrides === void 0 ? {} : _ref12$overrides, _ref12$formatArgument = _ref12.formatArguments, formatArguments = _ref12$formatArgument === void 0 ? true : _ref12$formatArgument, _ref12$cacheContract = _ref12.cacheContract, cacheContract = _ref12$cacheContract === void 0 ? true : _ref12$cacheContract, _ref12$overrideCached = _ref12.overrideCachedContract, overrideCachedContract = _ref12$overrideCached === void 0 ? false : _ref12$overrideCached;
320
- contractAddress = ValidateAddress(contractAddress);
321
-
322
- // Delete cached visibility value if it is being changed
323
- contractAddress = this.utils.FormatAddress(contractAddress);
324
- if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
325
- delete this.visibilityInfo[contractAddress];
326
- }
327
- if (abi) {
328
- _context6.next = 8;
329
- break;
330
- }
331
- _context6.next = 7;
332
- return this.ContractAbi({
333
- contractAddress: contractAddress
334
- });
335
- case 7:
336
- abi = _context6.sent;
337
- case 8:
338
- _context6.next = 10;
339
- return this.ethClient.CallContractMethodAndWait({
340
- contractAddress: contractAddress,
341
- abi: abi,
342
- methodName: methodName,
343
- methodArgs: methodArgs,
344
- value: value,
345
- overrides: overrides,
346
- formatArguments: formatArguments,
347
- cacheContract: cacheContract,
348
- overrideCachedContract: overrideCachedContract
349
- });
350
- case 10:
351
- return _context6.abrupt("return", _context6.sent);
352
- case 11:
353
- case "end":
354
- return _context6.stop();
370
+ while (1) {
371
+ switch (_context6.prev = _context6.next) {
372
+ case 0:
373
+ contractAddress = _ref12.contractAddress, abi = _ref12.abi, methodName = _ref12.methodName, methodArgs = _ref12.methodArgs, value = _ref12.value, _ref12$overrides = _ref12.overrides, overrides = _ref12$overrides === void 0 ? {} : _ref12$overrides, _ref12$formatArgument = _ref12.formatArguments, formatArguments = _ref12$formatArgument === void 0 ? true : _ref12$formatArgument, _ref12$cacheContract = _ref12.cacheContract, cacheContract = _ref12$cacheContract === void 0 ? true : _ref12$cacheContract, _ref12$overrideCached = _ref12.overrideCachedContract, overrideCachedContract = _ref12$overrideCached === void 0 ? false : _ref12$overrideCached;
374
+ contractAddress = ValidateAddress(contractAddress); // Delete cached visibility value if it is being changed
375
+
376
+ contractAddress = this.utils.FormatAddress(contractAddress);
377
+
378
+ if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
379
+ delete this.visibilityInfo[contractAddress];
380
+ }
381
+
382
+ if (abi) {
383
+ _context6.next = 8;
384
+ break;
385
+ }
386
+
387
+ _context6.next = 7;
388
+ return this.ContractAbi({
389
+ contractAddress: contractAddress
390
+ });
391
+
392
+ case 7:
393
+ abi = _context6.sent;
394
+
395
+ case 8:
396
+ _context6.next = 10;
397
+ return this.ethClient.CallContractMethodAndWait({
398
+ contractAddress: contractAddress,
399
+ abi: abi,
400
+ methodName: methodName,
401
+ methodArgs: methodArgs,
402
+ value: value,
403
+ overrides: overrides,
404
+ formatArguments: formatArguments,
405
+ cacheContract: cacheContract,
406
+ overrideCachedContract: overrideCachedContract
407
+ });
408
+
409
+ case 10:
410
+ return _context6.abrupt("return", _context6.sent);
411
+
412
+ case 11:
413
+ case "end":
414
+ return _context6.stop();
415
+ }
355
416
  }
356
417
  }, _callee6, this);
357
418
  }));
419
+
358
420
  return function (_x6) {
359
421
  return _ref13.apply(this, arguments);
360
422
  };
361
423
  }();
362
-
363
424
  /**
364
425
  * Retrieve metadata from the specified contract
365
426
  *
@@ -370,49 +431,58 @@ exports.CallContractMethodAndWait = /*#__PURE__*/function () {
370
431
  *
371
432
  * @return {Promise<Object|string>}
372
433
  */
434
+
435
+
373
436
  exports.ContractMetadata = /*#__PURE__*/function () {
374
437
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref14) {
375
438
  var contractAddress, metadataKey, metadata, data;
376
439
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
377
- while (1) switch (_context7.prev = _context7.next) {
378
- case 0:
379
- contractAddress = _ref14.contractAddress, metadataKey = _ref14.metadataKey;
380
- ValidatePresence("contractAddress", contractAddress);
381
- ValidatePresence("metadataKey", metadataKey);
382
- _context7.prev = 3;
383
- _context7.next = 6;
384
- return this.CallContractMethod({
385
- contractAddress: contractAddress,
386
- methodName: "getMeta",
387
- methodArgs: [metadataKey]
388
- });
389
- case 6:
390
- metadata = _context7.sent;
391
- data = Buffer.from((metadata || "").replace("0x", ""), "hex").toString("utf-8");
392
- _context7.prev = 8;
393
- return _context7.abrupt("return", JSON.parse(data));
394
- case 12:
395
- _context7.prev = 12;
396
- _context7.t0 = _context7["catch"](8);
397
- return _context7.abrupt("return", data);
398
- case 15:
399
- _context7.next = 20;
400
- break;
401
- case 17:
402
- _context7.prev = 17;
403
- _context7.t1 = _context7["catch"](3);
404
- return _context7.abrupt("return", "");
405
- case 20:
406
- case "end":
407
- return _context7.stop();
440
+ while (1) {
441
+ switch (_context7.prev = _context7.next) {
442
+ case 0:
443
+ contractAddress = _ref14.contractAddress, metadataKey = _ref14.metadataKey;
444
+ ValidatePresence("contractAddress", contractAddress);
445
+ ValidatePresence("metadataKey", metadataKey);
446
+ _context7.prev = 3;
447
+ _context7.next = 6;
448
+ return this.CallContractMethod({
449
+ contractAddress: contractAddress,
450
+ methodName: "getMeta",
451
+ methodArgs: [metadataKey]
452
+ });
453
+
454
+ case 6:
455
+ metadata = _context7.sent;
456
+ data = Buffer.from((metadata || "").replace("0x", ""), "hex").toString("utf-8");
457
+ _context7.prev = 8;
458
+ return _context7.abrupt("return", JSON.parse(data));
459
+
460
+ case 12:
461
+ _context7.prev = 12;
462
+ _context7.t0 = _context7["catch"](8);
463
+ return _context7.abrupt("return", data);
464
+
465
+ case 15:
466
+ _context7.next = 20;
467
+ break;
468
+
469
+ case 17:
470
+ _context7.prev = 17;
471
+ _context7.t1 = _context7["catch"](3);
472
+ return _context7.abrupt("return", "");
473
+
474
+ case 20:
475
+ case "end":
476
+ return _context7.stop();
477
+ }
408
478
  }
409
479
  }, _callee7, this, [[3, 17], [8, 12]]);
410
480
  }));
481
+
411
482
  return function (_x7) {
412
483
  return _ref15.apply(this, arguments);
413
484
  };
414
485
  }();
415
-
416
486
  /**
417
487
  * Merge contract metadata at the specified key.
418
488
  *
@@ -422,49 +492,60 @@ exports.ContractMetadata = /*#__PURE__*/function () {
422
492
  * @param {string} metadataKey - The metadata key to retrieve
423
493
  * @param {string} metadata
424
494
  */
495
+
496
+
425
497
  exports.MergeContractMetadata = /*#__PURE__*/function () {
426
498
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref16) {
427
499
  var contractAddress, metadataKey, metadata, existingMetadata;
428
500
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
429
- while (1) switch (_context8.prev = _context8.next) {
430
- case 0:
431
- contractAddress = _ref16.contractAddress, metadataKey = _ref16.metadataKey, metadata = _ref16.metadata;
432
- ValidatePresence("contractAddress", contractAddress);
433
- ValidatePresence("metadataKey", metadataKey);
434
- _context8.next = 5;
435
- return this.ContractMetadata({
436
- contractAddress: contractAddress,
437
- metadataKey: metadataKey
438
- });
439
- case 5:
440
- _context8.t0 = _context8.sent;
441
- if (_context8.t0) {
442
- _context8.next = 8;
443
- break;
444
- }
445
- _context8.t0 = {};
446
- case 8:
447
- existingMetadata = _context8.t0;
448
- if (_typeof(existingMetadata) === "object") {
449
- metadata = _objectSpread(_objectSpread({}, existingMetadata), metadata);
450
- }
451
- _context8.next = 12;
452
- return this.CallContractMethodAndWait({
453
- contractAddress: contractAddress,
454
- methodName: "putMeta",
455
- methodArgs: [metadataKey, JSON.stringify(metadata)]
456
- });
457
- case 12:
458
- case "end":
459
- return _context8.stop();
501
+ while (1) {
502
+ switch (_context8.prev = _context8.next) {
503
+ case 0:
504
+ contractAddress = _ref16.contractAddress, metadataKey = _ref16.metadataKey, metadata = _ref16.metadata;
505
+ ValidatePresence("contractAddress", contractAddress);
506
+ ValidatePresence("metadataKey", metadataKey);
507
+ _context8.next = 5;
508
+ return this.ContractMetadata({
509
+ contractAddress: contractAddress,
510
+ metadataKey: metadataKey
511
+ });
512
+
513
+ case 5:
514
+ _context8.t0 = _context8.sent;
515
+
516
+ if (_context8.t0) {
517
+ _context8.next = 8;
518
+ break;
519
+ }
520
+
521
+ _context8.t0 = {};
522
+
523
+ case 8:
524
+ existingMetadata = _context8.t0;
525
+
526
+ if (_typeof(existingMetadata) === "object") {
527
+ metadata = _objectSpread(_objectSpread({}, existingMetadata), metadata);
528
+ }
529
+
530
+ _context8.next = 12;
531
+ return this.CallContractMethodAndWait({
532
+ contractAddress: contractAddress,
533
+ methodName: "putMeta",
534
+ methodArgs: [metadataKey, JSON.stringify(metadata)]
535
+ });
536
+
537
+ case 12:
538
+ case "end":
539
+ return _context8.stop();
540
+ }
460
541
  }
461
542
  }, _callee8, this);
462
543
  }));
544
+
463
545
  return function (_x8) {
464
546
  return _ref17.apply(this, arguments);
465
547
  };
466
548
  }();
467
-
468
549
  /**
469
550
  * Replace the contract metadata at the specified key
470
551
  *
@@ -474,32 +555,37 @@ exports.MergeContractMetadata = /*#__PURE__*/function () {
474
555
  * @param {string} metadataKey - The metadata key to retrieve
475
556
  * @param {string|Object} metadata - The metadata to insert
476
557
  */
558
+
559
+
477
560
  exports.ReplaceContractMetadata = /*#__PURE__*/function () {
478
561
  var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref18) {
479
562
  var contractAddress, metadataKey, metadata;
480
563
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
481
- while (1) switch (_context9.prev = _context9.next) {
482
- case 0:
483
- contractAddress = _ref18.contractAddress, metadataKey = _ref18.metadataKey, metadata = _ref18.metadata;
484
- ValidatePresence("contractAddress", contractAddress);
485
- ValidatePresence("metadataKey", metadataKey);
486
- _context9.next = 5;
487
- return this.CallContractMethodAndWait({
488
- contractAddress: contractAddress,
489
- methodName: "putMeta",
490
- methodArgs: [metadataKey, JSON.stringify(metadata)]
491
- });
492
- case 5:
493
- case "end":
494
- return _context9.stop();
564
+ while (1) {
565
+ switch (_context9.prev = _context9.next) {
566
+ case 0:
567
+ contractAddress = _ref18.contractAddress, metadataKey = _ref18.metadataKey, metadata = _ref18.metadata;
568
+ ValidatePresence("contractAddress", contractAddress);
569
+ ValidatePresence("metadataKey", metadataKey);
570
+ _context9.next = 5;
571
+ return this.CallContractMethodAndWait({
572
+ contractAddress: contractAddress,
573
+ methodName: "putMeta",
574
+ methodArgs: [metadataKey, JSON.stringify(metadata)]
575
+ });
576
+
577
+ case 5:
578
+ case "end":
579
+ return _context9.stop();
580
+ }
495
581
  }
496
582
  }, _callee9, this);
497
583
  }));
584
+
498
585
  return function (_x9) {
499
586
  return _ref19.apply(this, arguments);
500
587
  };
501
588
  }();
502
-
503
589
  /**
504
590
  * Get the custom contract of the specified object
505
591
  *
@@ -511,61 +597,75 @@ exports.ReplaceContractMetadata = /*#__PURE__*/function () {
511
597
  *
512
598
  * @returns {Promise<string> | undefined} - If the object has a custom contract, this will return the address of the custom contract
513
599
  */
600
+
601
+
514
602
  exports.CustomContractAddress = /*#__PURE__*/function () {
515
603
  var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref20) {
516
604
  var libraryId, objectId, versionHash, abi, customContractAddress;
517
605
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
518
- while (1) switch (_context10.prev = _context10.next) {
519
- case 0:
520
- libraryId = _ref20.libraryId, objectId = _ref20.objectId, versionHash = _ref20.versionHash;
521
- ValidateParameters({
522
- libraryId: libraryId,
523
- objectId: objectId,
524
- versionHash: versionHash
525
- });
526
- if (versionHash) {
527
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
528
- }
529
- if (!(libraryId === this.contentSpaceLibraryId || this.utils.EqualHash(libraryId, objectId))) {
530
- _context10.next = 5;
531
- break;
532
- }
533
- return _context10.abrupt("return");
534
- case 5:
535
- this.Log("Retrieving custom contract address: ".concat(objectId));
536
- _context10.next = 8;
537
- return this.ContractAbi({
538
- id: objectId
539
- });
540
- case 8:
541
- abi = _context10.sent;
542
- _context10.next = 11;
543
- return this.ethClient.CallContractMethod({
544
- contractAddress: this.utils.HashToAddress(objectId),
545
- abi: abi,
546
- methodName: "contentContractAddress",
547
- methodArgs: []
548
- });
549
- case 11:
550
- customContractAddress = _context10.sent;
551
- if (!(customContractAddress === this.utils.nullAddress)) {
552
- _context10.next = 14;
553
- break;
554
- }
555
- return _context10.abrupt("return");
556
- case 14:
557
- return _context10.abrupt("return", this.utils.FormatAddress(customContractAddress));
558
- case 15:
559
- case "end":
560
- return _context10.stop();
606
+ while (1) {
607
+ switch (_context10.prev = _context10.next) {
608
+ case 0:
609
+ libraryId = _ref20.libraryId, objectId = _ref20.objectId, versionHash = _ref20.versionHash;
610
+ ValidateParameters({
611
+ libraryId: libraryId,
612
+ objectId: objectId,
613
+ versionHash: versionHash
614
+ });
615
+
616
+ if (versionHash) {
617
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
618
+ }
619
+
620
+ if (!(libraryId === this.contentSpaceLibraryId || this.utils.EqualHash(libraryId, objectId))) {
621
+ _context10.next = 5;
622
+ break;
623
+ }
624
+
625
+ return _context10.abrupt("return");
626
+
627
+ case 5:
628
+ this.Log("Retrieving custom contract address: ".concat(objectId));
629
+ _context10.next = 8;
630
+ return this.ContractAbi({
631
+ id: objectId
632
+ });
633
+
634
+ case 8:
635
+ abi = _context10.sent;
636
+ _context10.next = 11;
637
+ return this.ethClient.CallContractMethod({
638
+ contractAddress: this.utils.HashToAddress(objectId),
639
+ abi: abi,
640
+ methodName: "contentContractAddress",
641
+ methodArgs: []
642
+ });
643
+
644
+ case 11:
645
+ customContractAddress = _context10.sent;
646
+
647
+ if (!(customContractAddress === this.utils.nullAddress)) {
648
+ _context10.next = 14;
649
+ break;
650
+ }
651
+
652
+ return _context10.abrupt("return");
653
+
654
+ case 14:
655
+ return _context10.abrupt("return", this.utils.FormatAddress(customContractAddress));
656
+
657
+ case 15:
658
+ case "end":
659
+ return _context10.stop();
660
+ }
561
661
  }
562
662
  }, _callee10, this);
563
663
  }));
664
+
564
665
  return function (_x10) {
565
666
  return _ref21.apply(this, arguments);
566
667
  };
567
668
  }();
568
-
569
669
  /**
570
670
  * Set the custom contract of the specified object with the contract at the specified address
571
671
  *
@@ -584,71 +684,81 @@ exports.CustomContractAddress = /*#__PURE__*/function () {
584
684
  *
585
685
  * @returns {Promise<Object>} - Result transaction of calling the setCustomContract method on the content object contract
586
686
  */
687
+
688
+
587
689
  exports.SetCustomContentContract = /*#__PURE__*/function () {
588
690
  var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref22) {
589
691
  var libraryId, objectId, customContractAddress, name, description, abi, factoryAbi, _ref22$overrides, overrides, setResult, writeToken;
692
+
590
693
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
591
- while (1) switch (_context11.prev = _context11.next) {
592
- case 0:
593
- libraryId = _ref22.libraryId, objectId = _ref22.objectId, customContractAddress = _ref22.customContractAddress, name = _ref22.name, description = _ref22.description, abi = _ref22.abi, factoryAbi = _ref22.factoryAbi, _ref22$overrides = _ref22.overrides, overrides = _ref22$overrides === void 0 ? {} : _ref22$overrides;
594
- ValidateParameters({
595
- libraryId: libraryId,
596
- objectId: objectId
597
- });
598
- customContractAddress = ValidateAddress(customContractAddress);
599
- customContractAddress = this.utils.FormatAddress(customContractAddress);
600
- this.Log("Setting custom contract address: ".concat(objectId, " ").concat(customContractAddress));
601
- _context11.next = 7;
602
- return this.ethClient.SetCustomContentContract({
603
- contentContractAddress: this.utils.HashToAddress(objectId),
604
- customContractAddress: customContractAddress,
605
- overrides: overrides,
606
- signer: this.signer
607
- });
608
- case 7:
609
- setResult = _context11.sent;
610
- _context11.next = 10;
611
- return this.EditContentObject({
612
- libraryId: libraryId,
613
- objectId: objectId
614
- });
615
- case 10:
616
- writeToken = _context11.sent.write_token;
617
- _context11.next = 13;
618
- return this.ReplaceMetadata({
619
- libraryId: libraryId,
620
- objectId: objectId,
621
- writeToken: writeToken,
622
- metadataSubtree: "custom_contract",
623
- metadata: {
624
- name: name,
625
- description: description,
626
- address: customContractAddress,
627
- abi: abi,
628
- factoryAbi: factoryAbi
629
- }
630
- });
631
- case 13:
632
- _context11.next = 15;
633
- return this.FinalizeContentObject({
634
- libraryId: libraryId,
635
- objectId: objectId,
636
- writeToken: writeToken,
637
- commitMessage: "Set custom contract"
638
- });
639
- case 15:
640
- return _context11.abrupt("return", setResult);
641
- case 16:
642
- case "end":
643
- return _context11.stop();
694
+ while (1) {
695
+ switch (_context11.prev = _context11.next) {
696
+ case 0:
697
+ libraryId = _ref22.libraryId, objectId = _ref22.objectId, customContractAddress = _ref22.customContractAddress, name = _ref22.name, description = _ref22.description, abi = _ref22.abi, factoryAbi = _ref22.factoryAbi, _ref22$overrides = _ref22.overrides, overrides = _ref22$overrides === void 0 ? {} : _ref22$overrides;
698
+ ValidateParameters({
699
+ libraryId: libraryId,
700
+ objectId: objectId
701
+ });
702
+ customContractAddress = ValidateAddress(customContractAddress);
703
+ customContractAddress = this.utils.FormatAddress(customContractAddress);
704
+ this.Log("Setting custom contract address: ".concat(objectId, " ").concat(customContractAddress));
705
+ _context11.next = 7;
706
+ return this.ethClient.SetCustomContentContract({
707
+ contentContractAddress: this.utils.HashToAddress(objectId),
708
+ customContractAddress: customContractAddress,
709
+ overrides: overrides,
710
+ signer: this.signer
711
+ });
712
+
713
+ case 7:
714
+ setResult = _context11.sent;
715
+ _context11.next = 10;
716
+ return this.EditContentObject({
717
+ libraryId: libraryId,
718
+ objectId: objectId
719
+ });
720
+
721
+ case 10:
722
+ writeToken = _context11.sent.write_token;
723
+ _context11.next = 13;
724
+ return this.ReplaceMetadata({
725
+ libraryId: libraryId,
726
+ objectId: objectId,
727
+ writeToken: writeToken,
728
+ metadataSubtree: "custom_contract",
729
+ metadata: {
730
+ name: name,
731
+ description: description,
732
+ address: customContractAddress,
733
+ abi: abi,
734
+ factoryAbi: factoryAbi
735
+ }
736
+ });
737
+
738
+ case 13:
739
+ _context11.next = 15;
740
+ return this.FinalizeContentObject({
741
+ libraryId: libraryId,
742
+ objectId: objectId,
743
+ writeToken: writeToken,
744
+ commitMessage: "Set custom contract"
745
+ });
746
+
747
+ case 15:
748
+ return _context11.abrupt("return", setResult);
749
+
750
+ case 16:
751
+ case "end":
752
+ return _context11.stop();
753
+ }
644
754
  }
645
755
  }, _callee11, this);
646
756
  }));
757
+
647
758
  return function (_x11) {
648
759
  return _ref23.apply(this, arguments);
649
760
  };
650
761
  }();
651
-
652
762
  /**
653
763
  * Extract the specified event log from the given event obtained from the
654
764
  * CallContractAndMethodAndWait method
@@ -664,17 +774,18 @@ exports.SetCustomContentContract = /*#__PURE__*/function () {
664
774
  *
665
775
  * @returns {Promise<Object>} - The parsed event log from the event
666
776
  */
777
+
778
+
667
779
  exports.ExtractEventFromLogs = function (_ref24) {
668
780
  var abi = _ref24.abi,
669
- event = _ref24.event,
670
- eventName = _ref24.eventName;
781
+ event = _ref24.event,
782
+ eventName = _ref24.eventName;
671
783
  return this.ethClient.ExtractEventFromLogs({
672
784
  abi: abi,
673
785
  event: event,
674
786
  eventName: eventName
675
787
  });
676
788
  };
677
-
678
789
  /**
679
790
  * Extract the specified value from the specified event log from the given event obtained
680
791
  * from the CallContractAndMethodAndWait method
@@ -689,11 +800,13 @@ exports.ExtractEventFromLogs = function (_ref24) {
689
800
  *
690
801
  * @returns {Promise<string>} The value extracted from the event
691
802
  */
803
+
804
+
692
805
  exports.ExtractValueFromEvent = function (_ref25) {
693
806
  var abi = _ref25.abi,
694
- event = _ref25.event,
695
- eventName = _ref25.eventName,
696
- eventValue = _ref25.eventValue;
807
+ event = _ref25.event,
808
+ eventName = _ref25.eventName,
809
+ eventValue = _ref25.eventValue;
697
810
  var eventLog = this.ethClient.ExtractEventFromLogs({
698
811
  abi: abi,
699
812
  event: event,
@@ -702,50 +815,59 @@ exports.ExtractValueFromEvent = function (_ref25) {
702
815
  });
703
816
  return eventLog ? eventLog.args[eventValue] : undefined;
704
817
  };
818
+
705
819
  exports.FormatBlockNumbers = /*#__PURE__*/function () {
706
820
  var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref26) {
707
821
  var fromBlock, toBlock, _ref26$count, count, latestBlock;
822
+
708
823
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
709
- while (1) switch (_context12.prev = _context12.next) {
710
- case 0:
711
- fromBlock = _ref26.fromBlock, toBlock = _ref26.toBlock, _ref26$count = _ref26.count, count = _ref26$count === void 0 ? 10 : _ref26$count;
712
- _context12.next = 3;
713
- return this.BlockNumber();
714
- case 3:
715
- latestBlock = _context12.sent;
716
- if (!toBlock) {
717
- if (!fromBlock) {
718
- toBlock = latestBlock;
824
+ while (1) {
825
+ switch (_context12.prev = _context12.next) {
826
+ case 0:
827
+ fromBlock = _ref26.fromBlock, toBlock = _ref26.toBlock, _ref26$count = _ref26.count, count = _ref26$count === void 0 ? 10 : _ref26$count;
828
+ _context12.next = 3;
829
+ return this.BlockNumber();
830
+
831
+ case 3:
832
+ latestBlock = _context12.sent;
833
+
834
+ if (!toBlock) {
835
+ if (!fromBlock) {
836
+ toBlock = latestBlock;
837
+ fromBlock = toBlock - count + 1;
838
+ } else {
839
+ toBlock = fromBlock + count - 1;
840
+ }
841
+ } else if (!fromBlock) {
719
842
  fromBlock = toBlock - count + 1;
720
- } else {
721
- toBlock = fromBlock + count - 1;
843
+ } // Ensure block numbers are valid
844
+
845
+
846
+ if (toBlock > latestBlock) {
847
+ toBlock = latestBlock;
722
848
  }
723
- } else if (!fromBlock) {
724
- fromBlock = toBlock - count + 1;
725
- }
726
-
727
- // Ensure block numbers are valid
728
- if (toBlock > latestBlock) {
729
- toBlock = latestBlock;
730
- }
731
- if (fromBlock < 0) {
732
- fromBlock = 0;
733
- }
734
- return _context12.abrupt("return", {
735
- fromBlock: fromBlock,
736
- toBlock: toBlock
737
- });
738
- case 8:
739
- case "end":
740
- return _context12.stop();
849
+
850
+ if (fromBlock < 0) {
851
+ fromBlock = 0;
852
+ }
853
+
854
+ return _context12.abrupt("return", {
855
+ fromBlock: fromBlock,
856
+ toBlock: toBlock
857
+ });
858
+
859
+ case 8:
860
+ case "end":
861
+ return _context12.stop();
862
+ }
741
863
  }
742
864
  }, _callee12, this);
743
865
  }));
866
+
744
867
  return function (_x12) {
745
868
  return _ref27.apply(this, arguments);
746
869
  };
747
870
  }();
748
-
749
871
  /**
750
872
  * Get events from the blockchain in reverse chronological order, starting from toBlock. This will also attempt
751
873
  * to identify and parse any known Eluvio contract methods. If successful, the method name, signature, and input
@@ -760,44 +882,51 @@ exports.FormatBlockNumbers = /*#__PURE__*/function () {
760
882
  * Note: This requires two extra network calls per transaction, so it should not be used for very large ranges
761
883
  * @returns {Promise<Array<Array<Object>>>} - List of blocks, in ascending order by block number, each containing a list of the events in the block.
762
884
  */
885
+
886
+
763
887
  exports.Events = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
764
888
  var _ref29,
765
- toBlock,
766
- fromBlock,
767
- _ref29$count,
768
- count,
769
- _ref29$includeTransac,
770
- includeTransaction,
771
- blocks,
772
- _args13 = arguments;
889
+ toBlock,
890
+ fromBlock,
891
+ _ref29$count,
892
+ count,
893
+ _ref29$includeTransac,
894
+ includeTransaction,
895
+ blocks,
896
+ _args13 = arguments;
897
+
773
898
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
774
- while (1) switch (_context13.prev = _context13.next) {
775
- case 0:
776
- _ref29 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, toBlock = _ref29.toBlock, fromBlock = _ref29.fromBlock, _ref29$count = _ref29.count, count = _ref29$count === void 0 ? 10 : _ref29$count, _ref29$includeTransac = _ref29.includeTransaction, includeTransaction = _ref29$includeTransac === void 0 ? false : _ref29$includeTransac;
777
- _context13.next = 3;
778
- return this.FormatBlockNumbers({
779
- fromBlock: fromBlock,
780
- toBlock: toBlock,
781
- count: count
782
- });
783
- case 3:
784
- blocks = _context13.sent;
785
- this.Log("Querying events - Blocks ".concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
786
- _context13.next = 7;
787
- return this.ethClient.Events({
788
- fromBlock: blocks.fromBlock,
789
- toBlock: blocks.toBlock,
790
- includeTransaction: includeTransaction
791
- });
792
- case 7:
793
- return _context13.abrupt("return", _context13.sent);
794
- case 8:
795
- case "end":
796
- return _context13.stop();
899
+ while (1) {
900
+ switch (_context13.prev = _context13.next) {
901
+ case 0:
902
+ _ref29 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, toBlock = _ref29.toBlock, fromBlock = _ref29.fromBlock, _ref29$count = _ref29.count, count = _ref29$count === void 0 ? 10 : _ref29$count, _ref29$includeTransac = _ref29.includeTransaction, includeTransaction = _ref29$includeTransac === void 0 ? false : _ref29$includeTransac;
903
+ _context13.next = 3;
904
+ return this.FormatBlockNumbers({
905
+ fromBlock: fromBlock,
906
+ toBlock: toBlock,
907
+ count: count
908
+ });
909
+
910
+ case 3:
911
+ blocks = _context13.sent;
912
+ this.Log("Querying events - Blocks ".concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
913
+ _context13.next = 7;
914
+ return this.ethClient.Events({
915
+ fromBlock: blocks.fromBlock,
916
+ toBlock: blocks.toBlock,
917
+ includeTransaction: includeTransaction
918
+ });
919
+
920
+ case 7:
921
+ return _context13.abrupt("return", _context13.sent);
922
+
923
+ case 8:
924
+ case "end":
925
+ return _context13.stop();
926
+ }
797
927
  }
798
928
  }, _callee13, this);
799
929
  }));
800
-
801
930
  /**
802
931
  * Retrieve the latest block number on the blockchain
803
932
  *
@@ -805,23 +934,27 @@ exports.Events = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntim
805
934
  *
806
935
  * @returns {Promise<number>} - The latest block number
807
936
  */
937
+
808
938
  exports.BlockNumber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
809
939
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
810
- while (1) switch (_context14.prev = _context14.next) {
811
- case 0:
812
- _context14.next = 2;
813
- return this.ethClient.MakeProviderCall({
814
- methodName: "getBlockNumber"
815
- });
816
- case 2:
817
- return _context14.abrupt("return", _context14.sent);
818
- case 3:
819
- case "end":
820
- return _context14.stop();
940
+ while (1) {
941
+ switch (_context14.prev = _context14.next) {
942
+ case 0:
943
+ _context14.next = 2;
944
+ return this.ethClient.MakeProviderCall({
945
+ methodName: "getBlockNumber"
946
+ });
947
+
948
+ case 2:
949
+ return _context14.abrupt("return", _context14.sent);
950
+
951
+ case 3:
952
+ case "end":
953
+ return _context14.stop();
954
+ }
821
955
  }
822
956
  }, _callee14, this);
823
957
  }));
824
-
825
958
  /**
826
959
  * Get the balance (in ether) of the specified address
827
960
  *
@@ -831,33 +964,38 @@ exports.BlockNumber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorR
831
964
  *
832
965
  * @returns {Promise<string>} - Balance of the account, in ether (as string)
833
966
  */
967
+
834
968
  exports.GetBalance = /*#__PURE__*/function () {
835
969
  var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref31) {
836
970
  var address, balance;
837
971
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
838
- while (1) switch (_context15.prev = _context15.next) {
839
- case 0:
840
- address = _ref31.address;
841
- address = ValidateAddress(address);
842
- _context15.next = 4;
843
- return this.ethClient.MakeProviderCall({
844
- methodName: "getBalance",
845
- args: [address]
846
- });
847
- case 4:
848
- balance = _context15.sent;
849
- return _context15.abrupt("return", Ethers.utils.formatEther(balance));
850
- case 6:
851
- case "end":
852
- return _context15.stop();
972
+ while (1) {
973
+ switch (_context15.prev = _context15.next) {
974
+ case 0:
975
+ address = _ref31.address;
976
+ address = ValidateAddress(address);
977
+ _context15.next = 4;
978
+ return this.ethClient.MakeProviderCall({
979
+ methodName: "getBalance",
980
+ args: [address]
981
+ });
982
+
983
+ case 4:
984
+ balance = _context15.sent;
985
+ return _context15.abrupt("return", Ethers.utils.formatEther(balance));
986
+
987
+ case 6:
988
+ case "end":
989
+ return _context15.stop();
990
+ }
853
991
  }
854
992
  }, _callee15, this);
855
993
  }));
994
+
856
995
  return function (_x13) {
857
996
  return _ref32.apply(this, arguments);
858
997
  };
859
998
  }();
860
-
861
999
  /**
862
1000
  * Send ether from this client's current signer to the specified recipient address
863
1001
  *
@@ -868,31 +1006,39 @@ exports.GetBalance = /*#__PURE__*/function () {
868
1006
  *
869
1007
  * @returns {Promise<Object>} - The transaction receipt
870
1008
  */
1009
+
1010
+
871
1011
  exports.SendFunds = /*#__PURE__*/function () {
872
1012
  var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref33) {
873
1013
  var recipient, ether, transaction;
874
1014
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
875
- while (1) switch (_context16.prev = _context16.next) {
876
- case 0:
877
- recipient = _ref33.recipient, ether = _ref33.ether;
878
- recipient = ValidateAddress(recipient);
879
- _context16.next = 4;
880
- return this.signer.sendTransaction({
881
- to: recipient,
882
- value: Ethers.utils.parseEther(ether.toString())
883
- });
884
- case 4:
885
- transaction = _context16.sent;
886
- _context16.next = 7;
887
- return transaction.wait();
888
- case 7:
889
- return _context16.abrupt("return", _context16.sent);
890
- case 8:
891
- case "end":
892
- return _context16.stop();
1015
+ while (1) {
1016
+ switch (_context16.prev = _context16.next) {
1017
+ case 0:
1018
+ recipient = _ref33.recipient, ether = _ref33.ether;
1019
+ recipient = ValidateAddress(recipient);
1020
+ _context16.next = 4;
1021
+ return this.signer.sendTransaction({
1022
+ to: recipient,
1023
+ value: Ethers.utils.parseEther(ether.toString())
1024
+ });
1025
+
1026
+ case 4:
1027
+ transaction = _context16.sent;
1028
+ _context16.next = 7;
1029
+ return transaction.wait();
1030
+
1031
+ case 7:
1032
+ return _context16.abrupt("return", _context16.sent);
1033
+
1034
+ case 8:
1035
+ case "end":
1036
+ return _context16.stop();
1037
+ }
893
1038
  }
894
1039
  }, _callee16, this);
895
1040
  }));
1041
+
896
1042
  return function (_x14) {
897
1043
  return _ref34.apply(this, arguments);
898
1044
  };