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