@eluvio/elv-client-js 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +10 -11
- package/dist/ElvClient-node-min.js +10 -11
- package/dist/ElvFrameClient-min.js +10 -11
- package/dist/ElvPermissionsClient-min.js +9 -10
- package/dist/ElvWalletClient-min.js +10 -11
- package/dist/ElvWalletClient-node-min.js +9 -10
- package/dist/src/AuthorizationClient.js +2069 -1548
- package/dist/src/ContentObjectVerification.js +185 -134
- package/dist/src/Crypto.js +323 -226
- package/dist/src/ElvClient.js +1118 -824
- package/dist/src/ElvWallet.js +106 -64
- package/dist/src/EthClient.js +974 -719
- package/dist/src/FrameClient.js +318 -222
- package/dist/src/HttpClient.js +154 -112
- package/dist/src/Id.js +6 -1
- package/dist/src/LogMessage.js +8 -4
- package/dist/src/PermissionsClient.js +1271 -973
- package/dist/src/RemoteSigner.js +232 -161
- package/dist/src/UserProfileClient.js +1038 -781
- package/dist/src/Utils.js +302 -160
- package/dist/src/Validation.js +17 -2
- package/dist/src/client/ABRPublishing.js +942 -772
- package/dist/src/client/AccessGroups.js +1095 -849
- package/dist/src/client/ContentAccess.js +4198 -3272
- package/dist/src/client/ContentManagement.js +2284 -1812
- package/dist/src/client/Contracts.js +614 -468
- package/dist/src/client/Files.js +1831 -1491
- package/dist/src/client/NFT.js +116 -94
- package/dist/src/client/NTP.js +425 -326
- package/dist/src/index.js +5 -2
- package/dist/src/walletClient/ClientMethods.js +1766 -1350
- package/dist/src/walletClient/Configuration.js +2 -4
- package/dist/src/walletClient/Notifications.js +127 -98
- package/dist/src/walletClient/Profile.js +246 -184
- package/dist/src/walletClient/Utils.js +124 -78
- package/dist/src/walletClient/index.js +1498 -1169
- package/package.json +1 -1
- package/src/Crypto.js +2 -2
- package/src/ElvClient.js +2 -2
- package/src/Utils.js +1 -1
- package/src/client/ContentAccess.js +27 -10
- package/src/client/Files.js +1 -1
- package/src/walletClient/ClientMethods.js +18 -10
- package/src/walletClient/Utils.js +2 -2
- package/src/walletClient/index.js +7 -2
package/dist/src/EthClient.js
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
2
|
+
|
|
2
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
3
5
|
var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
|
|
6
|
+
|
|
4
7
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
8
|
+
|
|
5
9
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
10
|
+
|
|
6
11
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
12
|
+
|
|
7
13
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
14
|
+
|
|
8
15
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
16
|
+
|
|
9
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
18
|
+
|
|
19
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
20
|
+
|
|
11
21
|
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; }
|
|
22
|
+
|
|
12
23
|
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; }
|
|
24
|
+
|
|
13
25
|
// NOTE: Querying Ethereum requires CORS enabled
|
|
14
26
|
// Use --rpccorsdomain "http[s]://hostname:port" or set up proxy
|
|
15
27
|
var Ethers = require("ethers");
|
|
16
|
-
var HttpClient = require("./HttpClient");
|
|
17
28
|
|
|
29
|
+
var HttpClient = require("./HttpClient");
|
|
18
30
|
/*
|
|
19
31
|
// -- Contract javascript files built using build/BuildContracts.js
|
|
20
32
|
const ContentSpaceContract = require("./contracts/BaseContentSpace");
|
|
@@ -22,41 +34,46 @@ const ContentLibraryContract = require("./contracts/BaseLibrary");
|
|
|
22
34
|
const ContentContract = require("./contracts/BaseContent");
|
|
23
35
|
*/
|
|
24
36
|
|
|
37
|
+
|
|
25
38
|
var AccessibleContract = require("./contracts/v3/Accessible");
|
|
39
|
+
|
|
26
40
|
var Utils = require("./Utils");
|
|
41
|
+
|
|
27
42
|
var _require = require("./LogMessage"),
|
|
28
|
-
|
|
43
|
+
LogMessage = _require.LogMessage;
|
|
44
|
+
|
|
29
45
|
var Topics = require("./events/Topics");
|
|
46
|
+
|
|
30
47
|
var EthClient = /*#__PURE__*/function () {
|
|
31
48
|
"use strict";
|
|
32
49
|
|
|
33
50
|
function EthClient(_ref) {
|
|
34
51
|
var client = _ref.client,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
uris = _ref.uris,
|
|
53
|
+
networkId = _ref.networkId,
|
|
54
|
+
debug = _ref.debug,
|
|
55
|
+
_ref$timeout = _ref.timeout,
|
|
56
|
+
timeout = _ref$timeout === void 0 ? 10 : _ref$timeout;
|
|
57
|
+
|
|
40
58
|
_classCallCheck(this, EthClient);
|
|
59
|
+
|
|
41
60
|
this.client = client;
|
|
42
61
|
this.networkId = networkId;
|
|
43
62
|
this.ethereumURIs = uris;
|
|
44
63
|
this.ethereumURIIndex = 0;
|
|
45
64
|
this.locked = false;
|
|
46
|
-
this.debug = debug;
|
|
47
|
-
|
|
65
|
+
this.debug = debug; // convert to milliseconds
|
|
66
|
+
|
|
48
67
|
this.timeout = Math.floor(timeout * 1000);
|
|
49
68
|
this.cachedContracts = {};
|
|
50
|
-
this.contractNames = {};
|
|
69
|
+
this.contractNames = {}; // HTTP client for making misc calls to elv-master
|
|
51
70
|
|
|
52
|
-
// HTTP client for making misc calls to elv-master
|
|
53
71
|
this.HttpClient = new HttpClient({
|
|
54
72
|
uris: this.ethereumURIs,
|
|
55
73
|
debug: this.debug
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//Ethers.errors.setLogLevel("error");
|
|
74
|
+
}); //Ethers.errors.setLogLevel("error");
|
|
59
75
|
}
|
|
76
|
+
|
|
60
77
|
_createClass(EthClient, [{
|
|
61
78
|
key: "Log",
|
|
62
79
|
value: function Log(message) {
|
|
@@ -77,24 +94,27 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
77
94
|
key: "Provider",
|
|
78
95
|
value: function Provider() {
|
|
79
96
|
if (!this.provider) {
|
|
80
|
-
this.provider = new Ethers.providers.JsonRpcProvider(this.ethereumURIs[this.ethereumURIIndex], this.networkId);
|
|
81
|
-
|
|
82
|
-
// Ethers.js uses eth_getCode to ensure a contract is deployed and nothing else - this pulls a large chunk of pointless
|
|
97
|
+
this.provider = new Ethers.providers.JsonRpcProvider(this.ethereumURIs[this.ethereumURIIndex], this.networkId); // Ethers.js uses eth_getCode to ensure a contract is deployed and nothing else - this pulls a large chunk of pointless
|
|
83
98
|
// data every time a contract is initialized in the client (often). Ethers.js just checks that the code isn't == "0x", so
|
|
84
99
|
// we can give it some dummy string instead and assume the contract is fine
|
|
100
|
+
|
|
85
101
|
this.provider.getCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
86
102
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
87
|
-
while (1)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
while (1) {
|
|
104
|
+
switch (_context.prev = _context.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
return _context.abrupt("return", "0x123");
|
|
107
|
+
|
|
108
|
+
case 1:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
93
112
|
}
|
|
94
113
|
}, _callee);
|
|
95
114
|
}));
|
|
96
115
|
this.provider.pollingInterval = 500;
|
|
97
116
|
}
|
|
117
|
+
|
|
98
118
|
return this.provider;
|
|
99
119
|
}
|
|
100
120
|
}, {
|
|
@@ -102,96 +122,119 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
102
122
|
value: function () {
|
|
103
123
|
var _ContractName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(contractAddress) {
|
|
104
124
|
var _this = this;
|
|
125
|
+
|
|
105
126
|
var full,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
127
|
+
versionContract,
|
|
128
|
+
version,
|
|
129
|
+
_args3 = arguments;
|
|
109
130
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
110
|
-
while (1)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
131
|
+
while (1) {
|
|
132
|
+
switch (_context3.prev = _context3.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
full = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
|
|
135
|
+
versionContract = new Ethers.Contract(contractAddress, AccessibleContract.abi, this.Provider());
|
|
136
|
+
|
|
137
|
+
if (!this.contractNames[contractAddress]) {
|
|
138
|
+
this.contractNames[contractAddress] = new Promise( /*#__PURE__*/function () {
|
|
139
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve) {
|
|
140
|
+
var versionBytes32, _version;
|
|
141
|
+
|
|
142
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
143
|
+
while (1) {
|
|
144
|
+
switch (_context2.prev = _context2.next) {
|
|
145
|
+
case 0:
|
|
146
|
+
_context2.prev = 0;
|
|
147
|
+
_context2.next = 3;
|
|
148
|
+
return _this.CallContractMethod({
|
|
149
|
+
contract: versionContract,
|
|
150
|
+
abi: AccessibleContract.abi,
|
|
151
|
+
methodName: "version",
|
|
152
|
+
cacheContract: false
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
case 3:
|
|
156
|
+
versionBytes32 = _context2.sent;
|
|
157
|
+
_version = Ethers.utils.parseBytes32String( // Ensure bytes32 string is null terminated
|
|
158
|
+
versionBytes32.slice(0, -2) + "00");
|
|
159
|
+
resolve(_version);
|
|
160
|
+
_context2.next = 11;
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case 8:
|
|
164
|
+
_context2.prev = 8;
|
|
165
|
+
_context2.t0 = _context2["catch"](0);
|
|
166
|
+
resolve("Unknown");
|
|
167
|
+
|
|
168
|
+
case 11:
|
|
169
|
+
case "end":
|
|
170
|
+
return _context2.stop();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, _callee2, null, [[0, 8]]);
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
return function (_x2) {
|
|
177
|
+
return _ref3.apply(this, arguments);
|
|
178
|
+
};
|
|
179
|
+
}());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_context3.next = 5;
|
|
183
|
+
return this.contractNames[contractAddress];
|
|
184
|
+
|
|
185
|
+
case 5:
|
|
186
|
+
version = _context3.sent;
|
|
187
|
+
|
|
188
|
+
if (!full) {
|
|
189
|
+
_context3.next = 10;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return _context3.abrupt("return", version);
|
|
194
|
+
|
|
195
|
+
case 10:
|
|
196
|
+
return _context3.abrupt("return", version.split(/\d+/)[0]);
|
|
197
|
+
|
|
198
|
+
case 11:
|
|
199
|
+
case "end":
|
|
200
|
+
return _context3.stop();
|
|
201
|
+
}
|
|
166
202
|
}
|
|
167
203
|
}, _callee3, this);
|
|
168
204
|
}));
|
|
205
|
+
|
|
169
206
|
function ContractName(_x) {
|
|
170
207
|
return _ContractName.apply(this, arguments);
|
|
171
208
|
}
|
|
209
|
+
|
|
172
210
|
return ContractName;
|
|
173
211
|
}()
|
|
174
212
|
}, {
|
|
175
213
|
key: "Contract",
|
|
176
214
|
value: function Contract(_ref4) {
|
|
177
215
|
var contractAddress = _ref4.contractAddress,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
216
|
+
abi = _ref4.abi,
|
|
217
|
+
cacheContract = _ref4.cacheContract,
|
|
218
|
+
overrideCachedContract = _ref4.overrideCachedContract;
|
|
181
219
|
var contract;
|
|
220
|
+
|
|
182
221
|
if (!overrideCachedContract) {
|
|
183
222
|
contract = this.cachedContracts[contractAddress];
|
|
184
223
|
}
|
|
224
|
+
|
|
185
225
|
if (!abi) {
|
|
186
226
|
throw Error("No ABI for contract ".concat(contractAddress, " - Wrong network or deleted item?"));
|
|
187
227
|
}
|
|
228
|
+
|
|
188
229
|
if (!contract) {
|
|
189
230
|
contract = new Ethers.Contract(contractAddress, abi, this.Provider());
|
|
190
231
|
contract = contract.connect(this.client.signer);
|
|
232
|
+
|
|
191
233
|
if (cacheContract) {
|
|
192
234
|
this.cachedContracts[contractAddress] = contract;
|
|
193
235
|
}
|
|
194
236
|
}
|
|
237
|
+
|
|
195
238
|
return contract;
|
|
196
239
|
}
|
|
197
240
|
}, {
|
|
@@ -199,66 +242,84 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
199
242
|
value: function () {
|
|
200
243
|
var _MakeProviderCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
|
|
201
244
|
var methodName, _ref5$args, args, _ref5$attempts, attempts, provider;
|
|
245
|
+
|
|
202
246
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
203
|
-
while (1)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
_context4.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
247
|
+
while (1) {
|
|
248
|
+
switch (_context4.prev = _context4.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
methodName = _ref5.methodName, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$attempts = _ref5.attempts, attempts = _ref5$attempts === void 0 ? 0 : _ref5$attempts;
|
|
251
|
+
_context4.prev = 1;
|
|
252
|
+
provider = this.Provider();
|
|
253
|
+
_context4.next = 5;
|
|
254
|
+
return this.provider.getNetwork();
|
|
255
|
+
|
|
256
|
+
case 5:
|
|
257
|
+
this.Log("ETH ".concat(provider.connection.url, " ").concat(methodName, " [").concat(args.join(", "), "]"));
|
|
258
|
+
_context4.next = 8;
|
|
259
|
+
return provider[methodName].apply(provider, _toConsumableArray(args));
|
|
260
|
+
|
|
261
|
+
case 8:
|
|
262
|
+
return _context4.abrupt("return", _context4.sent);
|
|
263
|
+
|
|
264
|
+
case 11:
|
|
265
|
+
_context4.prev = 11;
|
|
266
|
+
_context4.t0 = _context4["catch"](1);
|
|
267
|
+
// eslint-disable-next-line no-console
|
|
268
|
+
console.error(_context4.t0);
|
|
269
|
+
|
|
270
|
+
if (!(attempts < this.ethereumURIs.length)) {
|
|
271
|
+
_context4.next = 19;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.Log("EthClient failing over: ".concat(attempts + 1, " attempts"), true);
|
|
276
|
+
this.provider = undefined;
|
|
277
|
+
this.ethereumURIIndex = (this.ethereumURIIndex + 1) % this.ethereumURIs.length;
|
|
278
|
+
return _context4.abrupt("return", this.MakeProviderCall({
|
|
279
|
+
methodName: methodName,
|
|
280
|
+
args: args,
|
|
281
|
+
attempts: attempts + 1
|
|
282
|
+
}));
|
|
283
|
+
|
|
284
|
+
case 19:
|
|
285
|
+
return _context4.abrupt("return", {});
|
|
286
|
+
|
|
287
|
+
case 20:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context4.stop();
|
|
290
|
+
}
|
|
238
291
|
}
|
|
239
292
|
}, _callee4, this, [[1, 11]]);
|
|
240
293
|
}));
|
|
294
|
+
|
|
241
295
|
function MakeProviderCall(_x3) {
|
|
242
296
|
return _MakeProviderCall.apply(this, arguments);
|
|
243
297
|
}
|
|
298
|
+
|
|
244
299
|
return MakeProviderCall;
|
|
245
|
-
}()
|
|
300
|
+
}()
|
|
301
|
+
/* General contract management */
|
|
302
|
+
|
|
246
303
|
}, {
|
|
247
304
|
key: "FormatContractArgument",
|
|
248
305
|
value: function FormatContractArgument(_ref6) {
|
|
249
306
|
var _this2 = this;
|
|
307
|
+
|
|
250
308
|
var type = _ref6.type,
|
|
251
|
-
|
|
309
|
+
value = _ref6.value;
|
|
310
|
+
|
|
252
311
|
// For array types, parse into array if necessary, then format each value.
|
|
253
312
|
if (type.endsWith("[]")) {
|
|
254
313
|
if (typeof value === "string") {
|
|
255
314
|
if (value.trim() === "") {
|
|
256
315
|
return [];
|
|
257
316
|
}
|
|
317
|
+
|
|
258
318
|
value = value.split(",").map(function (s) {
|
|
259
319
|
return s.trim();
|
|
260
320
|
});
|
|
261
321
|
}
|
|
322
|
+
|
|
262
323
|
var singleType = type.replace("[]", "");
|
|
263
324
|
return value.map(function (element) {
|
|
264
325
|
return _this2.FormatContractArgument({
|
|
@@ -267,44 +328,48 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
267
328
|
});
|
|
268
329
|
});
|
|
269
330
|
}
|
|
331
|
+
|
|
270
332
|
switch (type.toLowerCase()) {
|
|
271
333
|
case "bytes32":
|
|
272
334
|
return Ethers.utils.formatBytes32String(value);
|
|
335
|
+
|
|
273
336
|
case "bytes":
|
|
274
337
|
return Ethers.utils.toUtf8Bytes(value);
|
|
338
|
+
|
|
275
339
|
case "address":
|
|
276
340
|
return Utils.FormatAddress(value);
|
|
341
|
+
|
|
277
342
|
default:
|
|
278
343
|
return value;
|
|
279
344
|
}
|
|
280
|
-
}
|
|
345
|
+
} // Apply any necessary formatting to contract arguments based on the ABI spec
|
|
281
346
|
|
|
282
|
-
// Apply any necessary formatting to contract arguments based on the ABI spec
|
|
283
347
|
}, {
|
|
284
348
|
key: "FormatContractArguments",
|
|
285
349
|
value: function FormatContractArguments(_ref7) {
|
|
286
350
|
var _this3 = this;
|
|
351
|
+
|
|
287
352
|
var abi = _ref7.abi,
|
|
288
|
-
|
|
289
|
-
|
|
353
|
+
methodName = _ref7.methodName,
|
|
354
|
+
args = _ref7.args;
|
|
290
355
|
var method = abi.find(function (func) {
|
|
291
356
|
// Constructor has type=constructor but no name
|
|
292
357
|
return func.name === methodName || func.type === methodName;
|
|
293
358
|
});
|
|
359
|
+
|
|
294
360
|
if (method === undefined) {
|
|
295
361
|
throw Error("Unknown method: " + methodName);
|
|
296
|
-
}
|
|
362
|
+
} // Format each argument
|
|
363
|
+
|
|
297
364
|
|
|
298
|
-
// Format each argument
|
|
299
365
|
return args.map(function (arg, i) {
|
|
300
366
|
return _this3.FormatContractArgument({
|
|
301
367
|
type: method.inputs[i].type,
|
|
302
368
|
value: arg
|
|
303
369
|
});
|
|
304
370
|
});
|
|
305
|
-
}
|
|
371
|
+
} // Validate signer is set
|
|
306
372
|
|
|
307
|
-
// Validate signer is set
|
|
308
373
|
}, {
|
|
309
374
|
key: "ValidateSigner",
|
|
310
375
|
value: function ValidateSigner(signer) {
|
|
@@ -317,177 +382,221 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
317
382
|
value: function () {
|
|
318
383
|
var _DeployContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
319
384
|
var abi, bytecode, _ref8$constructorArgs, constructorArgs, _ref8$overrides, overrides, provider, signer, contractFactory, contract;
|
|
385
|
+
|
|
320
386
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
321
|
-
while (1)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
387
|
+
while (1) {
|
|
388
|
+
switch (_context5.prev = _context5.next) {
|
|
389
|
+
case 0:
|
|
390
|
+
abi = _ref8.abi, bytecode = _ref8.bytecode, _ref8$constructorArgs = _ref8.constructorArgs, constructorArgs = _ref8$constructorArgs === void 0 ? [] : _ref8$constructorArgs, _ref8$overrides = _ref8.overrides, overrides = _ref8$overrides === void 0 ? {} : _ref8$overrides;
|
|
391
|
+
this.Log("Deploying contract with args [".concat(constructorArgs.join(", "), "]"));
|
|
392
|
+
provider = this.Provider();
|
|
393
|
+
provider.getNetwork();
|
|
394
|
+
signer = this.client.signer.connect(provider);
|
|
395
|
+
this.ValidateSigner(signer);
|
|
396
|
+
contractFactory = new Ethers.ContractFactory(abi, bytecode, signer);
|
|
397
|
+
_context5.next = 9;
|
|
398
|
+
return contractFactory.deploy.apply(contractFactory, _toConsumableArray(constructorArgs).concat([overrides]));
|
|
399
|
+
|
|
400
|
+
case 9:
|
|
401
|
+
contract = _context5.sent;
|
|
402
|
+
_context5.next = 12;
|
|
403
|
+
return contract.deployed();
|
|
404
|
+
|
|
405
|
+
case 12:
|
|
406
|
+
this.Log("Deployed: ".concat(contract.address));
|
|
407
|
+
return _context5.abrupt("return", {
|
|
408
|
+
contractAddress: Utils.FormatAddress(contract.address),
|
|
409
|
+
transactionHash: contract.deployTransaction.hash
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
case 14:
|
|
413
|
+
case "end":
|
|
414
|
+
return _context5.stop();
|
|
415
|
+
}
|
|
345
416
|
}
|
|
346
417
|
}, _callee5, this);
|
|
347
418
|
}));
|
|
419
|
+
|
|
348
420
|
function DeployContract(_x4) {
|
|
349
421
|
return _DeployContract.apply(this, arguments);
|
|
350
422
|
}
|
|
423
|
+
|
|
351
424
|
return DeployContract;
|
|
352
425
|
}() // Accepts either contract object or contract address
|
|
426
|
+
|
|
353
427
|
}, {
|
|
354
428
|
key: "CallContractMethod",
|
|
355
429
|
value: function () {
|
|
356
430
|
var _CallContractMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref9) {
|
|
357
431
|
var contract, contractAddress, abi, methodName, _ref9$methodArgs, methodArgs, value, _ref9$overrides, overrides, _ref9$formatArguments, formatArguments, _ref9$cacheContract, cacheContract, _ref9$overrideCachedC, overrideCachedContract, methodAbi, result, success, _contract, latestBlock;
|
|
432
|
+
|
|
358
433
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
359
|
-
while (1)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
abi
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// Automatically format contract arguments
|
|
382
|
-
if (formatArguments) {
|
|
383
|
-
methodArgs = this.FormatContractArguments({
|
|
434
|
+
while (1) {
|
|
435
|
+
switch (_context6.prev = _context6.next) {
|
|
436
|
+
case 0:
|
|
437
|
+
contract = _ref9.contract, contractAddress = _ref9.contractAddress, abi = _ref9.abi, methodName = _ref9.methodName, _ref9$methodArgs = _ref9.methodArgs, methodArgs = _ref9$methodArgs === void 0 ? [] : _ref9$methodArgs, value = _ref9.value, _ref9$overrides = _ref9.overrides, overrides = _ref9$overrides === void 0 ? {} : _ref9$overrides, _ref9$formatArguments = _ref9.formatArguments, formatArguments = _ref9$formatArguments === void 0 ? true : _ref9$formatArguments, _ref9$cacheContract = _ref9.cacheContract, cacheContract = _ref9$cacheContract === void 0 ? true : _ref9$cacheContract, _ref9$overrideCachedC = _ref9.overrideCachedContract, overrideCachedContract = _ref9$overrideCachedC === void 0 ? false : _ref9$overrideCachedC;
|
|
438
|
+
|
|
439
|
+
if (abi) {
|
|
440
|
+
_context6.next = 5;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
_context6.next = 4;
|
|
445
|
+
return this.client.ContractAbi({
|
|
446
|
+
contractAddress: contractAddress
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
case 4:
|
|
450
|
+
abi = _context6.sent;
|
|
451
|
+
|
|
452
|
+
case 5:
|
|
453
|
+
contract = contract || this.Contract({
|
|
454
|
+
contractAddress: contractAddress,
|
|
384
455
|
abi: abi,
|
|
385
|
-
|
|
386
|
-
|
|
456
|
+
cacheContract: cacheContract,
|
|
457
|
+
overrideCachedContract: overrideCachedContract
|
|
387
458
|
});
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
459
|
+
abi = contract["interface"].fragments; // Automatically format contract arguments
|
|
460
|
+
|
|
461
|
+
if (formatArguments) {
|
|
462
|
+
methodArgs = this.FormatContractArguments({
|
|
463
|
+
abi: abi,
|
|
464
|
+
methodName: methodName,
|
|
465
|
+
args: methodArgs
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (value) {
|
|
470
|
+
// Convert Ether to Wei
|
|
471
|
+
overrides.value = "0x" + Utils.EtherToWei(value.toString()).toString(16);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (!(contract.functions[methodName] === undefined)) {
|
|
475
|
+
_context6.next = 11;
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
throw Error("Unknown method: " + methodName);
|
|
480
|
+
|
|
481
|
+
case 11:
|
|
482
|
+
this.Log("Calling contract method:\n Provider: ".concat(this.Provider().connection.url, "\n Address: ").concat(contract.address, "\n Method: ").concat(methodName, "\n Args: [").concat(methodArgs.join(", "), "]"));
|
|
483
|
+
methodAbi = contract["interface"].fragments.find(function (method) {
|
|
484
|
+
return method.name === methodName;
|
|
485
|
+
}); // Lock if performing a transaction
|
|
486
|
+
|
|
487
|
+
if (!(!methodAbi || !methodAbi.constant)) {
|
|
488
|
+
_context6.next = 20;
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
case 14:
|
|
493
|
+
if (!this.locked) {
|
|
494
|
+
_context6.next = 19;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
_context6.next = 17;
|
|
499
|
+
return new Promise(function (resolve) {
|
|
500
|
+
return setTimeout(resolve, 100);
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
case 17:
|
|
504
|
+
_context6.next = 14;
|
|
427
505
|
break;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
506
|
+
|
|
507
|
+
case 19:
|
|
508
|
+
this.locked = true;
|
|
509
|
+
|
|
510
|
+
case 20:
|
|
511
|
+
_context6.prev = 20;
|
|
512
|
+
success = false;
|
|
513
|
+
|
|
514
|
+
case 22:
|
|
515
|
+
if (success) {
|
|
516
|
+
_context6.next = 49;
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
_context6.prev = 23;
|
|
521
|
+
_context6.next = 26;
|
|
522
|
+
return (_contract = contract)[methodName].apply(_contract, _toConsumableArray(methodArgs).concat([overrides]));
|
|
523
|
+
|
|
524
|
+
case 26:
|
|
525
|
+
result = _context6.sent;
|
|
526
|
+
success = true;
|
|
527
|
+
_context6.next = 47;
|
|
442
528
|
break;
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
529
|
+
|
|
530
|
+
case 30:
|
|
531
|
+
_context6.prev = 30;
|
|
532
|
+
_context6.t0 = _context6["catch"](23);
|
|
533
|
+
|
|
534
|
+
if (!(_context6.t0.code === -32000 || _context6.t0.code === "REPLACEMENT_UNDERPRICED")) {
|
|
535
|
+
_context6.next = 40;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
_context6.next = 35;
|
|
540
|
+
return this.MakeProviderCall({
|
|
541
|
+
methodName: "getBlock",
|
|
542
|
+
args: ["latest"]
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
case 35:
|
|
546
|
+
latestBlock = _context6.sent;
|
|
547
|
+
overrides.gasLimit = latestBlock.gasLimit;
|
|
548
|
+
overrides.gasPrice = overrides.gasPrice ? overrides.gasPrice * 1.50 : 8000000000;
|
|
549
|
+
_context6.next = 47;
|
|
458
550
|
break;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
551
|
+
|
|
552
|
+
case 40:
|
|
553
|
+
if (!(_context6.t0.code === "NONCE_EXPIRED" && _context6.t0.reason === "nonce has already been used")) {
|
|
554
|
+
_context6.next = 44;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
this.Log("Retrying method call ".concat(methodName));
|
|
465
559
|
_context6.next = 47;
|
|
466
560
|
break;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
561
|
+
|
|
562
|
+
case 44:
|
|
563
|
+
if ((_context6.t0.message || _context6.t0).includes("invalid response")) {
|
|
564
|
+
_context6.next = 47;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
this.Log(_typeof(_context6.t0) === "object" ? JSON.stringify(_context6.t0, null, 2) : _context6.t0, true);
|
|
569
|
+
throw _context6.t0;
|
|
570
|
+
|
|
571
|
+
case 47:
|
|
572
|
+
_context6.next = 22;
|
|
573
|
+
break;
|
|
574
|
+
|
|
575
|
+
case 49:
|
|
576
|
+
return _context6.abrupt("return", result);
|
|
577
|
+
|
|
578
|
+
case 50:
|
|
579
|
+
_context6.prev = 50;
|
|
580
|
+
|
|
581
|
+
// Unlock if performing a transaction
|
|
582
|
+
if (!methodAbi || !methodAbi.constant) {
|
|
583
|
+
this.locked = false;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return _context6.finish(50);
|
|
587
|
+
|
|
588
|
+
case 53:
|
|
589
|
+
case "end":
|
|
590
|
+
return _context6.stop();
|
|
591
|
+
}
|
|
485
592
|
}
|
|
486
593
|
}, _callee6, this, [[20,, 50, 53], [23, 30]]);
|
|
487
594
|
}));
|
|
595
|
+
|
|
488
596
|
function CallContractMethod(_x5) {
|
|
489
597
|
return _CallContractMethod.apply(this, arguments);
|
|
490
598
|
}
|
|
599
|
+
|
|
491
600
|
return CallContractMethod;
|
|
492
601
|
}()
|
|
493
602
|
}, {
|
|
@@ -495,96 +604,118 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
495
604
|
value: function () {
|
|
496
605
|
var _CallContractMethodAndWait = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref10) {
|
|
497
606
|
var contractAddress, abi, methodName, methodArgs, value, timeout, _ref10$formatArgument, formatArguments, _ref10$cacheContract, cacheContract, _ref10$overrideCached, overrideCachedContract, contract, createMethodCall, interval, elapsed, methodEvent;
|
|
607
|
+
|
|
498
608
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
499
|
-
while (1)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
abi
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
_context7.next =
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
_context7.
|
|
609
|
+
while (1) {
|
|
610
|
+
switch (_context7.prev = _context7.next) {
|
|
611
|
+
case 0:
|
|
612
|
+
contractAddress = _ref10.contractAddress, abi = _ref10.abi, methodName = _ref10.methodName, methodArgs = _ref10.methodArgs, value = _ref10.value, timeout = _ref10.timeout, _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;
|
|
613
|
+
timeout = timeout || this.timeout || 10000;
|
|
614
|
+
|
|
615
|
+
if (abi) {
|
|
616
|
+
_context7.next = 6;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
_context7.next = 5;
|
|
621
|
+
return this.client.ContractAbi({
|
|
622
|
+
contractAddress: contractAddress
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
case 5:
|
|
626
|
+
abi = _context7.sent;
|
|
627
|
+
|
|
628
|
+
case 6:
|
|
629
|
+
contract = this.Contract({
|
|
630
|
+
contractAddress: contractAddress,
|
|
631
|
+
abi: abi,
|
|
632
|
+
cacheContract: cacheContract,
|
|
633
|
+
overrideCachedContract: overrideCachedContract
|
|
634
|
+
}); // Make method call
|
|
635
|
+
|
|
636
|
+
_context7.next = 9;
|
|
637
|
+
return this.CallContractMethod({
|
|
638
|
+
contract: contract,
|
|
639
|
+
abi: abi,
|
|
640
|
+
methodName: methodName,
|
|
641
|
+
methodArgs: methodArgs,
|
|
642
|
+
value: value,
|
|
643
|
+
formatArguments: formatArguments,
|
|
644
|
+
cacheContract: cacheContract
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
case 9:
|
|
648
|
+
createMethodCall = _context7.sent;
|
|
649
|
+
this.Log("Awaiting transaction completion: ".concat(createMethodCall.hash)); // Poll for transaction completion
|
|
650
|
+
|
|
651
|
+
interval = this.Provider().pollingInterval;
|
|
652
|
+
elapsed = 0;
|
|
653
|
+
|
|
654
|
+
case 13:
|
|
655
|
+
if (!(elapsed < timeout)) {
|
|
656
|
+
_context7.next = 25;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
_context7.next = 16;
|
|
661
|
+
return this.MakeProviderCall({
|
|
662
|
+
methodName: "getTransactionReceipt",
|
|
663
|
+
args: [createMethodCall.hash]
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
case 16:
|
|
667
|
+
methodEvent = _context7.sent;
|
|
668
|
+
|
|
669
|
+
if (!methodEvent) {
|
|
670
|
+
_context7.next = 20;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
methodEvent.logs = methodEvent.logs.map(function (log) {
|
|
675
|
+
var parsedLogs = {};
|
|
676
|
+
|
|
677
|
+
try {
|
|
678
|
+
parsedLogs = contract["interface"].parseLog(log); // eslint-disable-next-line no-empty
|
|
679
|
+
} catch (error) {}
|
|
680
|
+
|
|
681
|
+
return _objectSpread(_objectSpread({}, log), parsedLogs);
|
|
682
|
+
});
|
|
683
|
+
return _context7.abrupt("break", 25);
|
|
684
|
+
|
|
685
|
+
case 20:
|
|
686
|
+
elapsed += interval;
|
|
687
|
+
_context7.next = 23;
|
|
688
|
+
return new Promise(function (resolve) {
|
|
689
|
+
return setTimeout(resolve, interval);
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
case 23:
|
|
693
|
+
_context7.next = 13;
|
|
574
694
|
break;
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
695
|
+
|
|
696
|
+
case 25:
|
|
697
|
+
if (methodEvent) {
|
|
698
|
+
_context7.next = 27;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
throw Error("Timed out waiting for completion of ".concat(methodName, ". TXID: ").concat(createMethodCall.hash));
|
|
703
|
+
|
|
704
|
+
case 27:
|
|
705
|
+
return _context7.abrupt("return", methodEvent);
|
|
706
|
+
|
|
707
|
+
case 28:
|
|
708
|
+
case "end":
|
|
709
|
+
return _context7.stop();
|
|
710
|
+
}
|
|
582
711
|
}
|
|
583
712
|
}, _callee7, this);
|
|
584
713
|
}));
|
|
714
|
+
|
|
585
715
|
function CallContractMethodAndWait(_x6) {
|
|
586
716
|
return _CallContractMethodAndWait.apply(this, arguments);
|
|
587
717
|
}
|
|
718
|
+
|
|
588
719
|
return CallContractMethodAndWait;
|
|
589
720
|
}()
|
|
590
721
|
}, {
|
|
@@ -593,52 +724,61 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
593
724
|
var _AwaitEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref11) {
|
|
594
725
|
var contractAddress, abi, eventName, contract;
|
|
595
726
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
596
|
-
while (1)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
contract.
|
|
607
|
-
|
|
727
|
+
while (1) {
|
|
728
|
+
switch (_context8.prev = _context8.next) {
|
|
729
|
+
case 0:
|
|
730
|
+
contractAddress = _ref11.contractAddress, abi = _ref11.abi, eventName = _ref11.eventName;
|
|
731
|
+
contract = this.Contract({
|
|
732
|
+
contractAddress: contractAddress,
|
|
733
|
+
abi: abi
|
|
734
|
+
});
|
|
735
|
+
_context8.next = 4;
|
|
736
|
+
return new Promise(function (resolve) {
|
|
737
|
+
contract.on(eventName, function (_, __, event) {
|
|
738
|
+
contract.removeAllListeners(eventName);
|
|
739
|
+
resolve(event);
|
|
740
|
+
});
|
|
608
741
|
});
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
742
|
+
|
|
743
|
+
case 4:
|
|
744
|
+
return _context8.abrupt("return", _context8.sent);
|
|
745
|
+
|
|
746
|
+
case 5:
|
|
747
|
+
case "end":
|
|
748
|
+
return _context8.stop();
|
|
749
|
+
}
|
|
615
750
|
}
|
|
616
751
|
}, _callee8, this);
|
|
617
752
|
}));
|
|
753
|
+
|
|
618
754
|
function AwaitEvent(_x7) {
|
|
619
755
|
return _AwaitEvent.apply(this, arguments);
|
|
620
756
|
}
|
|
757
|
+
|
|
621
758
|
return AwaitEvent;
|
|
622
759
|
}()
|
|
623
760
|
}, {
|
|
624
761
|
key: "ExtractEventFromLogs",
|
|
625
762
|
value: function ExtractEventFromLogs(_ref12) {
|
|
626
763
|
var abi = _ref12.abi,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
var contractInterface = new Ethers.utils.Interface(abi);
|
|
630
|
-
|
|
764
|
+
event = _ref12.event,
|
|
765
|
+
eventName = _ref12.eventName;
|
|
766
|
+
var contractInterface = new Ethers.utils.Interface(abi); // Loop through logs to find the desired log
|
|
767
|
+
|
|
631
768
|
var _iterator = _createForOfIteratorHelper(event.logs),
|
|
632
|
-
|
|
769
|
+
_step;
|
|
770
|
+
|
|
633
771
|
try {
|
|
634
772
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
635
773
|
var log = _step.value;
|
|
774
|
+
|
|
636
775
|
try {
|
|
637
776
|
var parsedLog = contractInterface.parseLog(log);
|
|
777
|
+
|
|
638
778
|
if (parsedLog && parsedLog.name === eventName) {
|
|
639
779
|
return parsedLog;
|
|
640
|
-
}
|
|
641
|
-
|
|
780
|
+
} // eslint-disable-next-line no-empty
|
|
781
|
+
|
|
642
782
|
} catch (error) {}
|
|
643
783
|
}
|
|
644
784
|
} catch (err) {
|
|
@@ -652,78 +792,96 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
652
792
|
value: function () {
|
|
653
793
|
var _DeployDependentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
|
|
654
794
|
var contractAddress, methodName, _ref13$args, args, eventName, eventValue, abi, event, eventLog, newContractAddress;
|
|
795
|
+
|
|
655
796
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
656
|
-
while (1)
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
event
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
797
|
+
while (1) {
|
|
798
|
+
switch (_context9.prev = _context9.next) {
|
|
799
|
+
case 0:
|
|
800
|
+
contractAddress = _ref13.contractAddress, methodName = _ref13.methodName, _ref13$args = _ref13.args, args = _ref13$args === void 0 ? [] : _ref13$args, eventName = _ref13.eventName, eventValue = _ref13.eventValue;
|
|
801
|
+
_context9.next = 3;
|
|
802
|
+
return this.client.ContractAbi({
|
|
803
|
+
contractAddress: contractAddress
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
case 3:
|
|
807
|
+
abi = _context9.sent;
|
|
808
|
+
_context9.next = 6;
|
|
809
|
+
return this.CallContractMethodAndWait({
|
|
810
|
+
contractAddress: contractAddress,
|
|
811
|
+
abi: abi,
|
|
812
|
+
methodName: methodName,
|
|
813
|
+
methodArgs: args
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
case 6:
|
|
817
|
+
event = _context9.sent;
|
|
818
|
+
eventLog = this.ExtractEventFromLogs({
|
|
819
|
+
abi: abi,
|
|
820
|
+
event: event,
|
|
821
|
+
eventName: eventName,
|
|
822
|
+
eventValue: eventValue
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
if (eventLog) {
|
|
826
|
+
_context9.next = 10;
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
throw Error("".concat(methodName, " failed - Log not present in transaction"));
|
|
831
|
+
|
|
832
|
+
case 10:
|
|
833
|
+
newContractAddress = eventLog.args[eventValue];
|
|
834
|
+
return _context9.abrupt("return", {
|
|
835
|
+
contractAddress: Utils.FormatAddress(newContractAddress),
|
|
836
|
+
transactionHash: event.transactionHash
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
case 12:
|
|
840
|
+
case "end":
|
|
841
|
+
return _context9.stop();
|
|
842
|
+
}
|
|
694
843
|
}
|
|
695
844
|
}, _callee9, this);
|
|
696
845
|
}));
|
|
846
|
+
|
|
697
847
|
function DeployDependentContract(_x8) {
|
|
698
848
|
return _DeployDependentContract.apply(this, arguments);
|
|
699
849
|
}
|
|
850
|
+
|
|
700
851
|
return DeployDependentContract;
|
|
701
|
-
}()
|
|
852
|
+
}()
|
|
853
|
+
/* Specific contract management */
|
|
854
|
+
|
|
702
855
|
}, {
|
|
703
856
|
key: "DeployAccessGroupContract",
|
|
704
857
|
value: function () {
|
|
705
858
|
var _DeployAccessGroupContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
|
|
706
859
|
var contentSpaceAddress;
|
|
707
860
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
708
|
-
while (1)
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
861
|
+
while (1) {
|
|
862
|
+
switch (_context10.prev = _context10.next) {
|
|
863
|
+
case 0:
|
|
864
|
+
contentSpaceAddress = _ref14.contentSpaceAddress;
|
|
865
|
+
return _context10.abrupt("return", this.DeployDependentContract({
|
|
866
|
+
contractAddress: contentSpaceAddress,
|
|
867
|
+
methodName: "createGroup",
|
|
868
|
+
args: [],
|
|
869
|
+
eventName: "CreateGroup",
|
|
870
|
+
eventValue: "groupAddress"
|
|
871
|
+
}));
|
|
872
|
+
|
|
873
|
+
case 2:
|
|
874
|
+
case "end":
|
|
875
|
+
return _context10.stop();
|
|
876
|
+
}
|
|
721
877
|
}
|
|
722
878
|
}, _callee10, this);
|
|
723
879
|
}));
|
|
880
|
+
|
|
724
881
|
function DeployAccessGroupContract(_x9) {
|
|
725
882
|
return _DeployAccessGroupContract.apply(this, arguments);
|
|
726
883
|
}
|
|
884
|
+
|
|
727
885
|
return DeployAccessGroupContract;
|
|
728
886
|
}()
|
|
729
887
|
}, {
|
|
@@ -732,25 +890,30 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
732
890
|
var _DeployTypeContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref15) {
|
|
733
891
|
var contentSpaceAddress;
|
|
734
892
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
735
|
-
while (1)
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
893
|
+
while (1) {
|
|
894
|
+
switch (_context11.prev = _context11.next) {
|
|
895
|
+
case 0:
|
|
896
|
+
contentSpaceAddress = _ref15.contentSpaceAddress;
|
|
897
|
+
return _context11.abrupt("return", this.DeployDependentContract({
|
|
898
|
+
contractAddress: contentSpaceAddress,
|
|
899
|
+
methodName: "createContentType",
|
|
900
|
+
args: [],
|
|
901
|
+
eventName: "CreateContentType",
|
|
902
|
+
eventValue: "contentTypeAddress"
|
|
903
|
+
}));
|
|
904
|
+
|
|
905
|
+
case 2:
|
|
906
|
+
case "end":
|
|
907
|
+
return _context11.stop();
|
|
908
|
+
}
|
|
748
909
|
}
|
|
749
910
|
}, _callee11, this);
|
|
750
911
|
}));
|
|
912
|
+
|
|
751
913
|
function DeployTypeContract(_x10) {
|
|
752
914
|
return _DeployTypeContract.apply(this, arguments);
|
|
753
915
|
}
|
|
916
|
+
|
|
754
917
|
return DeployTypeContract;
|
|
755
918
|
}()
|
|
756
919
|
}, {
|
|
@@ -759,26 +922,31 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
759
922
|
var _DeployLibraryContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref16) {
|
|
760
923
|
var contentSpaceAddress, kmsId, kmsAddress;
|
|
761
924
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
762
|
-
while (1)
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
925
|
+
while (1) {
|
|
926
|
+
switch (_context12.prev = _context12.next) {
|
|
927
|
+
case 0:
|
|
928
|
+
contentSpaceAddress = _ref16.contentSpaceAddress, kmsId = _ref16.kmsId;
|
|
929
|
+
kmsAddress = Utils.HashToAddress(kmsId);
|
|
930
|
+
return _context12.abrupt("return", this.DeployDependentContract({
|
|
931
|
+
contractAddress: contentSpaceAddress,
|
|
932
|
+
methodName: "createLibrary",
|
|
933
|
+
args: [kmsAddress],
|
|
934
|
+
eventName: "CreateLibrary",
|
|
935
|
+
eventValue: "libraryAddress"
|
|
936
|
+
}));
|
|
937
|
+
|
|
938
|
+
case 3:
|
|
939
|
+
case "end":
|
|
940
|
+
return _context12.stop();
|
|
941
|
+
}
|
|
776
942
|
}
|
|
777
943
|
}, _callee12, this);
|
|
778
944
|
}));
|
|
945
|
+
|
|
779
946
|
function DeployLibraryContract(_x11) {
|
|
780
947
|
return _DeployLibraryContract.apply(this, arguments);
|
|
781
948
|
}
|
|
949
|
+
|
|
782
950
|
return DeployLibraryContract;
|
|
783
951
|
}()
|
|
784
952
|
}, {
|
|
@@ -787,27 +955,32 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
787
955
|
var _DeployContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
|
|
788
956
|
var contentLibraryAddress, typeAddress;
|
|
789
957
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
790
|
-
while (1)
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
958
|
+
while (1) {
|
|
959
|
+
switch (_context13.prev = _context13.next) {
|
|
960
|
+
case 0:
|
|
961
|
+
contentLibraryAddress = _ref17.contentLibraryAddress, typeAddress = _ref17.typeAddress;
|
|
962
|
+
// If type is not specified, use null address
|
|
963
|
+
typeAddress = typeAddress || Utils.nullAddress;
|
|
964
|
+
return _context13.abrupt("return", this.DeployDependentContract({
|
|
965
|
+
contractAddress: contentLibraryAddress,
|
|
966
|
+
methodName: "createContent",
|
|
967
|
+
args: [typeAddress],
|
|
968
|
+
eventName: "ContentObjectCreated",
|
|
969
|
+
eventValue: "contentAddress"
|
|
970
|
+
}));
|
|
971
|
+
|
|
972
|
+
case 3:
|
|
973
|
+
case "end":
|
|
974
|
+
return _context13.stop();
|
|
975
|
+
}
|
|
805
976
|
}
|
|
806
977
|
}, _callee13, this);
|
|
807
978
|
}));
|
|
979
|
+
|
|
808
980
|
function DeployContentContract(_x12) {
|
|
809
981
|
return _DeployContentContract.apply(this, arguments);
|
|
810
982
|
}
|
|
983
|
+
|
|
811
984
|
return DeployContentContract;
|
|
812
985
|
}()
|
|
813
986
|
}, {
|
|
@@ -816,27 +989,33 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
816
989
|
var _CommitContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
|
|
817
990
|
var contentObjectAddress, versionHash;
|
|
818
991
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
819
|
-
while (1)
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
992
|
+
while (1) {
|
|
993
|
+
switch (_context14.prev = _context14.next) {
|
|
994
|
+
case 0:
|
|
995
|
+
contentObjectAddress = _ref18.contentObjectAddress, versionHash = _ref18.versionHash;
|
|
996
|
+
_context14.next = 3;
|
|
997
|
+
return this.CallContractMethodAndWait({
|
|
998
|
+
contractAddress: contentObjectAddress,
|
|
999
|
+
methodName: "commit",
|
|
1000
|
+
methodArgs: [versionHash],
|
|
1001
|
+
eventName: "CommitPending"
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
case 3:
|
|
1005
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1006
|
+
|
|
1007
|
+
case 4:
|
|
1008
|
+
case "end":
|
|
1009
|
+
return _context14.stop();
|
|
1010
|
+
}
|
|
834
1011
|
}
|
|
835
1012
|
}, _callee14, this);
|
|
836
1013
|
}));
|
|
1014
|
+
|
|
837
1015
|
function CommitContent(_x13) {
|
|
838
1016
|
return _CommitContent.apply(this, arguments);
|
|
839
1017
|
}
|
|
1018
|
+
|
|
840
1019
|
return CommitContent;
|
|
841
1020
|
}()
|
|
842
1021
|
}, {
|
|
@@ -845,23 +1024,28 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
845
1024
|
var _EngageAccountLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
|
|
846
1025
|
var contentSpaceAddress;
|
|
847
1026
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
848
|
-
while (1)
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1027
|
+
while (1) {
|
|
1028
|
+
switch (_context15.prev = _context15.next) {
|
|
1029
|
+
case 0:
|
|
1030
|
+
contentSpaceAddress = _ref19.contentSpaceAddress;
|
|
1031
|
+
return _context15.abrupt("return", this.CallContractMethodAndWait({
|
|
1032
|
+
contractAddress: contentSpaceAddress,
|
|
1033
|
+
methodName: "engageAccountLibrary",
|
|
1034
|
+
args: []
|
|
1035
|
+
}));
|
|
1036
|
+
|
|
1037
|
+
case 2:
|
|
1038
|
+
case "end":
|
|
1039
|
+
return _context15.stop();
|
|
1040
|
+
}
|
|
859
1041
|
}
|
|
860
1042
|
}, _callee15, this);
|
|
861
1043
|
}));
|
|
1044
|
+
|
|
862
1045
|
function EngageAccountLibrary(_x14) {
|
|
863
1046
|
return _EngageAccountLibrary.apply(this, arguments);
|
|
864
1047
|
}
|
|
1048
|
+
|
|
865
1049
|
return EngageAccountLibrary;
|
|
866
1050
|
}()
|
|
867
1051
|
}, {
|
|
@@ -869,128 +1053,165 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
869
1053
|
value: function () {
|
|
870
1054
|
var _SetCustomContentContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
|
|
871
1055
|
var contentContractAddress, customContractAddress, _ref20$overrides, overrides;
|
|
1056
|
+
|
|
872
1057
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
873
|
-
while (1)
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1058
|
+
while (1) {
|
|
1059
|
+
switch (_context16.prev = _context16.next) {
|
|
1060
|
+
case 0:
|
|
1061
|
+
contentContractAddress = _ref20.contentContractAddress, customContractAddress = _ref20.customContractAddress, _ref20$overrides = _ref20.overrides, overrides = _ref20$overrides === void 0 ? {} : _ref20$overrides;
|
|
1062
|
+
_context16.next = 3;
|
|
1063
|
+
return this.CallContractMethodAndWait({
|
|
1064
|
+
contractAddress: contentContractAddress,
|
|
1065
|
+
methodName: "setContentContractAddress",
|
|
1066
|
+
methodArgs: [customContractAddress],
|
|
1067
|
+
overrides: overrides
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
case 3:
|
|
1071
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1072
|
+
|
|
1073
|
+
case 4:
|
|
1074
|
+
case "end":
|
|
1075
|
+
return _context16.stop();
|
|
1076
|
+
}
|
|
888
1077
|
}
|
|
889
1078
|
}, _callee16, this);
|
|
890
1079
|
}));
|
|
1080
|
+
|
|
891
1081
|
function SetCustomContentContract(_x15) {
|
|
892
1082
|
return _SetCustomContentContract.apply(this, arguments);
|
|
893
1083
|
}
|
|
1084
|
+
|
|
894
1085
|
return SetCustomContentContract;
|
|
895
1086
|
}() // Get all logs for the specified contract in the specified range
|
|
1087
|
+
|
|
896
1088
|
}, {
|
|
897
1089
|
key: "ContractEvents",
|
|
898
1090
|
value: function () {
|
|
899
1091
|
var _ContractEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
|
|
900
1092
|
var _this4 = this;
|
|
1093
|
+
|
|
901
1094
|
var contractAddress, abi, _ref21$fromBlock, fromBlock, toBlock, topics, _ref21$includeTransac, includeTransaction, filter, contractLogs, blocks;
|
|
1095
|
+
|
|
902
1096
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
903
|
-
while (1)
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1097
|
+
while (1) {
|
|
1098
|
+
switch (_context18.prev = _context18.next) {
|
|
1099
|
+
case 0:
|
|
1100
|
+
contractAddress = _ref21.contractAddress, abi = _ref21.abi, _ref21$fromBlock = _ref21.fromBlock, fromBlock = _ref21$fromBlock === void 0 ? 0 : _ref21$fromBlock, toBlock = _ref21.toBlock, topics = _ref21.topics, _ref21$includeTransac = _ref21.includeTransaction, includeTransaction = _ref21$includeTransac === void 0 ? false : _ref21$includeTransac;
|
|
1101
|
+
filter = {
|
|
1102
|
+
address: contractAddress,
|
|
1103
|
+
fromBlock: fromBlock,
|
|
1104
|
+
toBlock: toBlock
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
if (topics) {
|
|
1108
|
+
filter.topics = topics;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
_context18.next = 5;
|
|
1112
|
+
return this.MakeProviderCall({
|
|
1113
|
+
methodName: "getLogs",
|
|
1114
|
+
args: [filter]
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
case 5:
|
|
1118
|
+
_context18.t0 = _context18.sent;
|
|
1119
|
+
|
|
1120
|
+
if (_context18.t0) {
|
|
1121
|
+
_context18.next = 8;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
_context18.t0 = [];
|
|
1126
|
+
|
|
1127
|
+
case 8:
|
|
1128
|
+
contractLogs = _context18.t0;
|
|
1129
|
+
|
|
1130
|
+
if (Array.isArray(contractLogs)) {
|
|
1131
|
+
_context18.next = 11;
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
return _context18.abrupt("return", []);
|
|
1136
|
+
|
|
1137
|
+
case 11:
|
|
1138
|
+
blocks = {};
|
|
1139
|
+
_context18.next = 14;
|
|
1140
|
+
return Utils.LimitedMap(5, contractLogs, /*#__PURE__*/function () {
|
|
1141
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(log) {
|
|
1142
|
+
var eventInterface, parsedLog;
|
|
1143
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1144
|
+
while (1) {
|
|
1145
|
+
switch (_context17.prev = _context17.next) {
|
|
1146
|
+
case 0:
|
|
1147
|
+
eventInterface = new Ethers.utils.Interface(abi);
|
|
1148
|
+
parsedLog = _objectSpread(_objectSpread({}, log), eventInterface.parseLog(log));
|
|
1149
|
+
|
|
1150
|
+
if (!includeTransaction) {
|
|
1151
|
+
_context17.next = 9;
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
_context17.t0 = _objectSpread;
|
|
1156
|
+
_context17.t1 = _objectSpread({}, parsedLog);
|
|
1157
|
+
_context17.next = 7;
|
|
1158
|
+
return _this4.MakeProviderCall({
|
|
1159
|
+
methodName: "getTransaction",
|
|
1160
|
+
args: [log.transactionHash]
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
case 7:
|
|
1164
|
+
_context17.t2 = _context17.sent;
|
|
1165
|
+
parsedLog = (0, _context17.t0)(_context17.t1, _context17.t2);
|
|
1166
|
+
|
|
1167
|
+
case 9:
|
|
1168
|
+
blocks[log.blockNumber] = [parsedLog].concat(blocks[log.blockNumber] || []);
|
|
1169
|
+
|
|
1170
|
+
case 10:
|
|
1171
|
+
case "end":
|
|
1172
|
+
return _context17.stop();
|
|
947
1173
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
case 10:
|
|
961
|
-
case "end":
|
|
962
|
-
return _context17.stop();
|
|
963
|
-
}
|
|
964
|
-
}, _callee17);
|
|
1174
|
+
}
|
|
1175
|
+
}, _callee17);
|
|
1176
|
+
}));
|
|
1177
|
+
|
|
1178
|
+
return function (_x17) {
|
|
1179
|
+
return _ref22.apply(this, arguments);
|
|
1180
|
+
};
|
|
1181
|
+
}());
|
|
1182
|
+
|
|
1183
|
+
case 14:
|
|
1184
|
+
return _context18.abrupt("return", Object.values(blocks).sort(function (a, b) {
|
|
1185
|
+
return a[0].blockNumber < b[0].blockNumber ? 1 : -1;
|
|
965
1186
|
}));
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
return _context18.abrupt("return", Object.values(blocks).sort(function (a, b) {
|
|
972
|
-
return a[0].blockNumber < b[0].blockNumber ? 1 : -1;
|
|
973
|
-
}));
|
|
974
|
-
case 15:
|
|
975
|
-
case "end":
|
|
976
|
-
return _context18.stop();
|
|
1187
|
+
|
|
1188
|
+
case 15:
|
|
1189
|
+
case "end":
|
|
1190
|
+
return _context18.stop();
|
|
1191
|
+
}
|
|
977
1192
|
}
|
|
978
1193
|
}, _callee18, this);
|
|
979
1194
|
}));
|
|
1195
|
+
|
|
980
1196
|
function ContractEvents(_x16) {
|
|
981
1197
|
return _ContractEvents.apply(this, arguments);
|
|
982
1198
|
}
|
|
1199
|
+
|
|
983
1200
|
return ContractEvents;
|
|
984
1201
|
}() // Look up the log topic and see if it is known. If so, parse it and inject it into the log
|
|
1202
|
+
|
|
985
1203
|
}, {
|
|
986
1204
|
key: "ParseUnknownLog",
|
|
987
1205
|
value: function ParseUnknownLog(_ref23) {
|
|
988
1206
|
var log = _ref23.log;
|
|
1207
|
+
|
|
989
1208
|
if (log.topics && log.topics.length > 0) {
|
|
990
1209
|
var topicHash = log.topics[0];
|
|
991
1210
|
var topicInfo = Topics[topicHash];
|
|
1211
|
+
|
|
992
1212
|
if (topicInfo) {
|
|
993
1213
|
var eventInterface = new Ethers.utils.Interface(topicInfo.abi);
|
|
1214
|
+
|
|
994
1215
|
if (eventInterface) {
|
|
995
1216
|
log = _objectSpread(_objectSpread(_objectSpread({}, log), eventInterface.parseLog(log)), {}, {
|
|
996
1217
|
contract: topicInfo.contract
|
|
@@ -998,157 +1219,191 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
998
1219
|
}
|
|
999
1220
|
}
|
|
1000
1221
|
}
|
|
1001
|
-
return log;
|
|
1002
|
-
}
|
|
1003
1222
|
|
|
1004
|
-
|
|
1223
|
+
return log;
|
|
1224
|
+
} // Get logs for all blocks in the specified range
|
|
1005
1225
|
// Returns a list, sorted in descending block order, with each entry containing all logs or transactions in that block
|
|
1226
|
+
|
|
1006
1227
|
}, {
|
|
1007
1228
|
key: "Events",
|
|
1008
1229
|
value: function () {
|
|
1009
1230
|
var _Events = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref24) {
|
|
1010
1231
|
var _this5 = this;
|
|
1232
|
+
|
|
1011
1233
|
var toBlock, fromBlock, _ref24$includeTransac, includeTransaction, logs, i, newLogs, blocks, output;
|
|
1234
|
+
|
|
1012
1235
|
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1013
|
-
while (1)
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1236
|
+
while (1) {
|
|
1237
|
+
switch (_context21.prev = _context21.next) {
|
|
1238
|
+
case 0:
|
|
1239
|
+
toBlock = _ref24.toBlock, fromBlock = _ref24.fromBlock, _ref24$includeTransac = _ref24.includeTransaction, includeTransaction = _ref24$includeTransac === void 0 ? false : _ref24$includeTransac;
|
|
1240
|
+
// Pull logs in batches of 100
|
|
1241
|
+
logs = [];
|
|
1242
|
+
i = fromBlock;
|
|
1243
|
+
|
|
1244
|
+
case 3:
|
|
1245
|
+
if (!(i < toBlock)) {
|
|
1246
|
+
_context21.next = 11;
|
|
1247
|
+
break;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
_context21.next = 6;
|
|
1251
|
+
return this.MakeProviderCall({
|
|
1252
|
+
methodName: "getLogs",
|
|
1253
|
+
args: [{
|
|
1254
|
+
fromBlock: i,
|
|
1255
|
+
toBlock: Math.min(toBlock, i + 100)
|
|
1256
|
+
}]
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
case 6:
|
|
1260
|
+
newLogs = _context21.sent;
|
|
1261
|
+
logs = logs.concat(newLogs || []);
|
|
1262
|
+
|
|
1263
|
+
case 8:
|
|
1264
|
+
i += 101;
|
|
1265
|
+
_context21.next = 3;
|
|
1022
1266
|
break;
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1267
|
+
|
|
1268
|
+
case 11:
|
|
1269
|
+
// Group logs by blocknumber
|
|
1270
|
+
blocks = {};
|
|
1271
|
+
logs.forEach(function (log) {
|
|
1272
|
+
blocks[log.blockNumber] = [_this5.ParseUnknownLog({
|
|
1273
|
+
log: log
|
|
1274
|
+
})].concat(blocks[log.blockNumber] || []);
|
|
1275
|
+
});
|
|
1276
|
+
output = [];
|
|
1277
|
+
_context21.next = 16;
|
|
1278
|
+
return Utils.LimitedMap(3, _toConsumableArray(Array(toBlock - fromBlock + 1).keys()), /*#__PURE__*/function () {
|
|
1279
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(i) {
|
|
1280
|
+
var blockNumber, blockInfo, transactionInfo;
|
|
1281
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1282
|
+
while (1) {
|
|
1283
|
+
switch (_context20.prev = _context20.next) {
|
|
1284
|
+
case 0:
|
|
1285
|
+
blockNumber = toBlock - i;
|
|
1286
|
+
blockInfo = blocks[blockNumber];
|
|
1287
|
+
|
|
1288
|
+
if (blockInfo) {
|
|
1289
|
+
_context20.next = 8;
|
|
1290
|
+
break;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
_context20.next = 5;
|
|
1294
|
+
return _this5.MakeProviderCall({
|
|
1295
|
+
methodName: "getBlock",
|
|
1296
|
+
args: [blockNumber]
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
case 5:
|
|
1300
|
+
blockInfo = _context20.sent;
|
|
1301
|
+
blockInfo = blockInfo.transactions.map(function (transactionHash) {
|
|
1302
|
+
return _objectSpread(_objectSpread({
|
|
1303
|
+
blockNumber: blockInfo.number,
|
|
1304
|
+
blockHash: blockInfo.hash
|
|
1305
|
+
}, blockInfo), {}, {
|
|
1306
|
+
transactionHash: transactionHash
|
|
1307
|
+
});
|
|
1308
|
+
});
|
|
1309
|
+
blocks[blockNumber] = blockInfo;
|
|
1310
|
+
|
|
1311
|
+
case 8:
|
|
1312
|
+
if (!includeTransaction) {
|
|
1313
|
+
_context20.next = 13;
|
|
1314
|
+
break;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
transactionInfo = {};
|
|
1318
|
+
_context20.next = 12;
|
|
1319
|
+
return Promise.all(blockInfo.map( /*#__PURE__*/function () {
|
|
1320
|
+
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(block) {
|
|
1321
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1322
|
+
while (1) {
|
|
1323
|
+
switch (_context19.prev = _context19.next) {
|
|
1324
|
+
case 0:
|
|
1325
|
+
if (transactionInfo[block.transactionHash]) {
|
|
1326
|
+
_context19.next = 12;
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
_context19.t0 = _objectSpread;
|
|
1331
|
+
_context19.t1 = _objectSpread;
|
|
1332
|
+
_context19.t2 = {};
|
|
1333
|
+
_context19.next = 6;
|
|
1334
|
+
return _this5.MakeProviderCall({
|
|
1335
|
+
methodName: "getTransaction",
|
|
1336
|
+
args: [block.transactionHash]
|
|
1337
|
+
});
|
|
1338
|
+
|
|
1339
|
+
case 6:
|
|
1340
|
+
_context19.t3 = _context19.sent;
|
|
1341
|
+
_context19.t4 = (0, _context19.t1)(_context19.t2, _context19.t3);
|
|
1342
|
+
_context19.next = 10;
|
|
1343
|
+
return _this5.MakeProviderCall({
|
|
1344
|
+
methodName: "getTransactionReceipt",
|
|
1345
|
+
args: [block.transactionHash]
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
case 10:
|
|
1349
|
+
_context19.t5 = _context19.sent;
|
|
1350
|
+
transactionInfo[block.transactionHash] = (0, _context19.t0)(_context19.t4, _context19.t5);
|
|
1351
|
+
|
|
1352
|
+
case 12:
|
|
1353
|
+
return _context19.abrupt("return", _objectSpread(_objectSpread({}, block), transactionInfo[block.transactionHash]));
|
|
1354
|
+
|
|
1355
|
+
case 13:
|
|
1356
|
+
case "end":
|
|
1357
|
+
return _context19.stop();
|
|
1358
|
+
}
|
|
1092
1359
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
output.push(blocks[blockNumber]);
|
|
1128
|
-
case 14:
|
|
1129
|
-
case "end":
|
|
1130
|
-
return _context20.stop();
|
|
1131
|
-
}
|
|
1132
|
-
}, _callee20);
|
|
1133
|
-
}));
|
|
1134
|
-
return function (_x19) {
|
|
1135
|
-
return _ref25.apply(this, arguments);
|
|
1136
|
-
};
|
|
1137
|
-
}());
|
|
1138
|
-
case 16:
|
|
1139
|
-
return _context21.abrupt("return", output);
|
|
1140
|
-
case 17:
|
|
1141
|
-
case "end":
|
|
1142
|
-
return _context21.stop();
|
|
1360
|
+
}, _callee19);
|
|
1361
|
+
}));
|
|
1362
|
+
|
|
1363
|
+
return function (_x20) {
|
|
1364
|
+
return _ref26.apply(this, arguments);
|
|
1365
|
+
};
|
|
1366
|
+
}()));
|
|
1367
|
+
|
|
1368
|
+
case 12:
|
|
1369
|
+
blocks[blockNumber] = _context20.sent;
|
|
1370
|
+
|
|
1371
|
+
case 13:
|
|
1372
|
+
output.push(blocks[blockNumber]);
|
|
1373
|
+
|
|
1374
|
+
case 14:
|
|
1375
|
+
case "end":
|
|
1376
|
+
return _context20.stop();
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}, _callee20);
|
|
1380
|
+
}));
|
|
1381
|
+
|
|
1382
|
+
return function (_x19) {
|
|
1383
|
+
return _ref25.apply(this, arguments);
|
|
1384
|
+
};
|
|
1385
|
+
}());
|
|
1386
|
+
|
|
1387
|
+
case 16:
|
|
1388
|
+
return _context21.abrupt("return", output);
|
|
1389
|
+
|
|
1390
|
+
case 17:
|
|
1391
|
+
case "end":
|
|
1392
|
+
return _context21.stop();
|
|
1393
|
+
}
|
|
1143
1394
|
}
|
|
1144
1395
|
}, _callee21, this);
|
|
1145
1396
|
}));
|
|
1397
|
+
|
|
1146
1398
|
function Events(_x18) {
|
|
1147
1399
|
return _Events.apply(this, arguments);
|
|
1148
1400
|
}
|
|
1401
|
+
|
|
1149
1402
|
return Events;
|
|
1150
1403
|
}()
|
|
1151
1404
|
}]);
|
|
1405
|
+
|
|
1152
1406
|
return EthClient;
|
|
1153
1407
|
}();
|
|
1408
|
+
|
|
1154
1409
|
module.exports = EthClient;
|