@eluvio/elv-client-js 3.2.4 → 3.2.5
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 +15 -11
- package/dist/ElvClient-node-min.js +17 -13
- package/dist/ElvFrameClient-min.js +12 -8
- package/dist/ElvPermissionsClient-min.js +13 -9
- package/dist/ElvWalletClient-min.js +58 -0
- package/dist/ElvWalletClient-node-min.js +78 -0
- package/dist/src/AuthorizationClient.js +2248 -1990
- package/dist/src/ContentObjectVerification.js +164 -173
- package/dist/src/Crypto.js +376 -324
- package/dist/src/ElvClient.js +1185 -1019
- package/dist/src/ElvWallet.js +119 -95
- package/dist/src/EthClient.js +1040 -896
- package/dist/src/FrameClient.js +331 -300
- package/dist/src/HttpClient.js +153 -147
- package/dist/src/Id.js +1 -3
- package/dist/src/PermissionsClient.js +1294 -1168
- package/dist/src/RemoteSigner.js +263 -211
- package/dist/src/UserProfileClient.js +1164 -1023
- package/dist/src/Utils.js +229 -184
- package/dist/src/client/ABRPublishing.js +895 -858
- package/dist/src/client/AccessGroups.js +1102 -959
- package/dist/src/client/ContentAccess.js +3724 -3431
- package/dist/src/client/ContentManagement.js +2252 -2068
- package/dist/src/client/Contracts.js +647 -563
- package/dist/src/client/Files.js +1886 -1757
- package/dist/src/client/NFT.js +126 -112
- package/dist/src/client/NTP.js +478 -422
- package/dist/src/index.js +11 -0
- package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
- package/dist/src/marketplaceClient/Configuration.js +29 -0
- package/dist/src/marketplaceClient/Utils.js +304 -0
- package/dist/src/marketplaceClient/index.js +1553 -0
- package/dist/src/walletClient/ClientMethods.js +1978 -0
- package/dist/src/walletClient/Configuration.js +29 -0
- package/dist/src/walletClient/Utils.js +304 -0
- package/dist/src/walletClient/index.js +1571 -0
- package/package.json +8 -4
- package/src/ElvClient.js +4 -1
- package/src/Utils.js +22 -4
- package/src/index.js +7 -0
- package/src/walletClient/ClientMethods.js +1048 -0
- package/src/walletClient/Configuration.js +40 -0
- package/src/walletClient/README.md +185 -0
- package/src/walletClient/Utils.js +234 -0
- package/src/walletClient/index.js +884 -0
- package/testScripts/TestMarketplaceClient.js +25 -0
|
@@ -4,9 +4,11 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
4
4
|
|
|
5
5
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
8
8
|
|
|
9
|
-
function
|
|
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
|
+
|
|
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; }
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Methods for deploying and interacting with contracts
|
|
@@ -32,27 +34,33 @@ var _require = require("../Validation"),
|
|
|
32
34
|
*/
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
exports.ContractName = function
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
exports.ContractName = /*#__PURE__*/function () {
|
|
38
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
39
|
+
var contractAddress;
|
|
40
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
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
|
+
}
|
|
52
56
|
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
57
|
+
}, _callee, this);
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
return function (_x) {
|
|
61
|
+
return _ref2.apply(this, arguments);
|
|
62
|
+
};
|
|
63
|
+
}();
|
|
56
64
|
/**
|
|
57
65
|
* Retrieve the ABI for the given contract via its address or a Fabric ID. Contract must be a standard Eluvio contract
|
|
58
66
|
*
|
|
@@ -67,39 +75,45 @@ exports.ContractName = function _callee(_ref) {
|
|
|
67
75
|
*/
|
|
68
76
|
|
|
69
77
|
|
|
70
|
-
exports.ContractAbi = function
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
exports.ContractAbi = /*#__PURE__*/function () {
|
|
79
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
80
|
+
var contractAddress, id, contractInfo;
|
|
81
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
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
|
+
}
|
|
90
99
|
|
|
91
|
-
|
|
100
|
+
throw Error("Unable to determine contract info for ".concat(contractAddress));
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
case 6:
|
|
103
|
+
return _context2.abrupt("return", contractInfo.abi);
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
case 7:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context2.stop();
|
|
108
|
+
}
|
|
99
109
|
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
110
|
+
}, _callee2, this);
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
return function (_x2) {
|
|
114
|
+
return _ref4.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}();
|
|
103
117
|
/**
|
|
104
118
|
* Format the arguments to be used for the specified method of the contract
|
|
105
119
|
*
|
|
@@ -113,10 +127,10 @@ exports.ContractAbi = function _callee2(_ref2) {
|
|
|
113
127
|
*/
|
|
114
128
|
|
|
115
129
|
|
|
116
|
-
exports.FormatContractArguments = function (
|
|
117
|
-
var abi =
|
|
118
|
-
methodName =
|
|
119
|
-
args =
|
|
130
|
+
exports.FormatContractArguments = function (_ref5) {
|
|
131
|
+
var abi = _ref5.abi,
|
|
132
|
+
methodName = _ref5.methodName,
|
|
133
|
+
args = _ref5.args;
|
|
120
134
|
return this.ethClient.FormatContractArguments({
|
|
121
135
|
abi: abi,
|
|
122
136
|
methodName: methodName,
|
|
@@ -137,33 +151,39 @@ exports.FormatContractArguments = function (_ref3) {
|
|
|
137
151
|
*/
|
|
138
152
|
|
|
139
153
|
|
|
140
|
-
exports.DeployContract = function
|
|
141
|
-
var
|
|
154
|
+
exports.DeployContract = /*#__PURE__*/function () {
|
|
155
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
|
|
156
|
+
var abi, bytecode, constructorArgs, _ref6$overrides, overrides;
|
|
142
157
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
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
|
+
}
|
|
163
179
|
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
180
|
+
}, _callee3, this);
|
|
181
|
+
}));
|
|
182
|
+
|
|
183
|
+
return function (_x3) {
|
|
184
|
+
return _ref7.apply(this, arguments);
|
|
185
|
+
};
|
|
186
|
+
}();
|
|
167
187
|
/**
|
|
168
188
|
* Get all events on the specified contract
|
|
169
189
|
*
|
|
@@ -180,60 +200,66 @@ exports.DeployContract = function _callee3(_ref4) {
|
|
|
180
200
|
*/
|
|
181
201
|
|
|
182
202
|
|
|
183
|
-
exports.ContractEvents = function
|
|
184
|
-
var
|
|
203
|
+
exports.ContractEvents = /*#__PURE__*/function () {
|
|
204
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref8) {
|
|
205
|
+
var contractAddress, abi, _ref8$fromBlock, fromBlock, toBlock, _ref8$count, count, topics, _ref8$includeTransact, includeTransaction, blocks;
|
|
185
206
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
207
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
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);
|
|
192
213
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_context4.next = 5;
|
|
199
|
-
return _regeneratorRuntime.awrap(this.ContractAbi({
|
|
200
|
-
contractAddress: contractAddress
|
|
201
|
-
}));
|
|
202
|
-
|
|
203
|
-
case 5:
|
|
204
|
-
abi = _context4.sent;
|
|
205
|
-
|
|
206
|
-
case 6:
|
|
207
|
-
_context4.next = 8;
|
|
208
|
-
return _regeneratorRuntime.awrap(this.FormatBlockNumbers({
|
|
209
|
-
fromBlock: fromBlock,
|
|
210
|
-
toBlock: toBlock,
|
|
211
|
-
count: count
|
|
212
|
-
}));
|
|
213
|
-
|
|
214
|
-
case 8:
|
|
215
|
-
blocks = _context4.sent;
|
|
216
|
-
this.Log("Querying contract events ".concat(contractAddress, " - Blocks ").concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
|
|
217
|
-
_context4.next = 12;
|
|
218
|
-
return _regeneratorRuntime.awrap(this.ethClient.ContractEvents({
|
|
219
|
-
contractAddress: contractAddress,
|
|
220
|
-
abi: abi,
|
|
221
|
-
fromBlock: blocks.fromBlock,
|
|
222
|
-
toBlock: blocks.toBlock,
|
|
223
|
-
topics: topics,
|
|
224
|
-
includeTransaction: includeTransaction
|
|
225
|
-
}));
|
|
226
|
-
|
|
227
|
-
case 12:
|
|
228
|
-
return _context4.abrupt("return", _context4.sent);
|
|
214
|
+
if (abi) {
|
|
215
|
+
_context4.next = 6;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
229
218
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
+
}
|
|
233
255
|
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
256
|
+
}, _callee4, this);
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
return function (_x4) {
|
|
260
|
+
return _ref9.apply(this, arguments);
|
|
261
|
+
};
|
|
262
|
+
}();
|
|
237
263
|
/**
|
|
238
264
|
* Call the specified method on a deployed contract. This action will be performed by this client's signer.
|
|
239
265
|
*
|
|
@@ -254,59 +280,65 @@ exports.ContractEvents = function _callee4(_ref5) {
|
|
|
254
280
|
*/
|
|
255
281
|
|
|
256
282
|
|
|
257
|
-
exports.CallContractMethod = function
|
|
258
|
-
var
|
|
283
|
+
exports.CallContractMethod = /*#__PURE__*/function () {
|
|
284
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref10) {
|
|
285
|
+
var contractAddress, abi, methodName, _ref10$methodArgs, methodArgs, value, _ref10$overrides, overrides, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract;
|
|
259
286
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
287
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
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
|
|
266
293
|
|
|
267
|
-
|
|
294
|
+
contractAddress = this.utils.FormatAddress(contractAddress);
|
|
268
295
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
296
|
+
if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
|
|
297
|
+
delete this.visibilityInfo[contractAddress];
|
|
298
|
+
}
|
|
272
299
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
300
|
+
if (abi) {
|
|
301
|
+
_context5.next = 8;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
277
304
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
305
|
+
_context5.next = 7;
|
|
306
|
+
return this.ContractAbi({
|
|
307
|
+
contractAddress: contractAddress
|
|
308
|
+
});
|
|
282
309
|
|
|
283
|
-
|
|
284
|
-
|
|
310
|
+
case 7:
|
|
311
|
+
abi = _context5.sent;
|
|
285
312
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
+
}
|
|
306
334
|
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
335
|
+
}, _callee5, this);
|
|
336
|
+
}));
|
|
337
|
+
|
|
338
|
+
return function (_x5) {
|
|
339
|
+
return _ref11.apply(this, arguments);
|
|
340
|
+
};
|
|
341
|
+
}();
|
|
310
342
|
/**
|
|
311
343
|
* Call the specified method on a deployed contract and wait for the transaction to be mined.
|
|
312
344
|
* This action will be performed by this client's signer.
|
|
@@ -330,59 +362,65 @@ exports.CallContractMethod = function _callee5(_ref6) {
|
|
|
330
362
|
*/
|
|
331
363
|
|
|
332
364
|
|
|
333
|
-
exports.CallContractMethodAndWait = function
|
|
334
|
-
var
|
|
365
|
+
exports.CallContractMethodAndWait = /*#__PURE__*/function () {
|
|
366
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref12) {
|
|
367
|
+
var contractAddress, abi, methodName, methodArgs, value, _ref12$overrides, overrides, _ref12$formatArgument, formatArguments, _ref12$cacheContract, cacheContract, _ref12$overrideCached, overrideCachedContract;
|
|
335
368
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
369
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
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
|
|
342
375
|
|
|
343
|
-
|
|
376
|
+
contractAddress = this.utils.FormatAddress(contractAddress);
|
|
344
377
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
378
|
+
if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
|
|
379
|
+
delete this.visibilityInfo[contractAddress];
|
|
380
|
+
}
|
|
348
381
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
382
|
+
if (abi) {
|
|
383
|
+
_context6.next = 8;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
353
386
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
387
|
+
_context6.next = 7;
|
|
388
|
+
return this.ContractAbi({
|
|
389
|
+
contractAddress: contractAddress
|
|
390
|
+
});
|
|
358
391
|
|
|
359
|
-
|
|
360
|
-
|
|
392
|
+
case 7:
|
|
393
|
+
abi = _context6.sent;
|
|
361
394
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
+
}
|
|
382
416
|
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
417
|
+
}, _callee6, this);
|
|
418
|
+
}));
|
|
419
|
+
|
|
420
|
+
return function (_x6) {
|
|
421
|
+
return _ref13.apply(this, arguments);
|
|
422
|
+
};
|
|
423
|
+
}();
|
|
386
424
|
/**
|
|
387
425
|
* Retrieve metadata from the specified contract
|
|
388
426
|
*
|
|
@@ -395,50 +433,56 @@ exports.CallContractMethodAndWait = function _callee6(_ref7) {
|
|
|
395
433
|
*/
|
|
396
434
|
|
|
397
435
|
|
|
398
|
-
exports.ContractMetadata = function
|
|
399
|
-
var
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
exports.ContractMetadata = /*#__PURE__*/function () {
|
|
437
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref14) {
|
|
438
|
+
var contractAddress, metadataKey, metadata, data;
|
|
439
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
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
|
+
}
|
|
438
478
|
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
479
|
+
}, _callee7, this, [[3, 17], [8, 12]]);
|
|
480
|
+
}));
|
|
481
|
+
|
|
482
|
+
return function (_x7) {
|
|
483
|
+
return _ref15.apply(this, arguments);
|
|
484
|
+
};
|
|
485
|
+
}();
|
|
442
486
|
/**
|
|
443
487
|
* Merge contract metadata at the specified key.
|
|
444
488
|
*
|
|
@@ -450,52 +494,58 @@ exports.ContractMetadata = function _callee7(_ref8) {
|
|
|
450
494
|
*/
|
|
451
495
|
|
|
452
496
|
|
|
453
|
-
exports.MergeContractMetadata = function
|
|
454
|
-
var
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
_context8.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
_context8.t0 = {};
|
|
497
|
+
exports.MergeContractMetadata = /*#__PURE__*/function () {
|
|
498
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref16) {
|
|
499
|
+
var contractAddress, metadataKey, metadata, existingMetadata;
|
|
500
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
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
|
+
}
|
|
477
520
|
|
|
478
|
-
|
|
479
|
-
existingMetadata = _context8.t0;
|
|
521
|
+
_context8.t0 = {};
|
|
480
522
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
523
|
+
case 8:
|
|
524
|
+
existingMetadata = _context8.t0;
|
|
484
525
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
methodName: "putMeta",
|
|
489
|
-
methodArgs: [metadataKey, JSON.stringify(metadata)]
|
|
490
|
-
}));
|
|
526
|
+
if (_typeof(existingMetadata) === "object") {
|
|
527
|
+
metadata = _objectSpread(_objectSpread({}, existingMetadata), metadata);
|
|
528
|
+
}
|
|
491
529
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
+
}
|
|
495
541
|
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
542
|
+
}, _callee8, this);
|
|
543
|
+
}));
|
|
544
|
+
|
|
545
|
+
return function (_x8) {
|
|
546
|
+
return _ref17.apply(this, arguments);
|
|
547
|
+
};
|
|
548
|
+
}();
|
|
499
549
|
/**
|
|
500
550
|
* Replace the contract metadata at the specified key
|
|
501
551
|
*
|
|
@@ -507,29 +557,35 @@ exports.MergeContractMetadata = function _callee8(_ref9) {
|
|
|
507
557
|
*/
|
|
508
558
|
|
|
509
559
|
|
|
510
|
-
exports.ReplaceContractMetadata = function
|
|
511
|
-
var
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
560
|
+
exports.ReplaceContractMetadata = /*#__PURE__*/function () {
|
|
561
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref18) {
|
|
562
|
+
var contractAddress, metadataKey, metadata;
|
|
563
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
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
|
+
}
|
|
529
581
|
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
582
|
+
}, _callee9, this);
|
|
583
|
+
}));
|
|
584
|
+
|
|
585
|
+
return function (_x9) {
|
|
586
|
+
return _ref19.apply(this, arguments);
|
|
587
|
+
};
|
|
588
|
+
}();
|
|
533
589
|
/**
|
|
534
590
|
* Get the custom contract of the specified object
|
|
535
591
|
*
|
|
@@ -543,67 +599,73 @@ exports.ReplaceContractMetadata = function _callee9(_ref10) {
|
|
|
543
599
|
*/
|
|
544
600
|
|
|
545
601
|
|
|
546
|
-
exports.CustomContractAddress = function
|
|
547
|
-
var
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
602
|
+
exports.CustomContractAddress = /*#__PURE__*/function () {
|
|
603
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref20) {
|
|
604
|
+
var libraryId, objectId, versionHash, abi, customContractAddress;
|
|
605
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
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
|
+
}
|
|
558
619
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
620
|
+
if (!(libraryId === this.contentSpaceLibraryId || this.utils.EqualHash(libraryId, objectId))) {
|
|
621
|
+
_context10.next = 5;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
562
624
|
|
|
563
|
-
|
|
564
|
-
_context10.next = 5;
|
|
565
|
-
break;
|
|
566
|
-
}
|
|
625
|
+
return _context10.abrupt("return");
|
|
567
626
|
|
|
568
|
-
|
|
627
|
+
case 5:
|
|
628
|
+
this.Log("Retrieving custom contract address: ".concat(objectId));
|
|
629
|
+
_context10.next = 8;
|
|
630
|
+
return this.ContractAbi({
|
|
631
|
+
id: objectId
|
|
632
|
+
});
|
|
569
633
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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
|
+
});
|
|
576
643
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
_context10.next = 11;
|
|
580
|
-
return _regeneratorRuntime.awrap(this.ethClient.CallContractMethod({
|
|
581
|
-
contractAddress: this.utils.HashToAddress(objectId),
|
|
582
|
-
abi: abi,
|
|
583
|
-
methodName: "contentContractAddress",
|
|
584
|
-
methodArgs: []
|
|
585
|
-
}));
|
|
586
|
-
|
|
587
|
-
case 11:
|
|
588
|
-
customContractAddress = _context10.sent;
|
|
589
|
-
|
|
590
|
-
if (!(customContractAddress === this.utils.nullAddress)) {
|
|
591
|
-
_context10.next = 14;
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
644
|
+
case 11:
|
|
645
|
+
customContractAddress = _context10.sent;
|
|
594
646
|
|
|
595
|
-
|
|
647
|
+
if (!(customContractAddress === this.utils.nullAddress)) {
|
|
648
|
+
_context10.next = 14;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
596
651
|
|
|
597
|
-
|
|
598
|
-
return _context10.abrupt("return", this.utils.FormatAddress(customContractAddress));
|
|
652
|
+
return _context10.abrupt("return");
|
|
599
653
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
654
|
+
case 14:
|
|
655
|
+
return _context10.abrupt("return", this.utils.FormatAddress(customContractAddress));
|
|
656
|
+
|
|
657
|
+
case 15:
|
|
658
|
+
case "end":
|
|
659
|
+
return _context10.stop();
|
|
660
|
+
}
|
|
603
661
|
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
662
|
+
}, _callee10, this);
|
|
663
|
+
}));
|
|
664
|
+
|
|
665
|
+
return function (_x10) {
|
|
666
|
+
return _ref21.apply(this, arguments);
|
|
667
|
+
};
|
|
668
|
+
}();
|
|
607
669
|
/**
|
|
608
670
|
* Set the custom contract of the specified object with the contract at the specified address
|
|
609
671
|
*
|
|
@@ -624,73 +686,79 @@ exports.CustomContractAddress = function _callee10(_ref11) {
|
|
|
624
686
|
*/
|
|
625
687
|
|
|
626
688
|
|
|
627
|
-
exports.SetCustomContentContract = function
|
|
628
|
-
var
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
689
|
+
exports.SetCustomContentContract = /*#__PURE__*/function () {
|
|
690
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref22) {
|
|
691
|
+
var libraryId, objectId, customContractAddress, name, description, abi, factoryAbi, _ref22$overrides, overrides, setResult, writeToken;
|
|
692
|
+
|
|
693
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
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
|
+
}
|
|
690
754
|
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
|
|
755
|
+
}, _callee11, this);
|
|
756
|
+
}));
|
|
757
|
+
|
|
758
|
+
return function (_x11) {
|
|
759
|
+
return _ref23.apply(this, arguments);
|
|
760
|
+
};
|
|
761
|
+
}();
|
|
694
762
|
/**
|
|
695
763
|
* Extract the specified event log from the given event obtained from the
|
|
696
764
|
* CallContractAndMethodAndWait method
|
|
@@ -708,10 +776,10 @@ exports.SetCustomContentContract = function _callee11(_ref12) {
|
|
|
708
776
|
*/
|
|
709
777
|
|
|
710
778
|
|
|
711
|
-
exports.ExtractEventFromLogs = function (
|
|
712
|
-
var abi =
|
|
713
|
-
event =
|
|
714
|
-
eventName =
|
|
779
|
+
exports.ExtractEventFromLogs = function (_ref24) {
|
|
780
|
+
var abi = _ref24.abi,
|
|
781
|
+
event = _ref24.event,
|
|
782
|
+
eventName = _ref24.eventName;
|
|
715
783
|
return this.ethClient.ExtractEventFromLogs({
|
|
716
784
|
abi: abi,
|
|
717
785
|
event: event,
|
|
@@ -734,11 +802,11 @@ exports.ExtractEventFromLogs = function (_ref13) {
|
|
|
734
802
|
*/
|
|
735
803
|
|
|
736
804
|
|
|
737
|
-
exports.ExtractValueFromEvent = function (
|
|
738
|
-
var abi =
|
|
739
|
-
event =
|
|
740
|
-
eventName =
|
|
741
|
-
eventValue =
|
|
805
|
+
exports.ExtractValueFromEvent = function (_ref25) {
|
|
806
|
+
var abi = _ref25.abi,
|
|
807
|
+
event = _ref25.event,
|
|
808
|
+
eventName = _ref25.eventName,
|
|
809
|
+
eventValue = _ref25.eventValue;
|
|
742
810
|
var eventLog = this.ethClient.ExtractEventFromLogs({
|
|
743
811
|
abi: abi,
|
|
744
812
|
event: event,
|
|
@@ -748,52 +816,58 @@ exports.ExtractValueFromEvent = function (_ref14) {
|
|
|
748
816
|
return eventLog ? eventLog.values[eventValue] : undefined;
|
|
749
817
|
};
|
|
750
818
|
|
|
751
|
-
exports.FormatBlockNumbers = function
|
|
752
|
-
var
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
819
|
+
exports.FormatBlockNumbers = /*#__PURE__*/function () {
|
|
820
|
+
var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref26) {
|
|
821
|
+
var fromBlock, toBlock, _ref26$count, count, latestBlock;
|
|
822
|
+
|
|
823
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
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) {
|
|
842
|
+
fromBlock = toBlock - count + 1;
|
|
843
|
+
} // Ensure block numbers are valid
|
|
761
844
|
|
|
762
|
-
case 3:
|
|
763
|
-
latestBlock = _context12.sent;
|
|
764
845
|
|
|
765
|
-
|
|
766
|
-
if (!fromBlock) {
|
|
846
|
+
if (toBlock > latestBlock) {
|
|
767
847
|
toBlock = latestBlock;
|
|
768
|
-
fromBlock = toBlock - count + 1;
|
|
769
|
-
} else {
|
|
770
|
-
toBlock = fromBlock + count - 1;
|
|
771
848
|
}
|
|
772
|
-
} else if (!fromBlock) {
|
|
773
|
-
fromBlock = toBlock - count + 1;
|
|
774
|
-
} // Ensure block numbers are valid
|
|
775
|
-
|
|
776
849
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
850
|
+
if (fromBlock < 0) {
|
|
851
|
+
fromBlock = 0;
|
|
852
|
+
}
|
|
780
853
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
854
|
+
return _context12.abrupt("return", {
|
|
855
|
+
fromBlock: fromBlock,
|
|
856
|
+
toBlock: toBlock
|
|
857
|
+
});
|
|
784
858
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
case 8:
|
|
791
|
-
case "end":
|
|
792
|
-
return _context12.stop();
|
|
859
|
+
case 8:
|
|
860
|
+
case "end":
|
|
861
|
+
return _context12.stop();
|
|
862
|
+
}
|
|
793
863
|
}
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
864
|
+
}, _callee12, this);
|
|
865
|
+
}));
|
|
866
|
+
|
|
867
|
+
return function (_x12) {
|
|
868
|
+
return _ref27.apply(this, arguments);
|
|
869
|
+
};
|
|
870
|
+
}();
|
|
797
871
|
/**
|
|
798
872
|
* Get events from the blockchain in reverse chronological order, starting from toBlock. This will also attempt
|
|
799
873
|
* to identify and parse any known Eluvio contract methods. If successful, the method name, signature, and input
|
|
@@ -810,38 +884,38 @@ exports.FormatBlockNumbers = function _callee12(_ref15) {
|
|
|
810
884
|
*/
|
|
811
885
|
|
|
812
886
|
|
|
813
|
-
exports.Events = function _callee13() {
|
|
814
|
-
var
|
|
887
|
+
exports.Events = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
888
|
+
var _ref29,
|
|
815
889
|
toBlock,
|
|
816
890
|
fromBlock,
|
|
817
|
-
|
|
891
|
+
_ref29$count,
|
|
818
892
|
count,
|
|
819
|
-
|
|
893
|
+
_ref29$includeTransac,
|
|
820
894
|
includeTransaction,
|
|
821
895
|
blocks,
|
|
822
896
|
_args13 = arguments;
|
|
823
897
|
|
|
824
|
-
return _regeneratorRuntime.
|
|
898
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
825
899
|
while (1) {
|
|
826
900
|
switch (_context13.prev = _context13.next) {
|
|
827
901
|
case 0:
|
|
828
|
-
|
|
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;
|
|
829
903
|
_context13.next = 3;
|
|
830
|
-
return
|
|
904
|
+
return this.FormatBlockNumbers({
|
|
831
905
|
fromBlock: fromBlock,
|
|
832
906
|
toBlock: toBlock,
|
|
833
907
|
count: count
|
|
834
|
-
})
|
|
908
|
+
});
|
|
835
909
|
|
|
836
910
|
case 3:
|
|
837
911
|
blocks = _context13.sent;
|
|
838
912
|
this.Log("Querying events - Blocks ".concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
|
|
839
913
|
_context13.next = 7;
|
|
840
|
-
return
|
|
914
|
+
return this.ethClient.Events({
|
|
841
915
|
fromBlock: blocks.fromBlock,
|
|
842
916
|
toBlock: blocks.toBlock,
|
|
843
917
|
includeTransaction: includeTransaction
|
|
844
|
-
})
|
|
918
|
+
});
|
|
845
919
|
|
|
846
920
|
case 7:
|
|
847
921
|
return _context13.abrupt("return", _context13.sent);
|
|
@@ -851,8 +925,8 @@ exports.Events = function _callee13() {
|
|
|
851
925
|
return _context13.stop();
|
|
852
926
|
}
|
|
853
927
|
}
|
|
854
|
-
},
|
|
855
|
-
};
|
|
928
|
+
}, _callee13, this);
|
|
929
|
+
}));
|
|
856
930
|
/**
|
|
857
931
|
* Retrieve the latest block number on the blockchain
|
|
858
932
|
*
|
|
@@ -861,16 +935,15 @@ exports.Events = function _callee13() {
|
|
|
861
935
|
* @returns {Promise<number>} - The latest block number
|
|
862
936
|
*/
|
|
863
937
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
return _regeneratorRuntime.async(function _callee14$(_context14) {
|
|
938
|
+
exports.BlockNumber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
939
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
867
940
|
while (1) {
|
|
868
941
|
switch (_context14.prev = _context14.next) {
|
|
869
942
|
case 0:
|
|
870
943
|
_context14.next = 2;
|
|
871
|
-
return
|
|
944
|
+
return this.ethClient.MakeProviderCall({
|
|
872
945
|
methodName: "getBlockNumber"
|
|
873
|
-
})
|
|
946
|
+
});
|
|
874
947
|
|
|
875
948
|
case 2:
|
|
876
949
|
return _context14.abrupt("return", _context14.sent);
|
|
@@ -880,8 +953,8 @@ exports.BlockNumber = function _callee14() {
|
|
|
880
953
|
return _context14.stop();
|
|
881
954
|
}
|
|
882
955
|
}
|
|
883
|
-
},
|
|
884
|
-
};
|
|
956
|
+
}, _callee14, this);
|
|
957
|
+
}));
|
|
885
958
|
/**
|
|
886
959
|
* Get the balance (in ether) of the specified address
|
|
887
960
|
*
|
|
@@ -892,32 +965,37 @@ exports.BlockNumber = function _callee14() {
|
|
|
892
965
|
* @returns {Promise<string>} - Balance of the account, in ether (as string)
|
|
893
966
|
*/
|
|
894
967
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
968
|
+
exports.GetBalance = /*#__PURE__*/function () {
|
|
969
|
+
var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref31) {
|
|
970
|
+
var address, balance;
|
|
971
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
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
|
+
}
|
|
917
991
|
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
|
|
992
|
+
}, _callee15, this);
|
|
993
|
+
}));
|
|
994
|
+
|
|
995
|
+
return function (_x13) {
|
|
996
|
+
return _ref32.apply(this, arguments);
|
|
997
|
+
};
|
|
998
|
+
}();
|
|
921
999
|
/**
|
|
922
1000
|
* Send ether from this client's current signer to the specified recipient address
|
|
923
1001
|
*
|
|
@@ -930,32 +1008,38 @@ exports.GetBalance = function _callee15(_ref17) {
|
|
|
930
1008
|
*/
|
|
931
1009
|
|
|
932
1010
|
|
|
933
|
-
exports.SendFunds = function
|
|
934
|
-
var
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1011
|
+
exports.SendFunds = /*#__PURE__*/function () {
|
|
1012
|
+
var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref33) {
|
|
1013
|
+
var recipient, ether, transaction;
|
|
1014
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
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
|
+
}
|
|
958
1038
|
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
|
|
1039
|
+
}, _callee16, this);
|
|
1040
|
+
}));
|
|
1041
|
+
|
|
1042
|
+
return function (_x14) {
|
|
1043
|
+
return _ref34.apply(this, arguments);
|
|
1044
|
+
};
|
|
1045
|
+
}();
|