@eluvio/elv-client-js 4.0.112 → 4.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/ElvClient-min.js +0 -67
- package/dist/ElvClient-node-min.js +0 -66
- package/dist/ElvFrameClient-min.js +0 -60
- package/dist/ElvPermissionsClient-min.js +0 -60
- package/dist/ElvWalletClient-min.js +0 -67
- package/dist/ElvWalletClient-node-min.js +0 -66
- package/dist/src/AuthorizationClient.js +0 -2157
- package/dist/src/ContentObjectAudit.js +0 -175
- package/dist/src/ContentObjectVerification.js +0 -281
- package/dist/src/Crypto.js +0 -412
- package/dist/src/ElvClient.js +0 -2022
- package/dist/src/ElvWallet.js +0 -245
- package/dist/src/EthClient.js +0 -1154
- package/dist/src/FrameClient.js +0 -485
- package/dist/src/HttpClient.js +0 -315
- package/dist/src/Id.js +0 -21
- package/dist/src/LogMessage.js +0 -25
- package/dist/src/PermissionsClient.js +0 -1544
- package/dist/src/RemoteSigner.js +0 -385
- package/dist/src/UserProfileClient.js +0 -1450
- package/dist/src/Utils.js +0 -894
- package/dist/src/Validation.js +0 -121
- package/dist/src/abr_profiles/abr_profile_live_drm.js +0 -1661
- package/dist/src/abr_profiles/abr_profile_live_to_vod.js +0 -1606
- package/dist/src/client/ABRPublishing.js +0 -1018
- package/dist/src/client/AccessGroups.js +0 -1503
- package/dist/src/client/ContentAccess.js +0 -5173
- package/dist/src/client/ContentManagement.js +0 -2680
- package/dist/src/client/Contracts.js +0 -1520
- package/dist/src/client/Files.js +0 -2181
- package/dist/src/client/LiveConf.js +0 -567
- package/dist/src/client/LiveStream.js +0 -2638
- package/dist/src/client/NFT.js +0 -162
- package/dist/src/client/NTP.js +0 -581
- package/dist/src/contracts/v2/AccessIndexor.js +0 -831
- package/dist/src/contracts/v2/Accessible.js +0 -31
- package/dist/src/contracts/v2/BaseAccessControlGroup.js +0 -1263
- package/dist/src/contracts/v2/BaseAccessWallet.js +0 -1609
- package/dist/src/contracts/v2/BaseAccessWalletFactory.js +0 -93
- package/dist/src/contracts/v2/BaseContent.js +0 -1076
- package/dist/src/contracts/v2/BaseContentFactory.js +0 -219
- package/dist/src/contracts/v2/BaseContentSpace.js +0 -1352
- package/dist/src/contracts/v2/BaseContentType.js +0 -364
- package/dist/src/contracts/v2/BaseFactory.js +0 -107
- package/dist/src/contracts/v2/BaseGroupFactory.js +0 -93
- package/dist/src/contracts/v2/BaseLibrary.js +0 -1041
- package/dist/src/contracts/v2/BaseLibraryFactory.js +0 -96
- package/dist/src/contracts/v2/Certifyer.js +0 -86
- package/dist/src/contracts/v2/Container.js +0 -540
- package/dist/src/contracts/v2/Content.js +0 -443
- package/dist/src/contracts/v2/Editable.js +0 -306
- package/dist/src/contracts/v2/ExternalUserWallet.js +0 -379
- package/dist/src/contracts/v2/IFactorySpace.js +0 -57
- package/dist/src/contracts/v2/IKmsSpace.js +0 -52
- package/dist/src/contracts/v2/INodeSpace.js +0 -18
- package/dist/src/contracts/v2/IUserSpace.js +0 -18
- package/dist/src/contracts/v2/LvRecordableStream.js +0 -1037
- package/dist/src/contracts/v2/LvRecording.js +0 -627
- package/dist/src/contracts/v2/LvStreamRightsHolder.js +0 -562
- package/dist/src/contracts/v2/MetaObject.js +0 -119
- package/dist/src/contracts/v2/Node.js +0 -167
- package/dist/src/contracts/v2/NodeSpace.js +0 -273
- package/dist/src/contracts/v2/Ownable.js +0 -87
- package/dist/src/contracts/v2/PaymentService.js +0 -627
- package/dist/src/contracts/v2/Precompile.js +0 -15
- package/dist/src/contracts/v2/Transactable.js +0 -82
- package/dist/src/contracts/v2/UserSpace.js +0 -29
- package/dist/src/contracts/v2/Utils.js +0 -18
- package/dist/src/contracts/v2/Verifier.js +0 -53
- package/dist/src/contracts/v2/strings.js +0 -4
- package/dist/src/contracts/v3/AccessIndexor.js +0 -774
- package/dist/src/contracts/v3/Accessible.js +0 -232
- package/dist/src/contracts/v3/Adminable.js +0 -107
- package/dist/src/contracts/v3/AvailsDelivery.js +0 -586
- package/dist/src/contracts/v3/BaseAccessControlGroup.js +0 -1603
- package/dist/src/contracts/v3/BaseAccessWallet.js +0 -1628
- package/dist/src/contracts/v3/BaseAccessWalletFactory.js +0 -112
- package/dist/src/contracts/v3/BaseContent.js +0 -1312
- package/dist/src/contracts/v3/BaseContentFactory.js +0 -183
- package/dist/src/contracts/v3/BaseContentFactoryExt.js +0 -175
- package/dist/src/contracts/v3/BaseContentSpace.js +0 -1515
- package/dist/src/contracts/v3/BaseContentType.js +0 -527
- package/dist/src/contracts/v3/BaseFactory.js +0 -126
- package/dist/src/contracts/v3/BaseGroupFactory.js +0 -112
- package/dist/src/contracts/v3/BaseLibrary.js +0 -1204
- package/dist/src/contracts/v3/BaseLibraryFactory.js +0 -115
- package/dist/src/contracts/v3/BaseTenantSpace.js +0 -1587
- package/dist/src/contracts/v3/Certifyer.js +0 -86
- package/dist/src/contracts/v3/Container.js +0 -739
- package/dist/src/contracts/v3/Content.js +0 -438
- package/dist/src/contracts/v3/CounterObject.js +0 -243
- package/dist/src/contracts/v3/Editable.js +0 -519
- package/dist/src/contracts/v3/EncToken.js +0 -4
- package/dist/src/contracts/v3/ExternalUserWallet.js +0 -587
- package/dist/src/contracts/v3/IAdmin.js +0 -18
- package/dist/src/contracts/v3/IFactorySpace.js +0 -57
- package/dist/src/contracts/v3/IKmsSpace.js +0 -52
- package/dist/src/contracts/v3/INodeSpace.js +0 -18
- package/dist/src/contracts/v3/IUserSpace.js +0 -32
- package/dist/src/contracts/v3/LvRecordableStream.js +0 -1032
- package/dist/src/contracts/v3/LvRecording.js +0 -650
- package/dist/src/contracts/v3/LvStreamRightsHolder.js +0 -557
- package/dist/src/contracts/v3/MetaObject.js +0 -144
- package/dist/src/contracts/v3/Node.js +0 -178
- package/dist/src/contracts/v3/NodeSpace.js +0 -284
- package/dist/src/contracts/v3/Ownable.js +0 -98
- package/dist/src/contracts/v3/PaymentService.js +0 -622
- package/dist/src/contracts/v3/Precompile.js +0 -26
- package/dist/src/contracts/v3/TenantFuncsBase.js +0 -351
- package/dist/src/contracts/v3/Transactable.js +0 -82
- package/dist/src/contracts/v3/UserSpace.js +0 -43
- package/dist/src/contracts/v3/Utils.js +0 -18
- package/dist/src/contracts/v3/Verifier.js +0 -53
- package/dist/src/contracts/v3/strings.js +0 -4
- package/dist/src/contracts/v3b/BaseAccessControlGroup.js +0 -1704
- package/dist/src/events/Topics.js +0 -1793
- package/dist/src/index.js +0 -8
- package/dist/src/walletClient/ClientMethods.js +0 -3102
- package/dist/src/walletClient/Configuration.js +0 -38
- package/dist/src/walletClient/Notifications.js +0 -168
- package/dist/src/walletClient/Profile.js +0 -332
- package/dist/src/walletClient/Utils.js +0 -281
- package/dist/src/walletClient/index.js +0 -2106
|
@@ -1,1520 +0,0 @@
|
|
|
1
|
-
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
2
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
3
|
-
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
4
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
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; }
|
|
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; }
|
|
7
|
-
/**
|
|
8
|
-
* Methods for deploying and interacting with contracts
|
|
9
|
-
*
|
|
10
|
-
* @module ElvClient/Contracts
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
var Ethers = require("ethers");
|
|
14
|
-
//const ContentContract = require("../contracts/BaseContent");
|
|
15
|
-
|
|
16
|
-
var _require = require("../Validation"),
|
|
17
|
-
ValidateAddress = _require.ValidateAddress,
|
|
18
|
-
ValidateParameters = _require.ValidateParameters,
|
|
19
|
-
ValidatePresence = _require.ValidatePresence,
|
|
20
|
-
ValidateObject = _require.ValidateObject,
|
|
21
|
-
ValidateVersion = _require.ValidateVersion;
|
|
22
|
-
var Utils = require("../Utils");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Return the name of the contract, as specified in the contracts "version" string
|
|
26
|
-
*
|
|
27
|
-
* @methodGroup Contracts
|
|
28
|
-
*
|
|
29
|
-
* @namedParams
|
|
30
|
-
* @param {string} contractAddress - Address of the contract
|
|
31
|
-
*
|
|
32
|
-
* @return {Promise<string>} - Name of the contract
|
|
33
|
-
*/
|
|
34
|
-
exports.ContractName = /*#__PURE__*/function () {
|
|
35
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
36
|
-
var contractAddress;
|
|
37
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
38
|
-
while (1) switch (_context.prev = _context.next) {
|
|
39
|
-
case 0:
|
|
40
|
-
contractAddress = _ref.contractAddress;
|
|
41
|
-
contractAddress = ValidateAddress(contractAddress);
|
|
42
|
-
_context.next = 4;
|
|
43
|
-
return this.ethClient.ContractName(contractAddress);
|
|
44
|
-
case 4:
|
|
45
|
-
return _context.abrupt("return", _context.sent);
|
|
46
|
-
case 5:
|
|
47
|
-
case "end":
|
|
48
|
-
return _context.stop();
|
|
49
|
-
}
|
|
50
|
-
}, _callee, this);
|
|
51
|
-
}));
|
|
52
|
-
return function (_x) {
|
|
53
|
-
return _ref2.apply(this, arguments);
|
|
54
|
-
};
|
|
55
|
-
}();
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Retrieve the ABI for the given contract via its address or a Fabric ID. Contract must be a standard Eluvio contract
|
|
59
|
-
*
|
|
60
|
-
* @methodGroup Contracts
|
|
61
|
-
* @namedParams
|
|
62
|
-
* @param {string=} contractAddress - The address of the contract
|
|
63
|
-
* @param {string=} id - The Fabric ID of the contract
|
|
64
|
-
*
|
|
65
|
-
* @return {Promise<Object>} - The ABI for the given contract
|
|
66
|
-
*
|
|
67
|
-
* @throws If ABI is not able to be determined, throws an error
|
|
68
|
-
*/
|
|
69
|
-
exports.ContractAbi = /*#__PURE__*/function () {
|
|
70
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
71
|
-
var contractAddress, id, contractInfo;
|
|
72
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
73
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
74
|
-
case 0:
|
|
75
|
-
contractAddress = _ref3.contractAddress, id = _ref3.id;
|
|
76
|
-
_context2.next = 3;
|
|
77
|
-
return this.authClient.ContractInfo({
|
|
78
|
-
address: contractAddress,
|
|
79
|
-
id: id
|
|
80
|
-
});
|
|
81
|
-
case 3:
|
|
82
|
-
contractInfo = _context2.sent;
|
|
83
|
-
if (contractInfo) {
|
|
84
|
-
_context2.next = 6;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
throw Error("Unable to determine contract info for ".concat(contractAddress));
|
|
88
|
-
case 6:
|
|
89
|
-
return _context2.abrupt("return", contractInfo.abi);
|
|
90
|
-
case 7:
|
|
91
|
-
case "end":
|
|
92
|
-
return _context2.stop();
|
|
93
|
-
}
|
|
94
|
-
}, _callee2, this);
|
|
95
|
-
}));
|
|
96
|
-
return function (_x2) {
|
|
97
|
-
return _ref4.apply(this, arguments);
|
|
98
|
-
};
|
|
99
|
-
}();
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Retrieve the ABI, access type, and whether V3 is used for a given contract via its address or a Fabric ID.
|
|
103
|
-
*
|
|
104
|
-
* @methodGroup Contracts
|
|
105
|
-
* @namedParams
|
|
106
|
-
* @param {string=} id - The Fabric ID of the contract
|
|
107
|
-
* @param {string=} address - The address of the contract
|
|
108
|
-
*
|
|
109
|
-
* @return {Promise<Object>} - The ABI, access type, and isV3 for the given contract
|
|
110
|
-
*/
|
|
111
|
-
exports.ContractInfo = /*#__PURE__*/function () {
|
|
112
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
113
|
-
var id, address;
|
|
114
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
115
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
116
|
-
case 0:
|
|
117
|
-
id = _ref5.id, address = _ref5.address;
|
|
118
|
-
return _context3.abrupt("return", this.authClient.ContractInfo({
|
|
119
|
-
id: id,
|
|
120
|
-
address: address
|
|
121
|
-
}));
|
|
122
|
-
case 2:
|
|
123
|
-
case "end":
|
|
124
|
-
return _context3.stop();
|
|
125
|
-
}
|
|
126
|
-
}, _callee3, this);
|
|
127
|
-
}));
|
|
128
|
-
return function (_x3) {
|
|
129
|
-
return _ref6.apply(this, arguments);
|
|
130
|
-
};
|
|
131
|
-
}();
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Format the arguments to be used for the specified method of the contract
|
|
135
|
-
*
|
|
136
|
-
* @methodGroup Contracts
|
|
137
|
-
* @namedParams
|
|
138
|
-
* @param {Object} abi - ABI of contract
|
|
139
|
-
* @param {string} methodName - Name of method for which arguments will be formatted
|
|
140
|
-
* @param {Array<string>} args - List of arguments
|
|
141
|
-
*
|
|
142
|
-
* @returns {Array<string>} - List of formatted arguments
|
|
143
|
-
*/
|
|
144
|
-
exports.FormatContractArguments = function (_ref7) {
|
|
145
|
-
var abi = _ref7.abi,
|
|
146
|
-
methodName = _ref7.methodName,
|
|
147
|
-
args = _ref7.args;
|
|
148
|
-
return this.ethClient.FormatContractArguments({
|
|
149
|
-
abi: abi,
|
|
150
|
-
methodName: methodName,
|
|
151
|
-
args: args
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Deploy a contract from ABI and bytecode. This client's signer will be the owner of the contract.
|
|
157
|
-
*
|
|
158
|
-
* @methodGroup Contracts
|
|
159
|
-
* @namedParams
|
|
160
|
-
* @param {Object} abi - ABI of contract
|
|
161
|
-
* @param {string} bytecode - Bytecode of the contract
|
|
162
|
-
* @param {Array<string>} constructorArgs - List of arguments to the contract constructor
|
|
163
|
-
* @param {Object=} overrides - Change default gasPrice or gasLimit used for this action
|
|
164
|
-
*
|
|
165
|
-
* @returns {Promise<Object>} - Response containing the deployed contract address and the transaction hash of the deployment
|
|
166
|
-
*/
|
|
167
|
-
exports.DeployContract = /*#__PURE__*/function () {
|
|
168
|
-
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref8) {
|
|
169
|
-
var abi, bytecode, constructorArgs, _ref8$overrides, overrides;
|
|
170
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
171
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
172
|
-
case 0:
|
|
173
|
-
abi = _ref8.abi, bytecode = _ref8.bytecode, constructorArgs = _ref8.constructorArgs, _ref8$overrides = _ref8.overrides, overrides = _ref8$overrides === void 0 ? {} : _ref8$overrides;
|
|
174
|
-
_context4.next = 3;
|
|
175
|
-
return this.ethClient.DeployContract({
|
|
176
|
-
abi: abi,
|
|
177
|
-
bytecode: bytecode,
|
|
178
|
-
constructorArgs: constructorArgs,
|
|
179
|
-
overrides: overrides,
|
|
180
|
-
signer: this.signer
|
|
181
|
-
});
|
|
182
|
-
case 3:
|
|
183
|
-
return _context4.abrupt("return", _context4.sent);
|
|
184
|
-
case 4:
|
|
185
|
-
case "end":
|
|
186
|
-
return _context4.stop();
|
|
187
|
-
}
|
|
188
|
-
}, _callee4, this);
|
|
189
|
-
}));
|
|
190
|
-
return function (_x4) {
|
|
191
|
-
return _ref9.apply(this, arguments);
|
|
192
|
-
};
|
|
193
|
-
}();
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Get all events on the specified contract
|
|
197
|
-
*
|
|
198
|
-
* @methodGroup Contracts
|
|
199
|
-
* @namedParams
|
|
200
|
-
* @param {string} contractAddress - The address of the contract
|
|
201
|
-
* @param {Object=} abi - ABI of contract - If the contract is a standard Eluvio contract, this can be determined automatically if not specified
|
|
202
|
-
* @param {number=} fromBlock - Limit results to events after the specified block (inclusive)
|
|
203
|
-
* @param {number=} toBlock - Limit results to events before the specified block (inclusive)
|
|
204
|
-
* @param {number=} count=1000 - Maximum range of blocks to search (unless both toBlock and fromBlock are specified)
|
|
205
|
-
* @param {boolean=} includeTransaction=false - If specified, more detailed transaction info will be included.
|
|
206
|
-
* Note: This requires one extra network call per block, so it should not be used for very large ranges
|
|
207
|
-
* @returns {Promise<Array<Array<Object>>>} - List of blocks, in ascending order by block number, each containing a list of the events in the block.
|
|
208
|
-
*/
|
|
209
|
-
exports.ContractEvents = /*#__PURE__*/function () {
|
|
210
|
-
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref10) {
|
|
211
|
-
var contractAddress, abi, _ref10$fromBlock, fromBlock, toBlock, _ref10$count, count, topics, _ref10$includeTransac, includeTransaction, blocks;
|
|
212
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
213
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
214
|
-
case 0:
|
|
215
|
-
contractAddress = _ref10.contractAddress, abi = _ref10.abi, _ref10$fromBlock = _ref10.fromBlock, fromBlock = _ref10$fromBlock === void 0 ? 0 : _ref10$fromBlock, toBlock = _ref10.toBlock, _ref10$count = _ref10.count, count = _ref10$count === void 0 ? 1000 : _ref10$count, topics = _ref10.topics, _ref10$includeTransac = _ref10.includeTransaction, includeTransaction = _ref10$includeTransac === void 0 ? false : _ref10$includeTransac;
|
|
216
|
-
contractAddress = ValidateAddress(contractAddress);
|
|
217
|
-
if (abi) {
|
|
218
|
-
_context5.next = 6;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
_context5.next = 5;
|
|
222
|
-
return this.ContractAbi({
|
|
223
|
-
contractAddress: contractAddress
|
|
224
|
-
});
|
|
225
|
-
case 5:
|
|
226
|
-
abi = _context5.sent;
|
|
227
|
-
case 6:
|
|
228
|
-
_context5.next = 8;
|
|
229
|
-
return this.FormatBlockNumbers({
|
|
230
|
-
fromBlock: fromBlock,
|
|
231
|
-
toBlock: toBlock,
|
|
232
|
-
count: count
|
|
233
|
-
});
|
|
234
|
-
case 8:
|
|
235
|
-
blocks = _context5.sent;
|
|
236
|
-
this.Log("Querying contract events ".concat(contractAddress, " - Blocks ").concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
|
|
237
|
-
_context5.next = 12;
|
|
238
|
-
return this.ethClient.ContractEvents({
|
|
239
|
-
contractAddress: contractAddress,
|
|
240
|
-
abi: abi,
|
|
241
|
-
fromBlock: blocks.fromBlock,
|
|
242
|
-
toBlock: blocks.toBlock,
|
|
243
|
-
topics: topics,
|
|
244
|
-
includeTransaction: includeTransaction
|
|
245
|
-
});
|
|
246
|
-
case 12:
|
|
247
|
-
return _context5.abrupt("return", _context5.sent);
|
|
248
|
-
case 13:
|
|
249
|
-
case "end":
|
|
250
|
-
return _context5.stop();
|
|
251
|
-
}
|
|
252
|
-
}, _callee5, this);
|
|
253
|
-
}));
|
|
254
|
-
return function (_x5) {
|
|
255
|
-
return _ref11.apply(this, arguments);
|
|
256
|
-
};
|
|
257
|
-
}();
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Call the specified method on a deployed contract. This action will be performed by this client's signer.
|
|
261
|
-
*
|
|
262
|
-
* Use this method to call constant methods and contract attributes, as well as transaction-performing methods
|
|
263
|
-
* for which the transaction does not need to be awaited.
|
|
264
|
-
*
|
|
265
|
-
* @methodGroup Contracts
|
|
266
|
-
* @namedParams
|
|
267
|
-
* @param {string} contractAddress - Address of the contract to call the specified method on
|
|
268
|
-
* @param {Object=} abi - ABI of contract - If the contract is a standard Eluvio contract, this can be determined automatically if not specified
|
|
269
|
-
* @param {string} methodName - Method to call on the contract
|
|
270
|
-
* @param {Array=} methodArgs - List of arguments to the contract constructor
|
|
271
|
-
* @param {(number | BigNumber)=} value - Amount of ether to include in the transaction
|
|
272
|
-
* @param {boolean=} formatArguments=true - If specified, the arguments will automatically be formatted to the ABI specification
|
|
273
|
-
* @param {Object=} overrides - Change default gasPrice or gasLimit used for this action
|
|
274
|
-
*
|
|
275
|
-
* @returns {Promise<*>} - Response containing information about the transaction
|
|
276
|
-
*/
|
|
277
|
-
exports.CallContractMethod = /*#__PURE__*/function () {
|
|
278
|
-
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref12) {
|
|
279
|
-
var contractAddress, abi, methodName, _ref12$methodArgs, methodArgs, value, _ref12$overrides, overrides, _ref12$formatArgument, formatArguments, _ref12$cacheContract, cacheContract, _ref12$overrideCached, overrideCachedContract;
|
|
280
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
281
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
282
|
-
case 0:
|
|
283
|
-
contractAddress = _ref12.contractAddress, abi = _ref12.abi, methodName = _ref12.methodName, _ref12$methodArgs = _ref12.methodArgs, methodArgs = _ref12$methodArgs === void 0 ? [] : _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;
|
|
284
|
-
contractAddress = ValidateAddress(contractAddress);
|
|
285
|
-
|
|
286
|
-
// Delete cached visibility value if it is being changed
|
|
287
|
-
contractAddress = this.utils.FormatAddress(contractAddress);
|
|
288
|
-
if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
|
|
289
|
-
delete this.visibilityInfo[contractAddress];
|
|
290
|
-
}
|
|
291
|
-
if (abi) {
|
|
292
|
-
_context6.next = 8;
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
_context6.next = 7;
|
|
296
|
-
return this.ContractAbi({
|
|
297
|
-
contractAddress: contractAddress
|
|
298
|
-
});
|
|
299
|
-
case 7:
|
|
300
|
-
abi = _context6.sent;
|
|
301
|
-
case 8:
|
|
302
|
-
_context6.next = 10;
|
|
303
|
-
return this.ethClient.CallContractMethod({
|
|
304
|
-
contractAddress: contractAddress,
|
|
305
|
-
abi: abi,
|
|
306
|
-
methodName: methodName,
|
|
307
|
-
methodArgs: methodArgs,
|
|
308
|
-
value: value,
|
|
309
|
-
overrides: overrides,
|
|
310
|
-
formatArguments: formatArguments,
|
|
311
|
-
cacheContract: cacheContract,
|
|
312
|
-
overrideCachedContract: overrideCachedContract
|
|
313
|
-
});
|
|
314
|
-
case 10:
|
|
315
|
-
return _context6.abrupt("return", _context6.sent);
|
|
316
|
-
case 11:
|
|
317
|
-
case "end":
|
|
318
|
-
return _context6.stop();
|
|
319
|
-
}
|
|
320
|
-
}, _callee6, this);
|
|
321
|
-
}));
|
|
322
|
-
return function (_x6) {
|
|
323
|
-
return _ref13.apply(this, arguments);
|
|
324
|
-
};
|
|
325
|
-
}();
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Call the specified method on a deployed contract and wait for the transaction to be mined.
|
|
329
|
-
* This action will be performed by this client's signer.
|
|
330
|
-
*
|
|
331
|
-
* Use this method to call transaction-performing methods and wait for the transaction to complete.
|
|
332
|
-
*
|
|
333
|
-
* @methodGroup Contracts
|
|
334
|
-
* @namedParams
|
|
335
|
-
* @param {string} contractAddress - Address of the contract to call the specified method on
|
|
336
|
-
* @param {Object=} abi - ABI of contract - If the contract is a standard Eluvio contract, this can be determined automatically if not specified
|
|
337
|
-
* @param {string} methodName - Method to call on the contract
|
|
338
|
-
* @param {Array<string>=} methodArgs=[] - List of arguments to the contract constructor
|
|
339
|
-
* @param {(number | BigNumber)=} value - Amount of ether to include in the transaction
|
|
340
|
-
* @param {Object=} overrides - Change default gasPrice or gasLimit used for this action
|
|
341
|
-
* @param {boolean=} formatArguments=true - If specified, the arguments will automatically be formatted to the ABI specification
|
|
342
|
-
*
|
|
343
|
-
* @see Utils.WeiToEther
|
|
344
|
-
*
|
|
345
|
-
* @returns {Promise<*>} - The event object of this transaction. See the ExtractEventFromLogs method for parsing
|
|
346
|
-
* the resulting event(s)
|
|
347
|
-
*/
|
|
348
|
-
exports.CallContractMethodAndWait = /*#__PURE__*/function () {
|
|
349
|
-
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref14) {
|
|
350
|
-
var contractAddress, abi, methodName, methodArgs, value, _ref14$overrides, overrides, _ref14$formatArgument, formatArguments, _ref14$cacheContract, cacheContract, _ref14$overrideCached, overrideCachedContract;
|
|
351
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
352
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
353
|
-
case 0:
|
|
354
|
-
contractAddress = _ref14.contractAddress, abi = _ref14.abi, methodName = _ref14.methodName, methodArgs = _ref14.methodArgs, value = _ref14.value, _ref14$overrides = _ref14.overrides, overrides = _ref14$overrides === void 0 ? {} : _ref14$overrides, _ref14$formatArgument = _ref14.formatArguments, formatArguments = _ref14$formatArgument === void 0 ? true : _ref14$formatArgument, _ref14$cacheContract = _ref14.cacheContract, cacheContract = _ref14$cacheContract === void 0 ? true : _ref14$cacheContract, _ref14$overrideCached = _ref14.overrideCachedContract, overrideCachedContract = _ref14$overrideCached === void 0 ? false : _ref14$overrideCached;
|
|
355
|
-
contractAddress = ValidateAddress(contractAddress);
|
|
356
|
-
|
|
357
|
-
// Delete cached visibility value if it is being changed
|
|
358
|
-
contractAddress = this.utils.FormatAddress(contractAddress);
|
|
359
|
-
if (methodName === "setVisibility" && this.visibilityInfo[contractAddress]) {
|
|
360
|
-
delete this.visibilityInfo[contractAddress];
|
|
361
|
-
}
|
|
362
|
-
if (abi) {
|
|
363
|
-
_context7.next = 8;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
_context7.next = 7;
|
|
367
|
-
return this.ContractAbi({
|
|
368
|
-
contractAddress: contractAddress
|
|
369
|
-
});
|
|
370
|
-
case 7:
|
|
371
|
-
abi = _context7.sent;
|
|
372
|
-
case 8:
|
|
373
|
-
_context7.next = 10;
|
|
374
|
-
return this.ethClient.CallContractMethodAndWait({
|
|
375
|
-
contractAddress: contractAddress,
|
|
376
|
-
abi: abi,
|
|
377
|
-
methodName: methodName,
|
|
378
|
-
methodArgs: methodArgs,
|
|
379
|
-
value: value,
|
|
380
|
-
overrides: overrides,
|
|
381
|
-
formatArguments: formatArguments,
|
|
382
|
-
cacheContract: cacheContract,
|
|
383
|
-
overrideCachedContract: overrideCachedContract
|
|
384
|
-
});
|
|
385
|
-
case 10:
|
|
386
|
-
return _context7.abrupt("return", _context7.sent);
|
|
387
|
-
case 11:
|
|
388
|
-
case "end":
|
|
389
|
-
return _context7.stop();
|
|
390
|
-
}
|
|
391
|
-
}, _callee7, this);
|
|
392
|
-
}));
|
|
393
|
-
return function (_x7) {
|
|
394
|
-
return _ref15.apply(this, arguments);
|
|
395
|
-
};
|
|
396
|
-
}();
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Retrieve metadata from the specified contract
|
|
400
|
-
*
|
|
401
|
-
* @methodGroup Contracts
|
|
402
|
-
* @namedParams
|
|
403
|
-
* @param {string} contractAddress - The address of the contract
|
|
404
|
-
* @param {string} metadataKey - The metadata key to retrieve
|
|
405
|
-
*
|
|
406
|
-
* @return {Promise<Object|string>}
|
|
407
|
-
*/
|
|
408
|
-
exports.ContractMetadata = /*#__PURE__*/function () {
|
|
409
|
-
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref16) {
|
|
410
|
-
var contractAddress, metadataKey, metadata, data;
|
|
411
|
-
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
412
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
413
|
-
case 0:
|
|
414
|
-
contractAddress = _ref16.contractAddress, metadataKey = _ref16.metadataKey;
|
|
415
|
-
ValidatePresence("contractAddress", contractAddress);
|
|
416
|
-
ValidatePresence("metadataKey", metadataKey);
|
|
417
|
-
_context8.prev = 3;
|
|
418
|
-
_context8.next = 6;
|
|
419
|
-
return this.CallContractMethod({
|
|
420
|
-
contractAddress: contractAddress,
|
|
421
|
-
methodName: "getMeta",
|
|
422
|
-
methodArgs: [metadataKey]
|
|
423
|
-
});
|
|
424
|
-
case 6:
|
|
425
|
-
metadata = _context8.sent;
|
|
426
|
-
data = Buffer.from((metadata || "").replace("0x", ""), "hex").toString("utf-8");
|
|
427
|
-
_context8.prev = 8;
|
|
428
|
-
return _context8.abrupt("return", JSON.parse(data));
|
|
429
|
-
case 12:
|
|
430
|
-
_context8.prev = 12;
|
|
431
|
-
_context8.t0 = _context8["catch"](8);
|
|
432
|
-
return _context8.abrupt("return", data);
|
|
433
|
-
case 15:
|
|
434
|
-
_context8.next = 20;
|
|
435
|
-
break;
|
|
436
|
-
case 17:
|
|
437
|
-
_context8.prev = 17;
|
|
438
|
-
_context8.t1 = _context8["catch"](3);
|
|
439
|
-
return _context8.abrupt("return", "");
|
|
440
|
-
case 20:
|
|
441
|
-
case "end":
|
|
442
|
-
return _context8.stop();
|
|
443
|
-
}
|
|
444
|
-
}, _callee8, this, [[3, 17], [8, 12]]);
|
|
445
|
-
}));
|
|
446
|
-
return function (_x8) {
|
|
447
|
-
return _ref17.apply(this, arguments);
|
|
448
|
-
};
|
|
449
|
-
}();
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Merge contract metadata at the specified key.
|
|
453
|
-
*
|
|
454
|
-
* @methodGroup Contracts
|
|
455
|
-
* @namedParams
|
|
456
|
-
* @param {string} contractAddress - The address of the contract
|
|
457
|
-
* @param {string} metadataKey - The metadata key to retrieve
|
|
458
|
-
* @param {string} metadata
|
|
459
|
-
*/
|
|
460
|
-
exports.MergeContractMetadata = /*#__PURE__*/function () {
|
|
461
|
-
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref18) {
|
|
462
|
-
var contractAddress, metadataKey, metadata, existingMetadata;
|
|
463
|
-
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
464
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
465
|
-
case 0:
|
|
466
|
-
contractAddress = _ref18.contractAddress, metadataKey = _ref18.metadataKey, metadata = _ref18.metadata;
|
|
467
|
-
ValidatePresence("contractAddress", contractAddress);
|
|
468
|
-
ValidatePresence("metadataKey", metadataKey);
|
|
469
|
-
_context9.next = 5;
|
|
470
|
-
return this.ContractMetadata({
|
|
471
|
-
contractAddress: contractAddress,
|
|
472
|
-
metadataKey: metadataKey
|
|
473
|
-
});
|
|
474
|
-
case 5:
|
|
475
|
-
_context9.t0 = _context9.sent;
|
|
476
|
-
if (_context9.t0) {
|
|
477
|
-
_context9.next = 8;
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
_context9.t0 = {};
|
|
481
|
-
case 8:
|
|
482
|
-
existingMetadata = _context9.t0;
|
|
483
|
-
if (_typeof(existingMetadata) === "object") {
|
|
484
|
-
metadata = _objectSpread(_objectSpread({}, existingMetadata), metadata);
|
|
485
|
-
}
|
|
486
|
-
_context9.next = 12;
|
|
487
|
-
return this.CallContractMethodAndWait({
|
|
488
|
-
contractAddress: contractAddress,
|
|
489
|
-
methodName: "putMeta",
|
|
490
|
-
methodArgs: [metadataKey, JSON.stringify(metadata)]
|
|
491
|
-
});
|
|
492
|
-
case 12:
|
|
493
|
-
case "end":
|
|
494
|
-
return _context9.stop();
|
|
495
|
-
}
|
|
496
|
-
}, _callee9, this);
|
|
497
|
-
}));
|
|
498
|
-
return function (_x9) {
|
|
499
|
-
return _ref19.apply(this, arguments);
|
|
500
|
-
};
|
|
501
|
-
}();
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Replace the contract metadata at the specified key
|
|
505
|
-
*
|
|
506
|
-
* @methodGroup Contracts
|
|
507
|
-
* @namedParams
|
|
508
|
-
* @param {string} contractAddress - The address of the contract
|
|
509
|
-
* @param {string} metadataKey - The metadata key to retrieve
|
|
510
|
-
* @param {string|Object} metadata - The metadata to insert
|
|
511
|
-
*/
|
|
512
|
-
exports.ReplaceContractMetadata = /*#__PURE__*/function () {
|
|
513
|
-
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref20) {
|
|
514
|
-
var contractAddress, metadataKey, metadata;
|
|
515
|
-
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
516
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
517
|
-
case 0:
|
|
518
|
-
contractAddress = _ref20.contractAddress, metadataKey = _ref20.metadataKey, metadata = _ref20.metadata;
|
|
519
|
-
ValidatePresence("contractAddress", contractAddress);
|
|
520
|
-
ValidatePresence("metadataKey", metadataKey);
|
|
521
|
-
if (_typeof(metadata) === "object") {
|
|
522
|
-
metadata = JSON.stringify(metadata);
|
|
523
|
-
}
|
|
524
|
-
_context10.next = 6;
|
|
525
|
-
return this.CallContractMethodAndWait({
|
|
526
|
-
contractAddress: contractAddress,
|
|
527
|
-
methodName: "putMeta",
|
|
528
|
-
methodArgs: [metadataKey, metadata]
|
|
529
|
-
});
|
|
530
|
-
case 6:
|
|
531
|
-
case "end":
|
|
532
|
-
return _context10.stop();
|
|
533
|
-
}
|
|
534
|
-
}, _callee10, this);
|
|
535
|
-
}));
|
|
536
|
-
return function (_x10) {
|
|
537
|
-
return _ref21.apply(this, arguments);
|
|
538
|
-
};
|
|
539
|
-
}();
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Get the custom contract of the specified object
|
|
543
|
-
*
|
|
544
|
-
* @methodGroup Contracts
|
|
545
|
-
* @namedParams
|
|
546
|
-
* @param {string=} libraryId - ID of the library
|
|
547
|
-
* @param {string=} objectId - ID of the object
|
|
548
|
-
* @param {string=} versionHash - Version hash of the object
|
|
549
|
-
*
|
|
550
|
-
* @returns {Promise<string> | undefined} - If the object has a custom contract, this will return the address of the custom contract
|
|
551
|
-
*/
|
|
552
|
-
exports.CustomContractAddress = /*#__PURE__*/function () {
|
|
553
|
-
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref22) {
|
|
554
|
-
var libraryId, objectId, versionHash, abi, customContractAddress;
|
|
555
|
-
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
556
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
557
|
-
case 0:
|
|
558
|
-
libraryId = _ref22.libraryId, objectId = _ref22.objectId, versionHash = _ref22.versionHash;
|
|
559
|
-
ValidateParameters({
|
|
560
|
-
libraryId: libraryId,
|
|
561
|
-
objectId: objectId,
|
|
562
|
-
versionHash: versionHash
|
|
563
|
-
});
|
|
564
|
-
if (versionHash) {
|
|
565
|
-
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
566
|
-
}
|
|
567
|
-
if (!(libraryId === this.contentSpaceLibraryId || this.utils.EqualHash(libraryId, objectId))) {
|
|
568
|
-
_context11.next = 5;
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
return _context11.abrupt("return");
|
|
572
|
-
case 5:
|
|
573
|
-
this.Log("Retrieving custom contract address: ".concat(objectId));
|
|
574
|
-
_context11.next = 8;
|
|
575
|
-
return this.ContractAbi({
|
|
576
|
-
id: objectId
|
|
577
|
-
});
|
|
578
|
-
case 8:
|
|
579
|
-
abi = _context11.sent;
|
|
580
|
-
_context11.next = 11;
|
|
581
|
-
return this.ethClient.CallContractMethod({
|
|
582
|
-
contractAddress: this.utils.HashToAddress(objectId),
|
|
583
|
-
abi: abi,
|
|
584
|
-
methodName: "contentContractAddress",
|
|
585
|
-
methodArgs: []
|
|
586
|
-
});
|
|
587
|
-
case 11:
|
|
588
|
-
customContractAddress = _context11.sent;
|
|
589
|
-
if (!(customContractAddress === this.utils.nullAddress)) {
|
|
590
|
-
_context11.next = 14;
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
return _context11.abrupt("return");
|
|
594
|
-
case 14:
|
|
595
|
-
return _context11.abrupt("return", this.utils.FormatAddress(customContractAddress));
|
|
596
|
-
case 15:
|
|
597
|
-
case "end":
|
|
598
|
-
return _context11.stop();
|
|
599
|
-
}
|
|
600
|
-
}, _callee11, this);
|
|
601
|
-
}));
|
|
602
|
-
return function (_x11) {
|
|
603
|
-
return _ref23.apply(this, arguments);
|
|
604
|
-
};
|
|
605
|
-
}();
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Set the custom contract of the specified object with the contract at the specified address
|
|
609
|
-
*
|
|
610
|
-
* Note: This also updates the content object metadata with information about the contract - particularly the ABI
|
|
611
|
-
*
|
|
612
|
-
* @methodGroup Contracts
|
|
613
|
-
* @namedParams
|
|
614
|
-
* @param {string} libraryId - ID of the library
|
|
615
|
-
* @param {string} objectId - ID of the object
|
|
616
|
-
* @param {string} customContractAddress - Address of the deployed custom contract
|
|
617
|
-
* @param {string=} name - Optional name of the custom contract
|
|
618
|
-
* @param {string=} description - Optional description of the custom contract
|
|
619
|
-
* @param {Object} abi - ABI of the custom contract
|
|
620
|
-
* @param {Object=} factoryAbi - If the custom contract is a factory, the ABI of the contract it deploys
|
|
621
|
-
* @param {Object=} overrides - Change default gasPrice or gasLimit used for this action
|
|
622
|
-
*
|
|
623
|
-
* @returns {Promise<Object>} - Result transaction of calling the setCustomContract method on the content object contract
|
|
624
|
-
*/
|
|
625
|
-
exports.SetCustomContentContract = /*#__PURE__*/function () {
|
|
626
|
-
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref24) {
|
|
627
|
-
var libraryId, objectId, customContractAddress, name, description, abi, factoryAbi, _ref24$overrides, overrides, setResult, writeToken;
|
|
628
|
-
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
629
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
630
|
-
case 0:
|
|
631
|
-
libraryId = _ref24.libraryId, objectId = _ref24.objectId, customContractAddress = _ref24.customContractAddress, name = _ref24.name, description = _ref24.description, abi = _ref24.abi, factoryAbi = _ref24.factoryAbi, _ref24$overrides = _ref24.overrides, overrides = _ref24$overrides === void 0 ? {} : _ref24$overrides;
|
|
632
|
-
ValidateParameters({
|
|
633
|
-
libraryId: libraryId,
|
|
634
|
-
objectId: objectId
|
|
635
|
-
});
|
|
636
|
-
customContractAddress = ValidateAddress(customContractAddress);
|
|
637
|
-
customContractAddress = this.utils.FormatAddress(customContractAddress);
|
|
638
|
-
this.Log("Setting custom contract address: ".concat(objectId, " ").concat(customContractAddress));
|
|
639
|
-
_context12.next = 7;
|
|
640
|
-
return this.ethClient.SetCustomContentContract({
|
|
641
|
-
contentContractAddress: this.utils.HashToAddress(objectId),
|
|
642
|
-
customContractAddress: customContractAddress,
|
|
643
|
-
overrides: overrides,
|
|
644
|
-
signer: this.signer
|
|
645
|
-
});
|
|
646
|
-
case 7:
|
|
647
|
-
setResult = _context12.sent;
|
|
648
|
-
_context12.next = 10;
|
|
649
|
-
return this.EditContentObject({
|
|
650
|
-
libraryId: libraryId,
|
|
651
|
-
objectId: objectId
|
|
652
|
-
});
|
|
653
|
-
case 10:
|
|
654
|
-
writeToken = _context12.sent.write_token;
|
|
655
|
-
_context12.next = 13;
|
|
656
|
-
return this.ReplaceMetadata({
|
|
657
|
-
libraryId: libraryId,
|
|
658
|
-
objectId: objectId,
|
|
659
|
-
writeToken: writeToken,
|
|
660
|
-
metadataSubtree: "custom_contract",
|
|
661
|
-
metadata: {
|
|
662
|
-
name: name,
|
|
663
|
-
description: description,
|
|
664
|
-
address: customContractAddress,
|
|
665
|
-
abi: abi,
|
|
666
|
-
factoryAbi: factoryAbi
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
case 13:
|
|
670
|
-
_context12.next = 15;
|
|
671
|
-
return this.FinalizeContentObject({
|
|
672
|
-
libraryId: libraryId,
|
|
673
|
-
objectId: objectId,
|
|
674
|
-
writeToken: writeToken,
|
|
675
|
-
commitMessage: "Set custom contract"
|
|
676
|
-
});
|
|
677
|
-
case 15:
|
|
678
|
-
return _context12.abrupt("return", setResult);
|
|
679
|
-
case 16:
|
|
680
|
-
case "end":
|
|
681
|
-
return _context12.stop();
|
|
682
|
-
}
|
|
683
|
-
}, _callee12, this);
|
|
684
|
-
}));
|
|
685
|
-
return function (_x12) {
|
|
686
|
-
return _ref25.apply(this, arguments);
|
|
687
|
-
};
|
|
688
|
-
}();
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Extract the specified event log from the given event obtained from the
|
|
692
|
-
* CallContractAndMethodAndWait method
|
|
693
|
-
*
|
|
694
|
-
* @methodGroup Contracts
|
|
695
|
-
* @namedParams
|
|
696
|
-
* @param {string} contractAddress - Address of the contract to call the specified method on
|
|
697
|
-
*
|
|
698
|
-
* @param {Object} event - Event of the transaction from CallContractMethodAndWait
|
|
699
|
-
* @param {string} eventName - Name of the event to parse
|
|
700
|
-
*
|
|
701
|
-
* @see Utils.WeiToEther
|
|
702
|
-
*
|
|
703
|
-
* @returns {Promise<Object>} - The parsed event log from the event
|
|
704
|
-
*/
|
|
705
|
-
exports.ExtractEventFromLogs = function (_ref26) {
|
|
706
|
-
var abi = _ref26.abi,
|
|
707
|
-
event = _ref26.event,
|
|
708
|
-
eventName = _ref26.eventName;
|
|
709
|
-
return this.ethClient.ExtractEventFromLogs({
|
|
710
|
-
abi: abi,
|
|
711
|
-
event: event,
|
|
712
|
-
eventName: eventName
|
|
713
|
-
});
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Extract the specified value from the specified event log from the given event obtained
|
|
718
|
-
* from the CallContractAndMethodAndWait method
|
|
719
|
-
*
|
|
720
|
-
* @methodGroup Contracts
|
|
721
|
-
* @namedParams
|
|
722
|
-
* @param {string} contractAddress - Address of the contract to call the specified method on
|
|
723
|
-
* @param {Object} abi - ABI of contract
|
|
724
|
-
* @param {Object} event - Event of the transaction from CallContractMethodAndWait
|
|
725
|
-
* @param {string} eventName - Name of the event to parse
|
|
726
|
-
* @param {string} eventValue - Name of the value to extract from the event
|
|
727
|
-
*
|
|
728
|
-
* @returns {Promise<string>} The value extracted from the event
|
|
729
|
-
*/
|
|
730
|
-
exports.ExtractValueFromEvent = function (_ref27) {
|
|
731
|
-
var abi = _ref27.abi,
|
|
732
|
-
event = _ref27.event,
|
|
733
|
-
eventName = _ref27.eventName,
|
|
734
|
-
eventValue = _ref27.eventValue;
|
|
735
|
-
var eventLog = this.ethClient.ExtractEventFromLogs({
|
|
736
|
-
abi: abi,
|
|
737
|
-
event: event,
|
|
738
|
-
eventName: eventName,
|
|
739
|
-
eventValue: eventValue
|
|
740
|
-
});
|
|
741
|
-
return eventLog ? eventLog.args[eventValue] : undefined;
|
|
742
|
-
};
|
|
743
|
-
exports.FormatBlockNumbers = /*#__PURE__*/function () {
|
|
744
|
-
var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref28) {
|
|
745
|
-
var fromBlock, toBlock, _ref28$count, count, latestBlock;
|
|
746
|
-
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
747
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
748
|
-
case 0:
|
|
749
|
-
fromBlock = _ref28.fromBlock, toBlock = _ref28.toBlock, _ref28$count = _ref28.count, count = _ref28$count === void 0 ? 10 : _ref28$count;
|
|
750
|
-
_context13.next = 3;
|
|
751
|
-
return this.BlockNumber();
|
|
752
|
-
case 3:
|
|
753
|
-
latestBlock = _context13.sent;
|
|
754
|
-
if (!toBlock) {
|
|
755
|
-
if (!fromBlock) {
|
|
756
|
-
toBlock = latestBlock;
|
|
757
|
-
fromBlock = toBlock - count + 1;
|
|
758
|
-
} else {
|
|
759
|
-
toBlock = fromBlock + count - 1;
|
|
760
|
-
}
|
|
761
|
-
} else if (!fromBlock) {
|
|
762
|
-
fromBlock = toBlock - count + 1;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// Ensure block numbers are valid
|
|
766
|
-
if (toBlock > latestBlock) {
|
|
767
|
-
toBlock = latestBlock;
|
|
768
|
-
}
|
|
769
|
-
if (fromBlock < 0) {
|
|
770
|
-
fromBlock = 0;
|
|
771
|
-
}
|
|
772
|
-
return _context13.abrupt("return", {
|
|
773
|
-
fromBlock: fromBlock,
|
|
774
|
-
toBlock: toBlock
|
|
775
|
-
});
|
|
776
|
-
case 8:
|
|
777
|
-
case "end":
|
|
778
|
-
return _context13.stop();
|
|
779
|
-
}
|
|
780
|
-
}, _callee13, this);
|
|
781
|
-
}));
|
|
782
|
-
return function (_x13) {
|
|
783
|
-
return _ref29.apply(this, arguments);
|
|
784
|
-
};
|
|
785
|
-
}();
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* Get events from the blockchain in reverse chronological order, starting from toBlock. This will also attempt
|
|
789
|
-
* to identify and parse any known Eluvio contract methods. If successful, the method name, signature, and input
|
|
790
|
-
* values will be included in the log entry.
|
|
791
|
-
*
|
|
792
|
-
* @methodGroup Blockchain
|
|
793
|
-
* @namedParams
|
|
794
|
-
* @param {number=} toBlock - Limit results to events before the specified block (inclusive) - If not specified, will start from latest block
|
|
795
|
-
* @param {number=} fromBlock - Limit results to events after the specified block (inclusive)
|
|
796
|
-
* @param {number=} count=10 - Max number of events to include (unless both toBlock and fromBlock are specified)
|
|
797
|
-
* @param {boolean=} includeTransaction=false - If specified, more detailed transaction info will be included.
|
|
798
|
-
* Note: This requires two extra network calls per transaction, so it should not be used for very large ranges
|
|
799
|
-
* @returns {Promise<Array<Array<Object>>>} - List of blocks, in ascending order by block number, each containing a list of the events in the block.
|
|
800
|
-
*/
|
|
801
|
-
exports.Events = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
802
|
-
var _ref31,
|
|
803
|
-
toBlock,
|
|
804
|
-
fromBlock,
|
|
805
|
-
_ref31$count,
|
|
806
|
-
count,
|
|
807
|
-
_ref31$includeTransac,
|
|
808
|
-
includeTransaction,
|
|
809
|
-
blocks,
|
|
810
|
-
_args14 = arguments;
|
|
811
|
-
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
812
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
813
|
-
case 0:
|
|
814
|
-
_ref31 = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {}, toBlock = _ref31.toBlock, fromBlock = _ref31.fromBlock, _ref31$count = _ref31.count, count = _ref31$count === void 0 ? 10 : _ref31$count, _ref31$includeTransac = _ref31.includeTransaction, includeTransaction = _ref31$includeTransac === void 0 ? false : _ref31$includeTransac;
|
|
815
|
-
_context14.next = 3;
|
|
816
|
-
return this.FormatBlockNumbers({
|
|
817
|
-
fromBlock: fromBlock,
|
|
818
|
-
toBlock: toBlock,
|
|
819
|
-
count: count
|
|
820
|
-
});
|
|
821
|
-
case 3:
|
|
822
|
-
blocks = _context14.sent;
|
|
823
|
-
this.Log("Querying events - Blocks ".concat(blocks.fromBlock, " to ").concat(blocks.toBlock));
|
|
824
|
-
_context14.next = 7;
|
|
825
|
-
return this.ethClient.Events({
|
|
826
|
-
fromBlock: blocks.fromBlock,
|
|
827
|
-
toBlock: blocks.toBlock,
|
|
828
|
-
includeTransaction: includeTransaction
|
|
829
|
-
});
|
|
830
|
-
case 7:
|
|
831
|
-
return _context14.abrupt("return", _context14.sent);
|
|
832
|
-
case 8:
|
|
833
|
-
case "end":
|
|
834
|
-
return _context14.stop();
|
|
835
|
-
}
|
|
836
|
-
}, _callee14, this);
|
|
837
|
-
}));
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Retrieve the latest block number on the blockchain
|
|
841
|
-
*
|
|
842
|
-
* @methodGroup Blockchain
|
|
843
|
-
*
|
|
844
|
-
* @returns {Promise<number>} - The latest block number
|
|
845
|
-
*/
|
|
846
|
-
exports.BlockNumber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
847
|
-
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
848
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
849
|
-
case 0:
|
|
850
|
-
_context15.next = 2;
|
|
851
|
-
return this.ethClient.MakeProviderCall({
|
|
852
|
-
methodName: "getBlockNumber"
|
|
853
|
-
});
|
|
854
|
-
case 2:
|
|
855
|
-
return _context15.abrupt("return", _context15.sent);
|
|
856
|
-
case 3:
|
|
857
|
-
case "end":
|
|
858
|
-
return _context15.stop();
|
|
859
|
-
}
|
|
860
|
-
}, _callee15, this);
|
|
861
|
-
}));
|
|
862
|
-
|
|
863
|
-
/**
|
|
864
|
-
* Get the balance (in ether) of the specified address
|
|
865
|
-
*
|
|
866
|
-
* @methodGroup Blockchain
|
|
867
|
-
* @namedParams
|
|
868
|
-
* @param {string} address - Address to query
|
|
869
|
-
*
|
|
870
|
-
* @returns {Promise<string>} - Balance of the account, in ether (as string)
|
|
871
|
-
*/
|
|
872
|
-
exports.GetBalance = /*#__PURE__*/function () {
|
|
873
|
-
var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref33) {
|
|
874
|
-
var address, balance;
|
|
875
|
-
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
876
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
877
|
-
case 0:
|
|
878
|
-
address = _ref33.address;
|
|
879
|
-
address = ValidateAddress(address);
|
|
880
|
-
_context16.next = 4;
|
|
881
|
-
return this.ethClient.MakeProviderCall({
|
|
882
|
-
methodName: "getBalance",
|
|
883
|
-
args: [address]
|
|
884
|
-
});
|
|
885
|
-
case 4:
|
|
886
|
-
balance = _context16.sent;
|
|
887
|
-
return _context16.abrupt("return", Ethers.utils.formatEther(balance));
|
|
888
|
-
case 6:
|
|
889
|
-
case "end":
|
|
890
|
-
return _context16.stop();
|
|
891
|
-
}
|
|
892
|
-
}, _callee16, this);
|
|
893
|
-
}));
|
|
894
|
-
return function (_x14) {
|
|
895
|
-
return _ref34.apply(this, arguments);
|
|
896
|
-
};
|
|
897
|
-
}();
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* Send ether from this client's current signer to the specified recipient address
|
|
901
|
-
*
|
|
902
|
-
* @methodGroup Blockchain
|
|
903
|
-
* @namedParams
|
|
904
|
-
* @param {string} recipient - Address of the recipient
|
|
905
|
-
* @param {number} ether - Amount of ether to send
|
|
906
|
-
*
|
|
907
|
-
* @returns {Promise<Object>} - The transaction receipt
|
|
908
|
-
*/
|
|
909
|
-
exports.SendFunds = /*#__PURE__*/function () {
|
|
910
|
-
var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref35) {
|
|
911
|
-
var recipient, ether, transaction;
|
|
912
|
-
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
913
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
914
|
-
case 0:
|
|
915
|
-
recipient = _ref35.recipient, ether = _ref35.ether;
|
|
916
|
-
recipient = ValidateAddress(recipient);
|
|
917
|
-
_context17.next = 4;
|
|
918
|
-
return this.signer.sendTransaction({
|
|
919
|
-
to: recipient,
|
|
920
|
-
value: Ethers.utils.parseEther(ether.toString())
|
|
921
|
-
});
|
|
922
|
-
case 4:
|
|
923
|
-
transaction = _context17.sent;
|
|
924
|
-
_context17.next = 7;
|
|
925
|
-
return transaction.wait();
|
|
926
|
-
case 7:
|
|
927
|
-
return _context17.abrupt("return", _context17.sent);
|
|
928
|
-
case 8:
|
|
929
|
-
case "end":
|
|
930
|
-
return _context17.stop();
|
|
931
|
-
}
|
|
932
|
-
}, _callee17, this);
|
|
933
|
-
}));
|
|
934
|
-
return function (_x15) {
|
|
935
|
-
return _ref36.apply(this, arguments);
|
|
936
|
-
};
|
|
937
|
-
}();
|
|
938
|
-
var GetObjectIDAndContractAddress = /*#__PURE__*/function () {
|
|
939
|
-
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref37) {
|
|
940
|
-
var contractAddress, objectId, versionHash;
|
|
941
|
-
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
942
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
943
|
-
case 0:
|
|
944
|
-
contractAddress = _ref37.contractAddress, objectId = _ref37.objectId, versionHash = _ref37.versionHash;
|
|
945
|
-
if (!contractAddress) {
|
|
946
|
-
_context18.next = 6;
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
ValidateAddress(contractAddress);
|
|
950
|
-
objectId = Utils.AddressToObjectId(contractAddress);
|
|
951
|
-
_context18.next = 18;
|
|
952
|
-
break;
|
|
953
|
-
case 6:
|
|
954
|
-
if (!versionHash) {
|
|
955
|
-
_context18.next = 12;
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
ValidateVersion(versionHash);
|
|
959
|
-
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
960
|
-
contractAddress = Utils.HashToAddress(objectId);
|
|
961
|
-
_context18.next = 18;
|
|
962
|
-
break;
|
|
963
|
-
case 12:
|
|
964
|
-
if (!objectId) {
|
|
965
|
-
_context18.next = 17;
|
|
966
|
-
break;
|
|
967
|
-
}
|
|
968
|
-
ValidateObject(objectId);
|
|
969
|
-
contractAddress = Utils.HashToAddress(objectId);
|
|
970
|
-
_context18.next = 18;
|
|
971
|
-
break;
|
|
972
|
-
case 17:
|
|
973
|
-
throw Error("contractAddress or objectId or versionHash not specified");
|
|
974
|
-
case 18:
|
|
975
|
-
return _context18.abrupt("return", {
|
|
976
|
-
contractAddress: contractAddress,
|
|
977
|
-
objectId: objectId
|
|
978
|
-
});
|
|
979
|
-
case 19:
|
|
980
|
-
case "end":
|
|
981
|
-
return _context18.stop();
|
|
982
|
-
}
|
|
983
|
-
}, _callee18, this);
|
|
984
|
-
}));
|
|
985
|
-
return function GetObjectIDAndContractAddress(_x16) {
|
|
986
|
-
return _ref38.apply(this, arguments);
|
|
987
|
-
};
|
|
988
|
-
}();
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* Retrieve the ID of the tenant admin group set for the specified object
|
|
992
|
-
*
|
|
993
|
-
* @methodGroup Tenant
|
|
994
|
-
* @namedParams
|
|
995
|
-
* @param {string=} contractAddress - The address of the object
|
|
996
|
-
* @param {string=} objectId - The ID of the object
|
|
997
|
-
* @param {string=} versionHash - A version hash of the object
|
|
998
|
-
*
|
|
999
|
-
* @returns {Promise<string|undefined>}
|
|
1000
|
-
*/
|
|
1001
|
-
exports.TenantId = /*#__PURE__*/function () {
|
|
1002
|
-
var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref39) {
|
|
1003
|
-
var contractAddress, objectId, versionHash, tenantId, hasGetMetaMethod, libraryId;
|
|
1004
|
-
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1005
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1006
|
-
case 0:
|
|
1007
|
-
contractAddress = _ref39.contractAddress, objectId = _ref39.objectId, versionHash = _ref39.versionHash;
|
|
1008
|
-
_context19.next = 3;
|
|
1009
|
-
return GetObjectIDAndContractAddress({
|
|
1010
|
-
contractAddress: contractAddress,
|
|
1011
|
-
objectId: objectId,
|
|
1012
|
-
versionHash: versionHash
|
|
1013
|
-
});
|
|
1014
|
-
case 3:
|
|
1015
|
-
objectInfo = _context19.sent;
|
|
1016
|
-
contractAddress = objectInfo.contractAddress;
|
|
1017
|
-
objectId = objectInfo.objectId;
|
|
1018
|
-
_context19.prev = 6;
|
|
1019
|
-
_context19.next = 9;
|
|
1020
|
-
return this.authClient.ContractHasMethod({
|
|
1021
|
-
contractAddress: contractAddress,
|
|
1022
|
-
methodName: "getMeta"
|
|
1023
|
-
});
|
|
1024
|
-
case 9:
|
|
1025
|
-
hasGetMetaMethod = _context19.sent;
|
|
1026
|
-
if (!hasGetMetaMethod) {
|
|
1027
|
-
_context19.next = 14;
|
|
1028
|
-
break;
|
|
1029
|
-
}
|
|
1030
|
-
_context19.next = 13;
|
|
1031
|
-
return this.ContractMetadata({
|
|
1032
|
-
contractAddress: contractAddress,
|
|
1033
|
-
metadataKey: "_tenantId"
|
|
1034
|
-
});
|
|
1035
|
-
case 13:
|
|
1036
|
-
tenantId = _context19.sent;
|
|
1037
|
-
case 14:
|
|
1038
|
-
if (!(tenantId === undefined)) {
|
|
1039
|
-
_context19.next = 21;
|
|
1040
|
-
break;
|
|
1041
|
-
}
|
|
1042
|
-
_context19.next = 17;
|
|
1043
|
-
return this.ContentObjectLibraryId({
|
|
1044
|
-
objectId: objectId
|
|
1045
|
-
});
|
|
1046
|
-
case 17:
|
|
1047
|
-
libraryId = _context19.sent;
|
|
1048
|
-
_context19.next = 20;
|
|
1049
|
-
return this.ContentObjectMetadata({
|
|
1050
|
-
libraryId: libraryId,
|
|
1051
|
-
objectId: objectId,
|
|
1052
|
-
metadataSubtree: "tenantId"
|
|
1053
|
-
});
|
|
1054
|
-
case 20:
|
|
1055
|
-
tenantId = _context19.sent;
|
|
1056
|
-
case 21:
|
|
1057
|
-
return _context19.abrupt("return", tenantId);
|
|
1058
|
-
case 24:
|
|
1059
|
-
_context19.prev = 24;
|
|
1060
|
-
_context19.t0 = _context19["catch"](6);
|
|
1061
|
-
return _context19.abrupt("return", "");
|
|
1062
|
-
case 27:
|
|
1063
|
-
case "end":
|
|
1064
|
-
return _context19.stop();
|
|
1065
|
-
}
|
|
1066
|
-
}, _callee19, this, [[6, 24]]);
|
|
1067
|
-
}));
|
|
1068
|
-
return function (_x17) {
|
|
1069
|
-
return _ref40.apply(this, arguments);
|
|
1070
|
-
};
|
|
1071
|
-
}();
|
|
1072
|
-
|
|
1073
|
-
/**
|
|
1074
|
-
* Retrieve the ID of the tenant contract for the specified object
|
|
1075
|
-
*
|
|
1076
|
-
* @methodGroup Tenant
|
|
1077
|
-
* @namedParams
|
|
1078
|
-
* @param {string=} contractAddress - The address of the object
|
|
1079
|
-
* @param {string=} objectId - The ID of the object
|
|
1080
|
-
* @param {string=} versionHash - A version hash of the object
|
|
1081
|
-
*
|
|
1082
|
-
* @returns {Promise<string|undefined>}
|
|
1083
|
-
*/
|
|
1084
|
-
exports.TenantContractId = /*#__PURE__*/function () {
|
|
1085
|
-
var _ref42 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref41) {
|
|
1086
|
-
var contractAddress, objectId, versionHash, hasGetMetaMethod, _tenantContractId, libraryId;
|
|
1087
|
-
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1088
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
1089
|
-
case 0:
|
|
1090
|
-
contractAddress = _ref41.contractAddress, objectId = _ref41.objectId, versionHash = _ref41.versionHash;
|
|
1091
|
-
_context20.next = 3;
|
|
1092
|
-
return GetObjectIDAndContractAddress({
|
|
1093
|
-
contractAddress: contractAddress,
|
|
1094
|
-
objectId: objectId,
|
|
1095
|
-
versionHash: versionHash
|
|
1096
|
-
});
|
|
1097
|
-
case 3:
|
|
1098
|
-
objectInfo = _context20.sent;
|
|
1099
|
-
contractAddress = objectInfo.contractAddress;
|
|
1100
|
-
objectId = objectInfo.objectId;
|
|
1101
|
-
_context20.prev = 6;
|
|
1102
|
-
_context20.next = 9;
|
|
1103
|
-
return this.authClient.ContractHasMethod({
|
|
1104
|
-
contractAddress: contractAddress,
|
|
1105
|
-
methodName: "getMeta"
|
|
1106
|
-
});
|
|
1107
|
-
case 9:
|
|
1108
|
-
hasGetMetaMethod = _context20.sent;
|
|
1109
|
-
if (!hasGetMetaMethod) {
|
|
1110
|
-
_context20.next = 14;
|
|
1111
|
-
break;
|
|
1112
|
-
}
|
|
1113
|
-
_context20.next = 13;
|
|
1114
|
-
return this.ContractMetadata({
|
|
1115
|
-
contractAddress: contractAddress,
|
|
1116
|
-
metadataKey: "_ELV_TENANT_ID"
|
|
1117
|
-
});
|
|
1118
|
-
case 13:
|
|
1119
|
-
_tenantContractId = _context20.sent;
|
|
1120
|
-
case 14:
|
|
1121
|
-
if (!(_tenantContractId === undefined)) {
|
|
1122
|
-
_context20.next = 21;
|
|
1123
|
-
break;
|
|
1124
|
-
}
|
|
1125
|
-
_context20.next = 17;
|
|
1126
|
-
return this.ContentObjectLibraryId({
|
|
1127
|
-
objectId: objectId
|
|
1128
|
-
});
|
|
1129
|
-
case 17:
|
|
1130
|
-
libraryId = _context20.sent;
|
|
1131
|
-
_context20.next = 20;
|
|
1132
|
-
return this.ContentObjectMetadata({
|
|
1133
|
-
libraryId: libraryId,
|
|
1134
|
-
objectId: objectId,
|
|
1135
|
-
metadataSubtree: "tenantContractId"
|
|
1136
|
-
});
|
|
1137
|
-
case 20:
|
|
1138
|
-
_tenantContractId = _context20.sent;
|
|
1139
|
-
case 21:
|
|
1140
|
-
return _context20.abrupt("return", _tenantContractId);
|
|
1141
|
-
case 24:
|
|
1142
|
-
_context20.prev = 24;
|
|
1143
|
-
_context20.t0 = _context20["catch"](6);
|
|
1144
|
-
return _context20.abrupt("return", "");
|
|
1145
|
-
case 27:
|
|
1146
|
-
case "end":
|
|
1147
|
-
return _context20.stop();
|
|
1148
|
-
}
|
|
1149
|
-
}, _callee20, this, [[6, 24]]);
|
|
1150
|
-
}));
|
|
1151
|
-
return function (_x18) {
|
|
1152
|
-
return _ref42.apply(this, arguments);
|
|
1153
|
-
};
|
|
1154
|
-
}();
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
* Set the tenant contract ID and tenant admin group ID for the specified object
|
|
1158
|
-
* when tenant admin group ID is provided
|
|
1159
|
-
*
|
|
1160
|
-
* @methodGroup Tenant
|
|
1161
|
-
* @namedParams
|
|
1162
|
-
* @param {string=} contractAddress - The address of the object
|
|
1163
|
-
* @param {string=} objectId - The ID of the object
|
|
1164
|
-
* @param {string=} versionHash - A version hash of the object
|
|
1165
|
-
* @param {string} tenantContractId - The tenant contract ID to set
|
|
1166
|
-
* @param {string} tenantId - The tenant ID to set
|
|
1167
|
-
*
|
|
1168
|
-
* @returns {Promise<{tenantId: (undefined|string), tenantContractId}>}
|
|
1169
|
-
*/
|
|
1170
|
-
exports.SetTenantId = /*#__PURE__*/function () {
|
|
1171
|
-
var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref43) {
|
|
1172
|
-
var contractAddress, objectId, versionHash, tenantId, objectVersion, version;
|
|
1173
|
-
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1174
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1175
|
-
case 0:
|
|
1176
|
-
contractAddress = _ref43.contractAddress, objectId = _ref43.objectId, versionHash = _ref43.versionHash, tenantId = _ref43.tenantId;
|
|
1177
|
-
_context21.next = 3;
|
|
1178
|
-
return GetObjectIDAndContractAddress({
|
|
1179
|
-
contractAddress: contractAddress,
|
|
1180
|
-
objectId: objectId,
|
|
1181
|
-
versionHash: versionHash
|
|
1182
|
-
});
|
|
1183
|
-
case 3:
|
|
1184
|
-
objectInfo = _context21.sent;
|
|
1185
|
-
contractAddress = objectInfo.contractAddress;
|
|
1186
|
-
objectId = objectInfo.objectId;
|
|
1187
|
-
_context21.next = 8;
|
|
1188
|
-
return this.authClient.AccessType(objectId);
|
|
1189
|
-
case 8:
|
|
1190
|
-
objectVersion = _context21.sent;
|
|
1191
|
-
if (!(objectVersion !== this.authClient.ACCESS_TYPES.GROUP && objectVersion !== this.authClient.ACCESS_TYPES.WALLET && objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY && objectVersion !== this.authClient.ACCESS_TYPES.TYPE && objectVersion !== this.authClient.ACCESS_TYPES.TENANT)) {
|
|
1192
|
-
_context21.next = 11;
|
|
1193
|
-
break;
|
|
1194
|
-
}
|
|
1195
|
-
throw Error("Invalid object ID: ".concat(objectId, ", \n applicable only for wallet,group, library or content_type object."));
|
|
1196
|
-
case 11:
|
|
1197
|
-
ValidateObject(tenantId);
|
|
1198
|
-
if (!(!tenantId.startsWith("iten") || !Utils.ValidHash(tenantId))) {
|
|
1199
|
-
_context21.next = 14;
|
|
1200
|
-
break;
|
|
1201
|
-
}
|
|
1202
|
-
throw Error("Invalid tenant ID: ".concat(tenantId));
|
|
1203
|
-
case 14:
|
|
1204
|
-
_context21.next = 16;
|
|
1205
|
-
return this.authClient.AccessType(tenantId);
|
|
1206
|
-
case 16:
|
|
1207
|
-
version = _context21.sent;
|
|
1208
|
-
if (!(version !== this.authClient.ACCESS_TYPES.GROUP)) {
|
|
1209
|
-
_context21.next = 19;
|
|
1210
|
-
break;
|
|
1211
|
-
}
|
|
1212
|
-
throw Error("Invalid tenant ID: " + tenantId);
|
|
1213
|
-
case 19:
|
|
1214
|
-
_context21.next = 21;
|
|
1215
|
-
return this.TenantContractId({
|
|
1216
|
-
objectId: tenantId
|
|
1217
|
-
});
|
|
1218
|
-
case 21:
|
|
1219
|
-
tenantContractId = _context21.sent;
|
|
1220
|
-
if (!tenantContractId) {
|
|
1221
|
-
_context21.next = 28;
|
|
1222
|
-
break;
|
|
1223
|
-
}
|
|
1224
|
-
_context21.next = 25;
|
|
1225
|
-
return this.SetTenantContractId({
|
|
1226
|
-
contractAddress: contractAddress,
|
|
1227
|
-
objectId: objectId,
|
|
1228
|
-
versionHash: versionHash,
|
|
1229
|
-
tenantContractId: tenantContractId
|
|
1230
|
-
});
|
|
1231
|
-
case 25:
|
|
1232
|
-
return _context21.abrupt("return", _context21.sent);
|
|
1233
|
-
case 28:
|
|
1234
|
-
throw Error("Invalid tenantId: tenant contract id not found");
|
|
1235
|
-
case 29:
|
|
1236
|
-
case "end":
|
|
1237
|
-
return _context21.stop();
|
|
1238
|
-
}
|
|
1239
|
-
}, _callee21, this);
|
|
1240
|
-
}));
|
|
1241
|
-
return function (_x19) {
|
|
1242
|
-
return _ref44.apply(this, arguments);
|
|
1243
|
-
};
|
|
1244
|
-
}();
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Set the tenant contract ID and tenant admin group ID for the specified object
|
|
1248
|
-
* when tenant contract ID is provided
|
|
1249
|
-
*
|
|
1250
|
-
* @methodGroup Tenant
|
|
1251
|
-
* @namedParams
|
|
1252
|
-
* @param {string=} contractAddress - The address of the object
|
|
1253
|
-
* @param {string=} objectId - The ID of the object
|
|
1254
|
-
* @param {string=} versionHash - A version hash of the object
|
|
1255
|
-
* @param {string} tenantContractId - The tenant contract ID to set
|
|
1256
|
-
*
|
|
1257
|
-
* @returns {Promise<{tenantId: (undefined|string), tenantContractId}>}
|
|
1258
|
-
*/
|
|
1259
|
-
exports.SetTenantContractId = /*#__PURE__*/function () {
|
|
1260
|
-
var _ref46 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref45) {
|
|
1261
|
-
var contractAddress, objectId, versionHash, tenantContractId, objectVersion, tenantAddress, version, tenantAdminGroupAddress, hasPutMetaMethod, libraryId, editRequest;
|
|
1262
|
-
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1263
|
-
while (1) switch (_context22.prev = _context22.next) {
|
|
1264
|
-
case 0:
|
|
1265
|
-
contractAddress = _ref45.contractAddress, objectId = _ref45.objectId, versionHash = _ref45.versionHash, tenantContractId = _ref45.tenantContractId;
|
|
1266
|
-
_context22.next = 3;
|
|
1267
|
-
return GetObjectIDAndContractAddress({
|
|
1268
|
-
contractAddress: contractAddress,
|
|
1269
|
-
objectId: objectId,
|
|
1270
|
-
versionHash: versionHash
|
|
1271
|
-
});
|
|
1272
|
-
case 3:
|
|
1273
|
-
objectInfo = _context22.sent;
|
|
1274
|
-
contractAddress = objectInfo.contractAddress;
|
|
1275
|
-
objectId = objectInfo.objectId;
|
|
1276
|
-
_context22.next = 8;
|
|
1277
|
-
return this.authClient.AccessType(objectId);
|
|
1278
|
-
case 8:
|
|
1279
|
-
objectVersion = _context22.sent;
|
|
1280
|
-
if (!(objectVersion !== this.authClient.ACCESS_TYPES.GROUP && objectVersion !== this.authClient.ACCESS_TYPES.WALLET && objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY && objectVersion !== this.authClient.ACCESS_TYPES.TYPE && objectVersion !== this.authClient.ACCESS_TYPES.TENANT)) {
|
|
1281
|
-
_context22.next = 11;
|
|
1282
|
-
break;
|
|
1283
|
-
}
|
|
1284
|
-
throw Error("Invalid object ID: ".concat(objectId, ", \n applicable only for wallet,group, library or content_type object."));
|
|
1285
|
-
case 11:
|
|
1286
|
-
ValidateObject(tenantContractId);
|
|
1287
|
-
if (!(tenantContractId && (!tenantContractId.startsWith("iten") || !Utils.ValidHash(tenantContractId)))) {
|
|
1288
|
-
_context22.next = 14;
|
|
1289
|
-
break;
|
|
1290
|
-
}
|
|
1291
|
-
throw Error("Invalid tenant ID: ".concat(tenantContractId));
|
|
1292
|
-
case 14:
|
|
1293
|
-
tenantAddress = Utils.HashToAddress(tenantContractId);
|
|
1294
|
-
_context22.next = 17;
|
|
1295
|
-
return this.authClient.AccessType(tenantContractId);
|
|
1296
|
-
case 17:
|
|
1297
|
-
version = _context22.sent;
|
|
1298
|
-
if (!(version !== this.authClient.ACCESS_TYPES.TENANT)) {
|
|
1299
|
-
_context22.next = 20;
|
|
1300
|
-
break;
|
|
1301
|
-
}
|
|
1302
|
-
throw Error("Invalid tenant ID: " + tenantContractId);
|
|
1303
|
-
case 20:
|
|
1304
|
-
_context22.next = 22;
|
|
1305
|
-
return this.CallContractMethod({
|
|
1306
|
-
contractAddress: tenantAddress,
|
|
1307
|
-
methodName: "groupsMapping",
|
|
1308
|
-
methodArgs: ["tenant_admin", 0],
|
|
1309
|
-
formatArguments: true
|
|
1310
|
-
});
|
|
1311
|
-
case 22:
|
|
1312
|
-
tenantAdminGroupAddress = _context22.sent;
|
|
1313
|
-
_context22.next = 25;
|
|
1314
|
-
return this.authClient.ContractHasMethod({
|
|
1315
|
-
contractAddress: contractAddress,
|
|
1316
|
-
methodName: "putMeta"
|
|
1317
|
-
});
|
|
1318
|
-
case 25:
|
|
1319
|
-
hasPutMetaMethod = _context22.sent;
|
|
1320
|
-
if (!hasPutMetaMethod) {
|
|
1321
|
-
_context22.next = 37;
|
|
1322
|
-
break;
|
|
1323
|
-
}
|
|
1324
|
-
_context22.next = 29;
|
|
1325
|
-
return this.ReplaceContractMetadata({
|
|
1326
|
-
contractAddress: contractAddress,
|
|
1327
|
-
metadataKey: "_ELV_TENANT_ID",
|
|
1328
|
-
metadata: tenantContractId
|
|
1329
|
-
});
|
|
1330
|
-
case 29:
|
|
1331
|
-
if (!tenantAdminGroupAddress) {
|
|
1332
|
-
_context22.next = 34;
|
|
1333
|
-
break;
|
|
1334
|
-
}
|
|
1335
|
-
_context22.next = 32;
|
|
1336
|
-
return this.ReplaceContractMetadata({
|
|
1337
|
-
contractAddress: contractAddress,
|
|
1338
|
-
metadataKey: "_tenantId",
|
|
1339
|
-
metadata: "iten".concat(Utils.AddressToHash(tenantAdminGroupAddress))
|
|
1340
|
-
});
|
|
1341
|
-
case 32:
|
|
1342
|
-
_context22.next = 35;
|
|
1343
|
-
break;
|
|
1344
|
-
case 34:
|
|
1345
|
-
// eslint-disable-next-line no-console
|
|
1346
|
-
console.warn("No tenant ID associated with current tenant.");
|
|
1347
|
-
case 35:
|
|
1348
|
-
_context22.next = 47;
|
|
1349
|
-
break;
|
|
1350
|
-
case 37:
|
|
1351
|
-
_context22.next = 39;
|
|
1352
|
-
return this.ContentObjectLibraryId({
|
|
1353
|
-
objectId: objectId
|
|
1354
|
-
});
|
|
1355
|
-
case 39:
|
|
1356
|
-
libraryId = _context22.sent;
|
|
1357
|
-
_context22.next = 42;
|
|
1358
|
-
return this.EditContentObject({
|
|
1359
|
-
libraryId: libraryId,
|
|
1360
|
-
objectId: objectId
|
|
1361
|
-
});
|
|
1362
|
-
case 42:
|
|
1363
|
-
editRequest = _context22.sent;
|
|
1364
|
-
_context22.next = 45;
|
|
1365
|
-
return this.MergeMetadata({
|
|
1366
|
-
libraryId: libraryId,
|
|
1367
|
-
objectId: objectId,
|
|
1368
|
-
writeToken: editRequest.write_token,
|
|
1369
|
-
metadata: {
|
|
1370
|
-
tenantContractId: tenantContractId,
|
|
1371
|
-
tenantId: !tenantAdminGroupAddress ? undefined : "iten".concat(Utils.AddressToHash(tenantAdminGroupAddress))
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
case 45:
|
|
1375
|
-
_context22.next = 47;
|
|
1376
|
-
return this.FinalizeContentObject({
|
|
1377
|
-
libraryId: libraryId,
|
|
1378
|
-
objectId: objectId,
|
|
1379
|
-
writeToken: editRequest.write_token,
|
|
1380
|
-
commitMessage: "set tenant_contract_id"
|
|
1381
|
-
});
|
|
1382
|
-
case 47:
|
|
1383
|
-
return _context22.abrupt("return", {
|
|
1384
|
-
tenantContractId: tenantContractId,
|
|
1385
|
-
tenantId: !tenantAdminGroupAddress ? undefined : "iten".concat(Utils.AddressToHash(tenantAdminGroupAddress))
|
|
1386
|
-
});
|
|
1387
|
-
case 48:
|
|
1388
|
-
case "end":
|
|
1389
|
-
return _context22.stop();
|
|
1390
|
-
}
|
|
1391
|
-
}, _callee22, this);
|
|
1392
|
-
}));
|
|
1393
|
-
return function (_x20) {
|
|
1394
|
-
return _ref46.apply(this, arguments);
|
|
1395
|
-
};
|
|
1396
|
-
}();
|
|
1397
|
-
|
|
1398
|
-
/**
|
|
1399
|
-
* Remove the tenant contract ID and tenant admin group ID for the specified object
|
|
1400
|
-
*
|
|
1401
|
-
* @methodGroup Tenant
|
|
1402
|
-
* @namedParams
|
|
1403
|
-
* @param {string=} contractAddress - The address of the object
|
|
1404
|
-
* @param {string=} objectId - The ID of the object
|
|
1405
|
-
* @param {string=} versionHash - A version hash of the object
|
|
1406
|
-
*
|
|
1407
|
-
* @returns {Promise<void>}
|
|
1408
|
-
*/
|
|
1409
|
-
exports.ResetTenantId = /*#__PURE__*/function () {
|
|
1410
|
-
var _ref48 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref47) {
|
|
1411
|
-
var contractAddress, objectId, versionHash, objectVersion, tenantContractId, tenantId, hasPutMetaMethod, libraryId, editRequest;
|
|
1412
|
-
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1413
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
1414
|
-
case 0:
|
|
1415
|
-
contractAddress = _ref47.contractAddress, objectId = _ref47.objectId, versionHash = _ref47.versionHash;
|
|
1416
|
-
_context23.next = 3;
|
|
1417
|
-
return GetObjectIDAndContractAddress({
|
|
1418
|
-
contractAddress: contractAddress,
|
|
1419
|
-
objectId: objectId,
|
|
1420
|
-
versionHash: versionHash
|
|
1421
|
-
});
|
|
1422
|
-
case 3:
|
|
1423
|
-
objectInfo = _context23.sent;
|
|
1424
|
-
contractAddress = objectInfo.contractAddress;
|
|
1425
|
-
objectId = objectInfo.objectId;
|
|
1426
|
-
_context23.next = 8;
|
|
1427
|
-
return this.authClient.AccessType(objectId);
|
|
1428
|
-
case 8:
|
|
1429
|
-
objectVersion = _context23.sent;
|
|
1430
|
-
if (!(objectVersion !== this.authClient.ACCESS_TYPES.GROUP && objectVersion !== this.authClient.ACCESS_TYPES.WALLET && objectVersion !== this.authClient.ACCESS_TYPES.LIBRARY && objectVersion !== this.authClient.ACCESS_TYPES.TYPE && objectVersion !== this.authClient.ACCESS_TYPES.TENANT)) {
|
|
1431
|
-
_context23.next = 11;
|
|
1432
|
-
break;
|
|
1433
|
-
}
|
|
1434
|
-
throw Error("Invalid object ID: ".concat(objectId, ", \n applicable only for wallet,group, library or content_type object."));
|
|
1435
|
-
case 11:
|
|
1436
|
-
tenantContractId = this.TenantContractId({
|
|
1437
|
-
objectId: objectId
|
|
1438
|
-
});
|
|
1439
|
-
tenantId = this.TenantId({
|
|
1440
|
-
objectId: objectId
|
|
1441
|
-
});
|
|
1442
|
-
if (!(tenantContractId || tenantId)) {
|
|
1443
|
-
_context23.next = 36;
|
|
1444
|
-
break;
|
|
1445
|
-
}
|
|
1446
|
-
_context23.next = 16;
|
|
1447
|
-
return this.authClient.ContractHasMethod({
|
|
1448
|
-
contractAddress: contractAddress,
|
|
1449
|
-
methodName: "putMeta"
|
|
1450
|
-
});
|
|
1451
|
-
case 16:
|
|
1452
|
-
hasPutMetaMethod = _context23.sent;
|
|
1453
|
-
if (!hasPutMetaMethod) {
|
|
1454
|
-
_context23.next = 24;
|
|
1455
|
-
break;
|
|
1456
|
-
}
|
|
1457
|
-
_context23.next = 20;
|
|
1458
|
-
return this.ReplaceContractMetadata({
|
|
1459
|
-
contractAddress: contractAddress,
|
|
1460
|
-
metadataKey: "_ELV_TENANT_ID",
|
|
1461
|
-
metadata: ""
|
|
1462
|
-
});
|
|
1463
|
-
case 20:
|
|
1464
|
-
_context23.next = 22;
|
|
1465
|
-
return this.ReplaceContractMetadata({
|
|
1466
|
-
contractAddress: contractAddress,
|
|
1467
|
-
metadataKey: "_tenantId",
|
|
1468
|
-
metadata: ""
|
|
1469
|
-
});
|
|
1470
|
-
case 22:
|
|
1471
|
-
_context23.next = 34;
|
|
1472
|
-
break;
|
|
1473
|
-
case 24:
|
|
1474
|
-
_context23.next = 26;
|
|
1475
|
-
return this.ContentObjectLibraryId({
|
|
1476
|
-
objectId: objectId
|
|
1477
|
-
});
|
|
1478
|
-
case 26:
|
|
1479
|
-
libraryId = _context23.sent;
|
|
1480
|
-
_context23.next = 29;
|
|
1481
|
-
return this.EditContentObject({
|
|
1482
|
-
libraryId: libraryId,
|
|
1483
|
-
objectId: objectId
|
|
1484
|
-
});
|
|
1485
|
-
case 29:
|
|
1486
|
-
editRequest = _context23.sent;
|
|
1487
|
-
_context23.next = 32;
|
|
1488
|
-
return this.MergeMetadata({
|
|
1489
|
-
libraryId: libraryId,
|
|
1490
|
-
objectId: objectId,
|
|
1491
|
-
writeToken: editRequest.write_token,
|
|
1492
|
-
metadata: {
|
|
1493
|
-
tenantContractId: undefined,
|
|
1494
|
-
tenantId: undefined
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
case 32:
|
|
1498
|
-
_context23.next = 34;
|
|
1499
|
-
return this.FinalizeContentObject({
|
|
1500
|
-
libraryId: libraryId,
|
|
1501
|
-
objectId: objectId,
|
|
1502
|
-
writeToken: editRequest.write_token,
|
|
1503
|
-
commitMessage: "remove tenant_contract_id"
|
|
1504
|
-
});
|
|
1505
|
-
case 34:
|
|
1506
|
-
_context23.next = 37;
|
|
1507
|
-
break;
|
|
1508
|
-
case 36:
|
|
1509
|
-
// eslint-disable-next-line no-console
|
|
1510
|
-
console.warn("No tenant ID associated with current tenant.");
|
|
1511
|
-
case 37:
|
|
1512
|
-
case "end":
|
|
1513
|
-
return _context23.stop();
|
|
1514
|
-
}
|
|
1515
|
-
}, _callee23, this);
|
|
1516
|
-
}));
|
|
1517
|
-
return function (_x21) {
|
|
1518
|
-
return _ref48.apply(this, arguments);
|
|
1519
|
-
};
|
|
1520
|
-
}();
|