@eluvio/elv-client-js 4.0.8 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +10 -11
- package/dist/ElvClient-node-min.js +10 -11
- package/dist/ElvFrameClient-min.js +10 -11
- package/dist/ElvPermissionsClient-min.js +9 -10
- package/dist/ElvWalletClient-min.js +10 -11
- package/dist/ElvWalletClient-node-min.js +9 -10
- package/dist/src/AuthorizationClient.js +2069 -1548
- package/dist/src/ContentObjectVerification.js +185 -134
- package/dist/src/Crypto.js +323 -226
- package/dist/src/ElvClient.js +1118 -824
- package/dist/src/ElvWallet.js +106 -64
- package/dist/src/EthClient.js +974 -719
- package/dist/src/FrameClient.js +318 -222
- package/dist/src/HttpClient.js +154 -112
- package/dist/src/Id.js +6 -1
- package/dist/src/LogMessage.js +8 -4
- package/dist/src/PermissionsClient.js +1271 -973
- package/dist/src/RemoteSigner.js +232 -161
- package/dist/src/UserProfileClient.js +1038 -781
- package/dist/src/Utils.js +302 -160
- package/dist/src/Validation.js +17 -2
- package/dist/src/client/ABRPublishing.js +942 -772
- package/dist/src/client/AccessGroups.js +1095 -849
- package/dist/src/client/ContentAccess.js +4198 -3272
- package/dist/src/client/ContentManagement.js +2284 -1812
- package/dist/src/client/Contracts.js +614 -468
- package/dist/src/client/Files.js +1831 -1491
- package/dist/src/client/NFT.js +116 -94
- package/dist/src/client/NTP.js +425 -326
- package/dist/src/index.js +5 -2
- package/dist/src/walletClient/ClientMethods.js +1766 -1350
- package/dist/src/walletClient/Configuration.js +2 -4
- package/dist/src/walletClient/Notifications.js +127 -98
- package/dist/src/walletClient/Profile.js +246 -184
- package/dist/src/walletClient/Utils.js +124 -78
- package/dist/src/walletClient/index.js +1498 -1169
- package/package.json +1 -1
- package/src/client/ContentAccess.js +27 -10
- package/src/walletClient/ClientMethods.js +18 -10
- 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
_context8.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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)
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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)
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
-
|
|
670
|
-
|
|
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
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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)
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
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
|
-
}
|
|
721
|
-
|
|
843
|
+
} // Ensure block numbers are valid
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
if (toBlock > latestBlock) {
|
|
847
|
+
toBlock = latestBlock;
|
|
722
848
|
}
|
|
723
|
-
|
|
724
|
-
fromBlock
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
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)
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
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)
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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)
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
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)
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
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
|
};
|