@waku/rln 0.1.5-cad3e7a.0 → 0.1.5-d17562d.0

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.
Files changed (168) hide show
  1. package/bundle/index.js +4 -3
  2. package/bundle/packages/rln/dist/contract/constants.js +2 -1
  3. package/bundle/packages/rln/dist/contract/{rln_light_contract.js → rln_base_contract.js} +191 -186
  4. package/bundle/packages/rln/dist/contract/rln_contract.js +10 -420
  5. package/bundle/packages/rln/dist/contract/types.js +9 -0
  6. package/bundle/packages/rln/dist/create.js +1 -1
  7. package/bundle/packages/rln/dist/{rln_light.js → credentials_manager.js} +114 -48
  8. package/bundle/packages/rln/dist/identity.js +0 -9
  9. package/bundle/packages/rln/dist/keystore/keystore.js +31 -17
  10. package/bundle/packages/rln/dist/rln.js +57 -167
  11. package/bundle/packages/rln/dist/utils/bytes.js +8 -2
  12. package/bundle/packages/rln/dist/utils/metamask.js +2 -2
  13. package/bundle/packages/rln/dist/zerokit.js +5 -5
  14. package/dist/.tsbuildinfo +1 -1
  15. package/dist/contract/constants.d.ts +1 -1
  16. package/dist/contract/constants.js +1 -1
  17. package/dist/contract/constants.js.map +1 -1
  18. package/dist/contract/index.d.ts +1 -0
  19. package/dist/contract/index.js +1 -0
  20. package/dist/contract/index.js.map +1 -1
  21. package/dist/contract/{rln_light_contract.d.ts → rln_base_contract.d.ts} +24 -58
  22. package/dist/contract/{rln_light_contract.js → rln_base_contract.js} +189 -184
  23. package/dist/contract/rln_base_contract.js.map +1 -0
  24. package/dist/contract/rln_contract.d.ts +5 -122
  25. package/dist/contract/rln_contract.js +8 -417
  26. package/dist/contract/rln_contract.js.map +1 -1
  27. package/dist/contract/types.d.ts +45 -0
  28. package/dist/contract/types.js +8 -0
  29. package/dist/contract/types.js.map +1 -0
  30. package/dist/create.js +1 -1
  31. package/dist/create.js.map +1 -1
  32. package/dist/credentials_manager.d.ts +44 -0
  33. package/dist/credentials_manager.js +197 -0
  34. package/dist/credentials_manager.js.map +1 -0
  35. package/dist/identity.d.ts +0 -1
  36. package/dist/identity.js +0 -9
  37. package/dist/identity.js.map +1 -1
  38. package/dist/index.d.ts +5 -4
  39. package/dist/index.js +4 -3
  40. package/dist/index.js.map +1 -1
  41. package/dist/keystore/keystore.d.ts +1 -0
  42. package/dist/keystore/keystore.js +31 -17
  43. package/dist/keystore/keystore.js.map +1 -1
  44. package/dist/keystore/types.d.ts +3 -3
  45. package/dist/rln.d.ts +9 -52
  46. package/dist/rln.js +55 -164
  47. package/dist/rln.js.map +1 -1
  48. package/dist/types.d.ts +27 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/utils/bytes.js +8 -2
  52. package/dist/utils/bytes.js.map +1 -1
  53. package/dist/zerokit.d.ts +3 -3
  54. package/dist/zerokit.js +5 -5
  55. package/dist/zerokit.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/contract/constants.ts +1 -1
  58. package/src/contract/index.ts +1 -0
  59. package/src/contract/{rln_light_contract.ts → rln_base_contract.ts} +308 -323
  60. package/src/contract/rln_contract.ts +9 -663
  61. package/src/contract/types.ts +53 -0
  62. package/src/create.ts +1 -1
  63. package/src/credentials_manager.ts +282 -0
  64. package/src/identity.ts +0 -10
  65. package/src/index.ts +7 -5
  66. package/src/keystore/keystore.ts +57 -31
  67. package/src/keystore/types.ts +3 -3
  68. package/src/rln.ts +68 -259
  69. package/src/types.ts +31 -0
  70. package/src/utils/bytes.ts +10 -2
  71. package/src/zerokit.ts +3 -3
  72. package/bundle/_virtual/__node-resolve_empty.js +0 -6
  73. package/bundle/_virtual/_node-resolve_empty.js +0 -3
  74. package/bundle/_virtual/bn.js +0 -3
  75. package/bundle/_virtual/common.js +0 -3
  76. package/bundle/_virtual/common2.js +0 -3
  77. package/bundle/_virtual/hash.js +0 -3
  78. package/bundle/_virtual/inherits_browser.js +0 -3
  79. package/bundle/_virtual/ripemd.js +0 -3
  80. package/bundle/_virtual/sha.js +0 -3
  81. package/bundle/_virtual/sha3.js +0 -3
  82. package/bundle/_virtual/utils3.js +0 -3
  83. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
  84. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
  85. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
  86. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
  87. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
  88. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
  89. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
  90. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
  91. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
  92. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
  93. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
  94. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
  95. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
  96. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
  97. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
  98. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
  99. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
  100. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
  101. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
  102. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
  103. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
  104. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
  105. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
  106. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
  107. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
  108. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
  109. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
  110. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
  111. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
  112. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
  113. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
  114. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
  115. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
  116. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
  117. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
  118. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
  119. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
  120. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
  121. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
  122. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
  123. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
  124. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
  125. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
  126. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
  127. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
  128. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
  129. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
  130. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
  131. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
  132. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
  133. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
  134. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
  135. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
  136. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
  137. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
  138. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
  139. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
  140. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
  141. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
  142. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
  143. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
  144. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
  145. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
  146. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
  147. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
  148. package/bundle/node_modules/bech32/index.js +0 -187
  149. package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
  150. package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
  151. package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
  152. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
  153. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
  154. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
  155. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
  156. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
  157. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
  158. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
  159. package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
  160. package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
  161. package/bundle/node_modules/hash.js/lib/hash.js +0 -33
  162. package/bundle/node_modules/inherits/inherits_browser.js +0 -33
  163. package/bundle/node_modules/minimalistic-assert/index.js +0 -13
  164. package/dist/contract/rln_light_contract.js.map +0 -1
  165. package/dist/rln_light.d.ts +0 -64
  166. package/dist/rln_light.js +0 -144
  167. package/dist/rln_light.js.map +0 -1
  168. package/src/rln_light.ts +0 -235
@@ -1,352 +0,0 @@
1
- import { version } from './_version.js';
2
-
3
- let _permanentCensorErrors = false;
4
- let _censorErrors = false;
5
- const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
6
- let _logLevel = LogLevels["default"];
7
- let _globalLogger = null;
8
- function _checkNormalize() {
9
- try {
10
- const missing = [];
11
- // Make sure all forms of normalization are supported
12
- ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
13
- try {
14
- if ("test".normalize(form) !== "test") {
15
- throw new Error("bad normalize");
16
- }
17
- ;
18
- }
19
- catch (error) {
20
- missing.push(form);
21
- }
22
- });
23
- if (missing.length) {
24
- throw new Error("missing " + missing.join(", "));
25
- }
26
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
27
- throw new Error("broken implementation");
28
- }
29
- }
30
- catch (error) {
31
- return error.message;
32
- }
33
- return null;
34
- }
35
- const _normalizeError = _checkNormalize();
36
- var LogLevel;
37
- (function (LogLevel) {
38
- LogLevel["DEBUG"] = "DEBUG";
39
- LogLevel["INFO"] = "INFO";
40
- LogLevel["WARNING"] = "WARNING";
41
- LogLevel["ERROR"] = "ERROR";
42
- LogLevel["OFF"] = "OFF";
43
- })(LogLevel || (LogLevel = {}));
44
- var ErrorCode;
45
- (function (ErrorCode) {
46
- ///////////////////
47
- // Generic Errors
48
- // Unknown Error
49
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
50
- // Not Implemented
51
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
52
- // Unsupported Operation
53
- // - operation
54
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
55
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
56
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
57
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
58
- // Some sort of bad response from the server
59
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
60
- // Timeout
61
- ErrorCode["TIMEOUT"] = "TIMEOUT";
62
- ///////////////////
63
- // Operational Errors
64
- // Buffer Overrun
65
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
66
- // Numeric Fault
67
- // - operation: the operation being executed
68
- // - fault: the reason this faulted
69
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
70
- ///////////////////
71
- // Argument Errors
72
- // Missing new operator to an object
73
- // - name: The name of the class
74
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
75
- // Invalid argument (e.g. value is incompatible with type) to a function:
76
- // - argument: The argument name that was invalid
77
- // - value: The value of the argument
78
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
79
- // Missing argument to a function:
80
- // - count: The number of arguments received
81
- // - expectedCount: The number of arguments expected
82
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
83
- // Too many arguments
84
- // - count: The number of arguments received
85
- // - expectedCount: The number of arguments expected
86
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
87
- ///////////////////
88
- // Blockchain Errors
89
- // Call exception
90
- // - transaction: the transaction
91
- // - address?: the contract address
92
- // - args?: The arguments passed into the function
93
- // - method?: The Solidity method signature
94
- // - errorSignature?: The EIP848 error signature
95
- // - errorArgs?: The EIP848 error parameters
96
- // - reason: The reason (only for EIP848 "Error(string)")
97
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
98
- // Insufficient funds (< value + gasLimit * gasPrice)
99
- // - transaction: the transaction attempted
100
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
101
- // Nonce has already been used
102
- // - transaction: the transaction attempted
103
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
104
- // The replacement fee for the transaction is too low
105
- // - transaction: the transaction attempted
106
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
107
- // The gas limit could not be estimated
108
- // - transaction: the transaction passed to estimateGas
109
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
110
- // The transaction was replaced by one with a higher gas price
111
- // - reason: "cancelled", "replaced" or "repriced"
112
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
113
- // - hash: original transaction hash
114
- // - replacement: the full TransactionsResponse for the replacement
115
- // - receipt: the receipt of the replacement
116
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
117
- ///////////////////
118
- // Interaction Errors
119
- // The user rejected the action, such as signing a message or sending
120
- // a transaction
121
- ErrorCode["ACTION_REJECTED"] = "ACTION_REJECTED";
122
- })(ErrorCode || (ErrorCode = {}));
123
- const HEX = "0123456789abcdef";
124
- class Logger {
125
- constructor(version) {
126
- Object.defineProperty(this, "version", {
127
- enumerable: true,
128
- value: version,
129
- writable: false
130
- });
131
- }
132
- _log(logLevel, args) {
133
- const level = logLevel.toLowerCase();
134
- if (LogLevels[level] == null) {
135
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
136
- }
137
- if (_logLevel > LogLevels[level]) {
138
- return;
139
- }
140
- console.log.apply(console, args);
141
- }
142
- debug(...args) {
143
- this._log(Logger.levels.DEBUG, args);
144
- }
145
- info(...args) {
146
- this._log(Logger.levels.INFO, args);
147
- }
148
- warn(...args) {
149
- this._log(Logger.levels.WARNING, args);
150
- }
151
- makeError(message, code, params) {
152
- // Errors are being censored
153
- if (_censorErrors) {
154
- return this.makeError("censored error", code, {});
155
- }
156
- if (!code) {
157
- code = Logger.errors.UNKNOWN_ERROR;
158
- }
159
- if (!params) {
160
- params = {};
161
- }
162
- const messageDetails = [];
163
- Object.keys(params).forEach((key) => {
164
- const value = params[key];
165
- try {
166
- if (value instanceof Uint8Array) {
167
- let hex = "";
168
- for (let i = 0; i < value.length; i++) {
169
- hex += HEX[value[i] >> 4];
170
- hex += HEX[value[i] & 0x0f];
171
- }
172
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
173
- }
174
- else {
175
- messageDetails.push(key + "=" + JSON.stringify(value));
176
- }
177
- }
178
- catch (error) {
179
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
180
- }
181
- });
182
- messageDetails.push(`code=${code}`);
183
- messageDetails.push(`version=${this.version}`);
184
- const reason = message;
185
- let url = "";
186
- switch (code) {
187
- case ErrorCode.NUMERIC_FAULT: {
188
- url = "NUMERIC_FAULT";
189
- const fault = message;
190
- switch (fault) {
191
- case "overflow":
192
- case "underflow":
193
- case "division-by-zero":
194
- url += "-" + fault;
195
- break;
196
- case "negative-power":
197
- case "negative-width":
198
- url += "-unsupported";
199
- break;
200
- case "unbound-bitwise-result":
201
- url += "-unbound-result";
202
- break;
203
- }
204
- break;
205
- }
206
- case ErrorCode.CALL_EXCEPTION:
207
- case ErrorCode.INSUFFICIENT_FUNDS:
208
- case ErrorCode.MISSING_NEW:
209
- case ErrorCode.NONCE_EXPIRED:
210
- case ErrorCode.REPLACEMENT_UNDERPRICED:
211
- case ErrorCode.TRANSACTION_REPLACED:
212
- case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
213
- url = code;
214
- break;
215
- }
216
- if (url) {
217
- message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
218
- }
219
- if (messageDetails.length) {
220
- message += " (" + messageDetails.join(", ") + ")";
221
- }
222
- // @TODO: Any??
223
- const error = new Error(message);
224
- error.reason = reason;
225
- error.code = code;
226
- Object.keys(params).forEach(function (key) {
227
- error[key] = params[key];
228
- });
229
- return error;
230
- }
231
- throwError(message, code, params) {
232
- throw this.makeError(message, code, params);
233
- }
234
- throwArgumentError(message, name, value) {
235
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
236
- argument: name,
237
- value: value
238
- });
239
- }
240
- assert(condition, message, code, params) {
241
- if (!!condition) {
242
- return;
243
- }
244
- this.throwError(message, code, params);
245
- }
246
- assertArgument(condition, message, name, value) {
247
- if (!!condition) {
248
- return;
249
- }
250
- this.throwArgumentError(message, name, value);
251
- }
252
- checkNormalize(message) {
253
- if (_normalizeError) {
254
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
255
- operation: "String.prototype.normalize", form: _normalizeError
256
- });
257
- }
258
- }
259
- checkSafeUint53(value, message) {
260
- if (typeof (value) !== "number") {
261
- return;
262
- }
263
- if (message == null) {
264
- message = "value not safe";
265
- }
266
- if (value < 0 || value >= 0x1fffffffffffff) {
267
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
268
- operation: "checkSafeInteger",
269
- fault: "out-of-safe-range",
270
- value: value
271
- });
272
- }
273
- if (value % 1) {
274
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
275
- operation: "checkSafeInteger",
276
- fault: "non-integer",
277
- value: value
278
- });
279
- }
280
- }
281
- checkArgumentCount(count, expectedCount, message) {
282
- if (message) {
283
- message = ": " + message;
284
- }
285
- else {
286
- message = "";
287
- }
288
- if (count < expectedCount) {
289
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
290
- count: count,
291
- expectedCount: expectedCount
292
- });
293
- }
294
- if (count > expectedCount) {
295
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
296
- count: count,
297
- expectedCount: expectedCount
298
- });
299
- }
300
- }
301
- checkNew(target, kind) {
302
- if (target === Object || target == null) {
303
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
304
- }
305
- }
306
- checkAbstract(target, kind) {
307
- if (target === kind) {
308
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
309
- }
310
- else if (target === Object || target == null) {
311
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
312
- }
313
- }
314
- static globalLogger() {
315
- if (!_globalLogger) {
316
- _globalLogger = new Logger(version);
317
- }
318
- return _globalLogger;
319
- }
320
- static setCensorship(censorship, permanent) {
321
- if (!censorship && permanent) {
322
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
323
- operation: "setCensorship"
324
- });
325
- }
326
- if (_permanentCensorErrors) {
327
- if (!censorship) {
328
- return;
329
- }
330
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
331
- operation: "setCensorship"
332
- });
333
- }
334
- _censorErrors = !!censorship;
335
- _permanentCensorErrors = !!permanent;
336
- }
337
- static setLogLevel(logLevel) {
338
- const level = LogLevels[logLevel.toLowerCase()];
339
- if (level == null) {
340
- Logger.globalLogger().warn("invalid log level - " + logLevel);
341
- return;
342
- }
343
- _logLevel = level;
344
- }
345
- static from(version) {
346
- return new Logger(version);
347
- }
348
- }
349
- Logger.errors = ErrorCode;
350
- Logger.levels = LogLevel;
351
-
352
- export { ErrorCode, LogLevel, Logger };
@@ -1,3 +0,0 @@
1
- const version = "networks/5.7.1";
2
-
3
- export { version };
@@ -1,248 +0,0 @@
1
- import { Logger } from '../../logger/lib.esm/index.js';
2
- import { version } from './_version.js';
3
-
4
- const logger = new Logger(version);
5
- function isRenetworkable(value) {
6
- return (value && typeof (value.renetwork) === "function");
7
- }
8
- function ethDefaultProvider(network) {
9
- const func = function (providers, options) {
10
- if (options == null) {
11
- options = {};
12
- }
13
- const providerList = [];
14
- if (providers.InfuraProvider && options.infura !== "-") {
15
- try {
16
- providerList.push(new providers.InfuraProvider(network, options.infura));
17
- }
18
- catch (error) { }
19
- }
20
- if (providers.EtherscanProvider && options.etherscan !== "-") {
21
- try {
22
- providerList.push(new providers.EtherscanProvider(network, options.etherscan));
23
- }
24
- catch (error) { }
25
- }
26
- if (providers.AlchemyProvider && options.alchemy !== "-") {
27
- try {
28
- providerList.push(new providers.AlchemyProvider(network, options.alchemy));
29
- }
30
- catch (error) { }
31
- }
32
- if (providers.PocketProvider && options.pocket !== "-") {
33
- // These networks are currently faulty on Pocket as their
34
- // network does not handle the Berlin hardfork, which is
35
- // live on these ones.
36
- // @TODO: This goes away once Pocket has upgraded their nodes
37
- const skip = ["goerli", "ropsten", "rinkeby", "sepolia"];
38
- try {
39
- const provider = new providers.PocketProvider(network, options.pocket);
40
- if (provider.network && skip.indexOf(provider.network.name) === -1) {
41
- providerList.push(provider);
42
- }
43
- }
44
- catch (error) { }
45
- }
46
- if (providers.CloudflareProvider && options.cloudflare !== "-") {
47
- try {
48
- providerList.push(new providers.CloudflareProvider(network));
49
- }
50
- catch (error) { }
51
- }
52
- if (providers.AnkrProvider && options.ankr !== "-") {
53
- try {
54
- const skip = ["ropsten"];
55
- const provider = new providers.AnkrProvider(network, options.ankr);
56
- if (provider.network && skip.indexOf(provider.network.name) === -1) {
57
- providerList.push(provider);
58
- }
59
- }
60
- catch (error) { }
61
- }
62
- if (providerList.length === 0) {
63
- return null;
64
- }
65
- if (providers.FallbackProvider) {
66
- let quorum = 1;
67
- if (options.quorum != null) {
68
- quorum = options.quorum;
69
- }
70
- else if (network === "homestead") {
71
- quorum = 2;
72
- }
73
- return new providers.FallbackProvider(providerList, quorum);
74
- }
75
- return providerList[0];
76
- };
77
- func.renetwork = function (network) {
78
- return ethDefaultProvider(network);
79
- };
80
- return func;
81
- }
82
- function etcDefaultProvider(url, network) {
83
- const func = function (providers, options) {
84
- if (providers.JsonRpcProvider) {
85
- return new providers.JsonRpcProvider(url, network);
86
- }
87
- return null;
88
- };
89
- func.renetwork = function (network) {
90
- return etcDefaultProvider(url, network);
91
- };
92
- return func;
93
- }
94
- const homestead = {
95
- chainId: 1,
96
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
97
- name: "homestead",
98
- _defaultProvider: ethDefaultProvider("homestead")
99
- };
100
- const ropsten = {
101
- chainId: 3,
102
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
103
- name: "ropsten",
104
- _defaultProvider: ethDefaultProvider("ropsten")
105
- };
106
- const classicMordor = {
107
- chainId: 63,
108
- name: "classicMordor",
109
- _defaultProvider: etcDefaultProvider("https://www.ethercluster.com/mordor", "classicMordor")
110
- };
111
- // See: https://chainlist.org
112
- const networks = {
113
- unspecified: { chainId: 0, name: "unspecified" },
114
- homestead: homestead,
115
- mainnet: homestead,
116
- morden: { chainId: 2, name: "morden" },
117
- ropsten: ropsten,
118
- testnet: ropsten,
119
- rinkeby: {
120
- chainId: 4,
121
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
122
- name: "rinkeby",
123
- _defaultProvider: ethDefaultProvider("rinkeby")
124
- },
125
- kovan: {
126
- chainId: 42,
127
- name: "kovan",
128
- _defaultProvider: ethDefaultProvider("kovan")
129
- },
130
- goerli: {
131
- chainId: 5,
132
- ensAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
133
- name: "goerli",
134
- _defaultProvider: ethDefaultProvider("goerli")
135
- },
136
- kintsugi: { chainId: 1337702, name: "kintsugi" },
137
- sepolia: {
138
- chainId: 11155111,
139
- name: "sepolia",
140
- _defaultProvider: ethDefaultProvider("sepolia")
141
- },
142
- // ETC (See: #351)
143
- classic: {
144
- chainId: 61,
145
- name: "classic",
146
- _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/etc", "classic")
147
- },
148
- classicMorden: { chainId: 62, name: "classicMorden" },
149
- classicMordor: classicMordor,
150
- classicTestnet: classicMordor,
151
- classicKotti: {
152
- chainId: 6,
153
- name: "classicKotti",
154
- _defaultProvider: etcDefaultProvider("https:/\/www.ethercluster.com/kotti", "classicKotti")
155
- },
156
- xdai: { chainId: 100, name: "xdai" },
157
- matic: {
158
- chainId: 137,
159
- name: "matic",
160
- _defaultProvider: ethDefaultProvider("matic")
161
- },
162
- maticmum: { chainId: 80001, name: "maticmum" },
163
- optimism: {
164
- chainId: 10,
165
- name: "optimism",
166
- _defaultProvider: ethDefaultProvider("optimism")
167
- },
168
- "optimism-kovan": { chainId: 69, name: "optimism-kovan" },
169
- "optimism-goerli": { chainId: 420, name: "optimism-goerli" },
170
- arbitrum: { chainId: 42161, name: "arbitrum" },
171
- "arbitrum-rinkeby": { chainId: 421611, name: "arbitrum-rinkeby" },
172
- "arbitrum-goerli": { chainId: 421613, name: "arbitrum-goerli" },
173
- bnb: { chainId: 56, name: "bnb" },
174
- bnbt: { chainId: 97, name: "bnbt" },
175
- };
176
- /**
177
- * getNetwork
178
- *
179
- * Converts a named common networks or chain ID (network ID) to a Network
180
- * and verifies a network is a valid Network..
181
- */
182
- function getNetwork(network) {
183
- // No network (null)
184
- if (network == null) {
185
- return null;
186
- }
187
- if (typeof (network) === "number") {
188
- for (const name in networks) {
189
- const standard = networks[name];
190
- if (standard.chainId === network) {
191
- return {
192
- name: standard.name,
193
- chainId: standard.chainId,
194
- ensAddress: (standard.ensAddress || null),
195
- _defaultProvider: (standard._defaultProvider || null)
196
- };
197
- }
198
- }
199
- return {
200
- chainId: network,
201
- name: "unknown"
202
- };
203
- }
204
- if (typeof (network) === "string") {
205
- const standard = networks[network];
206
- if (standard == null) {
207
- return null;
208
- }
209
- return {
210
- name: standard.name,
211
- chainId: standard.chainId,
212
- ensAddress: standard.ensAddress,
213
- _defaultProvider: (standard._defaultProvider || null)
214
- };
215
- }
216
- const standard = networks[network.name];
217
- // Not a standard network; check that it is a valid network in general
218
- if (!standard) {
219
- if (typeof (network.chainId) !== "number") {
220
- logger.throwArgumentError("invalid network chainId", "network", network);
221
- }
222
- return network;
223
- }
224
- // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
225
- if (network.chainId !== 0 && network.chainId !== standard.chainId) {
226
- logger.throwArgumentError("network chainId mismatch", "network", network);
227
- }
228
- // @TODO: In the next major version add an attach function to a defaultProvider
229
- // class and move the _defaultProvider internal to this file (extend Network)
230
- let defaultProvider = network._defaultProvider || null;
231
- if (defaultProvider == null && standard._defaultProvider) {
232
- if (isRenetworkable(standard._defaultProvider)) {
233
- defaultProvider = standard._defaultProvider.renetwork(network);
234
- }
235
- else {
236
- defaultProvider = standard._defaultProvider;
237
- }
238
- }
239
- // Standard Network (allow overriding the ENS address)
240
- return {
241
- name: network.name,
242
- chainId: standard.chainId,
243
- ensAddress: (network.ensAddress || standard.ensAddress || null),
244
- _defaultProvider: defaultProvider
245
- };
246
- }
247
-
248
- export { getNetwork };
@@ -1,3 +0,0 @@
1
- const version = "properties/5.7.0";
2
-
3
- export { version };