@waku/rln 0.1.5-053bb95.0 → 0.1.5-164df63.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 (158) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +2 -1
  4. package/bundle/packages/rln/dist/contract/constants.js +6 -2
  5. package/bundle/packages/rln/dist/contract/rln_base_contract.js +282 -146
  6. package/bundle/packages/rln/dist/contract/rln_contract.js +74 -89
  7. package/bundle/packages/rln/dist/credentials_manager.js +1 -1
  8. package/bundle/packages/rln/dist/identity.js +0 -8
  9. package/bundle/packages/rln/dist/keystore/keystore.js +28 -15
  10. package/bundle/packages/rln/dist/utils/bytes.js +8 -2
  11. package/bundle/packages/rln/dist/utils/metamask.js +2 -2
  12. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  13. package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  14. package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +1 -1
  15. package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +1 -1
  16. package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
  17. package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +1 -1
  18. package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
  19. package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +1 -1
  20. package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
  21. package/dist/.tsbuildinfo +1 -1
  22. package/dist/contract/constants.d.ts +1 -1
  23. package/dist/contract/constants.js +1 -1
  24. package/dist/contract/constants.js.map +1 -1
  25. package/dist/contract/index.d.ts +1 -0
  26. package/dist/contract/index.js +1 -0
  27. package/dist/contract/index.js.map +1 -1
  28. package/dist/contract/rln_base_contract.d.ts +27 -25
  29. package/dist/contract/rln_base_contract.js +280 -144
  30. package/dist/contract/rln_base_contract.js.map +1 -1
  31. package/dist/contract/rln_contract.d.ts +4 -24
  32. package/dist/contract/rln_contract.js +74 -89
  33. package/dist/contract/rln_contract.js.map +1 -1
  34. package/dist/contract/types.d.ts +5 -0
  35. package/dist/contract/types.js.map +1 -1
  36. package/dist/credentials_manager.js +1 -1
  37. package/dist/credentials_manager.js.map +1 -1
  38. package/dist/identity.d.ts +0 -1
  39. package/dist/identity.js +0 -8
  40. package/dist/identity.js.map +1 -1
  41. package/dist/index.d.ts +2 -1
  42. package/dist/index.js +1 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/keystore/keystore.d.ts +1 -0
  45. package/dist/keystore/keystore.js +28 -15
  46. package/dist/keystore/keystore.js.map +1 -1
  47. package/dist/keystore/types.d.ts +2 -2
  48. package/dist/utils/bytes.js +8 -2
  49. package/dist/utils/bytes.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/contract/constants.ts +1 -1
  52. package/src/contract/index.ts +1 -0
  53. package/src/contract/rln_base_contract.ts +428 -216
  54. package/src/contract/rln_contract.ts +95 -120
  55. package/src/contract/types.ts +5 -0
  56. package/src/credentials_manager.ts +1 -1
  57. package/src/identity.ts +0 -9
  58. package/src/index.ts +3 -1
  59. package/src/keystore/keystore.ts +54 -29
  60. package/src/keystore/types.ts +2 -2
  61. package/src/utils/bytes.ts +10 -2
  62. package/bundle/_virtual/__node-resolve_empty.js +0 -6
  63. package/bundle/_virtual/_node-resolve_empty.js +0 -3
  64. package/bundle/_virtual/bn.js +0 -3
  65. package/bundle/_virtual/common.js +0 -3
  66. package/bundle/_virtual/common2.js +0 -3
  67. package/bundle/_virtual/hash.js +0 -3
  68. package/bundle/_virtual/inherits_browser.js +0 -3
  69. package/bundle/_virtual/ripemd.js +0 -3
  70. package/bundle/_virtual/sha.js +0 -3
  71. package/bundle/_virtual/sha3.js +0 -3
  72. package/bundle/_virtual/utils3.js +0 -3
  73. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
  74. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
  75. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
  76. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
  77. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
  78. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
  79. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
  80. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
  81. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
  82. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
  83. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
  84. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
  85. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
  86. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
  87. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
  88. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
  89. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
  90. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
  91. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
  92. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
  93. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
  94. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
  95. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
  96. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
  97. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
  98. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
  99. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
  100. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
  101. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
  102. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
  103. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
  104. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
  105. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
  106. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
  107. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
  108. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
  109. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
  110. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
  111. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
  112. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
  113. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
  114. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
  115. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
  116. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
  117. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
  118. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
  119. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
  120. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
  121. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
  122. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
  123. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
  124. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
  125. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
  126. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
  127. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
  128. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
  129. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
  130. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
  131. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
  132. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
  133. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
  134. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
  135. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
  136. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
  137. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
  138. package/bundle/node_modules/bech32/index.js +0 -187
  139. package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
  140. package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
  141. package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
  142. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
  143. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
  144. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
  145. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
  146. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
  147. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
  148. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
  149. package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
  150. package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
  151. package/bundle/node_modules/hash.js/lib/hash.js +0 -33
  152. package/bundle/node_modules/inherits/inherits_browser.js +0 -33
  153. package/bundle/node_modules/minimalistic-assert/index.js +0 -13
  154. package/bundle/packages/rln/dist/contract/errors.js +0 -62
  155. package/dist/contract/errors.d.ts +0 -30
  156. package/dist/contract/errors.js +0 -61
  157. package/dist/contract/errors.js.map +0 -1
  158. package/src/contract/errors.ts +0 -75
@@ -1,302 +0,0 @@
1
- import { defineReadOnly, resolveProperties, shallowCopy } from '../../properties/lib.esm/index.js';
2
- import { Logger } from '../../logger/lib.esm/index.js';
3
- import { version } from './_version.js';
4
-
5
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- const logger = new Logger(version);
15
- const allowedTransactionKeys = [
16
- "accessList", "ccipReadEnabled", "chainId", "customData", "data", "from", "gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "to", "type", "value"
17
- ];
18
- const forwardErrors = [
19
- Logger.errors.INSUFFICIENT_FUNDS,
20
- Logger.errors.NONCE_EXPIRED,
21
- Logger.errors.REPLACEMENT_UNDERPRICED,
22
- ];
23
- class Signer {
24
- ///////////////////
25
- // Sub-classes MUST call super
26
- constructor() {
27
- logger.checkAbstract(new.target, Signer);
28
- defineReadOnly(this, "_isSigner", true);
29
- }
30
- ///////////////////
31
- // Sub-classes MAY override these
32
- getBalance(blockTag) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- this._checkProvider("getBalance");
35
- return yield this.provider.getBalance(this.getAddress(), blockTag);
36
- });
37
- }
38
- getTransactionCount(blockTag) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- this._checkProvider("getTransactionCount");
41
- return yield this.provider.getTransactionCount(this.getAddress(), blockTag);
42
- });
43
- }
44
- // Populates "from" if unspecified, and estimates the gas for the transaction
45
- estimateGas(transaction) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- this._checkProvider("estimateGas");
48
- const tx = yield resolveProperties(this.checkTransaction(transaction));
49
- return yield this.provider.estimateGas(tx);
50
- });
51
- }
52
- // Populates "from" if unspecified, and calls with the transaction
53
- call(transaction, blockTag) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- this._checkProvider("call");
56
- const tx = yield resolveProperties(this.checkTransaction(transaction));
57
- return yield this.provider.call(tx, blockTag);
58
- });
59
- }
60
- // Populates all fields in a transaction, signs it and sends it to the network
61
- sendTransaction(transaction) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- this._checkProvider("sendTransaction");
64
- const tx = yield this.populateTransaction(transaction);
65
- const signedTx = yield this.signTransaction(tx);
66
- return yield this.provider.sendTransaction(signedTx);
67
- });
68
- }
69
- getChainId() {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- this._checkProvider("getChainId");
72
- const network = yield this.provider.getNetwork();
73
- return network.chainId;
74
- });
75
- }
76
- getGasPrice() {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- this._checkProvider("getGasPrice");
79
- return yield this.provider.getGasPrice();
80
- });
81
- }
82
- getFeeData() {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- this._checkProvider("getFeeData");
85
- return yield this.provider.getFeeData();
86
- });
87
- }
88
- resolveName(name) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- this._checkProvider("resolveName");
91
- return yield this.provider.resolveName(name);
92
- });
93
- }
94
- // Checks a transaction does not contain invalid keys and if
95
- // no "from" is provided, populates it.
96
- // - does NOT require a provider
97
- // - adds "from" is not present
98
- // - returns a COPY (safe to mutate the result)
99
- // By default called from: (overriding these prevents it)
100
- // - call
101
- // - estimateGas
102
- // - populateTransaction (and therefor sendTransaction)
103
- checkTransaction(transaction) {
104
- for (const key in transaction) {
105
- if (allowedTransactionKeys.indexOf(key) === -1) {
106
- logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction);
107
- }
108
- }
109
- const tx = shallowCopy(transaction);
110
- if (tx.from == null) {
111
- tx.from = this.getAddress();
112
- }
113
- else {
114
- // Make sure any provided address matches this signer
115
- tx.from = Promise.all([
116
- Promise.resolve(tx.from),
117
- this.getAddress()
118
- ]).then((result) => {
119
- if (result[0].toLowerCase() !== result[1].toLowerCase()) {
120
- logger.throwArgumentError("from address mismatch", "transaction", transaction);
121
- }
122
- return result[0];
123
- });
124
- }
125
- return tx;
126
- }
127
- // Populates ALL keys for a transaction and checks that "from" matches
128
- // this Signer. Should be used by sendTransaction but NOT by signTransaction.
129
- // By default called from: (overriding these prevents it)
130
- // - sendTransaction
131
- //
132
- // Notes:
133
- // - We allow gasPrice for EIP-1559 as long as it matches maxFeePerGas
134
- populateTransaction(transaction) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- const tx = yield resolveProperties(this.checkTransaction(transaction));
137
- if (tx.to != null) {
138
- tx.to = Promise.resolve(tx.to).then((to) => __awaiter(this, void 0, void 0, function* () {
139
- if (to == null) {
140
- return null;
141
- }
142
- const address = yield this.resolveName(to);
143
- if (address == null) {
144
- logger.throwArgumentError("provided ENS name resolves to null", "tx.to", to);
145
- }
146
- return address;
147
- }));
148
- // Prevent this error from causing an UnhandledPromiseException
149
- tx.to.catch((error) => { });
150
- }
151
- // Do not allow mixing pre-eip-1559 and eip-1559 properties
152
- const hasEip1559 = (tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null);
153
- if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) {
154
- logger.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction);
155
- }
156
- else if ((tx.type === 0 || tx.type === 1) && hasEip1559) {
157
- logger.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction);
158
- }
159
- if ((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null)) {
160
- // Fully-formed EIP-1559 transaction (skip getFeeData)
161
- tx.type = 2;
162
- }
163
- else if (tx.type === 0 || tx.type === 1) {
164
- // Explicit Legacy or EIP-2930 transaction
165
- // Populate missing gasPrice
166
- if (tx.gasPrice == null) {
167
- tx.gasPrice = this.getGasPrice();
168
- }
169
- }
170
- else {
171
- // We need to get fee data to determine things
172
- const feeData = yield this.getFeeData();
173
- if (tx.type == null) {
174
- // We need to auto-detect the intended type of this transaction...
175
- if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
176
- // The network supports EIP-1559!
177
- // Upgrade transaction from null to eip-1559
178
- tx.type = 2;
179
- if (tx.gasPrice != null) {
180
- // Using legacy gasPrice property on an eip-1559 network,
181
- // so use gasPrice as both fee properties
182
- const gasPrice = tx.gasPrice;
183
- delete tx.gasPrice;
184
- tx.maxFeePerGas = gasPrice;
185
- tx.maxPriorityFeePerGas = gasPrice;
186
- }
187
- else {
188
- // Populate missing fee data
189
- if (tx.maxFeePerGas == null) {
190
- tx.maxFeePerGas = feeData.maxFeePerGas;
191
- }
192
- if (tx.maxPriorityFeePerGas == null) {
193
- tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
194
- }
195
- }
196
- }
197
- else if (feeData.gasPrice != null) {
198
- // Network doesn't support EIP-1559...
199
- // ...but they are trying to use EIP-1559 properties
200
- if (hasEip1559) {
201
- logger.throwError("network does not support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
202
- operation: "populateTransaction"
203
- });
204
- }
205
- // Populate missing fee data
206
- if (tx.gasPrice == null) {
207
- tx.gasPrice = feeData.gasPrice;
208
- }
209
- // Explicitly set untyped transaction to legacy
210
- tx.type = 0;
211
- }
212
- else {
213
- // getFeeData has failed us.
214
- logger.throwError("failed to get consistent fee data", Logger.errors.UNSUPPORTED_OPERATION, {
215
- operation: "signer.getFeeData"
216
- });
217
- }
218
- }
219
- else if (tx.type === 2) {
220
- // Explicitly using EIP-1559
221
- // Populate missing fee data
222
- if (tx.maxFeePerGas == null) {
223
- tx.maxFeePerGas = feeData.maxFeePerGas;
224
- }
225
- if (tx.maxPriorityFeePerGas == null) {
226
- tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
227
- }
228
- }
229
- }
230
- if (tx.nonce == null) {
231
- tx.nonce = this.getTransactionCount("pending");
232
- }
233
- if (tx.gasLimit == null) {
234
- tx.gasLimit = this.estimateGas(tx).catch((error) => {
235
- if (forwardErrors.indexOf(error.code) >= 0) {
236
- throw error;
237
- }
238
- return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
239
- error: error,
240
- tx: tx
241
- });
242
- });
243
- }
244
- if (tx.chainId == null) {
245
- tx.chainId = this.getChainId();
246
- }
247
- else {
248
- tx.chainId = Promise.all([
249
- Promise.resolve(tx.chainId),
250
- this.getChainId()
251
- ]).then((results) => {
252
- if (results[1] !== 0 && results[0] !== results[1]) {
253
- logger.throwArgumentError("chainId address mismatch", "transaction", transaction);
254
- }
255
- return results[0];
256
- });
257
- }
258
- return yield resolveProperties(tx);
259
- });
260
- }
261
- ///////////////////
262
- // Sub-classes SHOULD leave these alone
263
- _checkProvider(operation) {
264
- if (!this.provider) {
265
- logger.throwError("missing provider", Logger.errors.UNSUPPORTED_OPERATION, {
266
- operation: (operation || "_checkProvider")
267
- });
268
- }
269
- }
270
- static isSigner(value) {
271
- return !!(value && value._isSigner);
272
- }
273
- }
274
- class VoidSigner extends Signer {
275
- constructor(address, provider) {
276
- super();
277
- defineReadOnly(this, "address", address);
278
- defineReadOnly(this, "provider", provider || null);
279
- }
280
- getAddress() {
281
- return Promise.resolve(this.address);
282
- }
283
- _fail(message, operation) {
284
- return Promise.resolve().then(() => {
285
- logger.throwError(message, Logger.errors.UNSUPPORTED_OPERATION, { operation: operation });
286
- });
287
- }
288
- signMessage(message) {
289
- return this._fail("VoidSigner cannot sign messages", "signMessage");
290
- }
291
- signTransaction(transaction) {
292
- return this._fail("VoidSigner cannot sign transactions", "signTransaction");
293
- }
294
- _signTypedData(domain, types, value) {
295
- return this._fail("VoidSigner cannot sign typed data", "signTypedData");
296
- }
297
- connect(provider) {
298
- return new VoidSigner(this.address, provider);
299
- }
300
- }
301
-
302
- export { Signer, VoidSigner };
@@ -1,3 +0,0 @@
1
- const version = "address/5.7.0";
2
-
3
- export { version };
@@ -1,110 +0,0 @@
1
- import { stripZeros, arrayify, hexDataSlice, isHexString } from '../../bytes/lib.esm/index.js';
2
- import { keccak256 } from '../../keccak256/lib.esm/index.js';
3
- import { encode } from '../../rlp/lib.esm/index.js';
4
- import { Logger } from '../../logger/lib.esm/index.js';
5
- import { version } from './_version.js';
6
- import { _base36To16, BigNumber } from '../../bignumber/lib.esm/bignumber.js';
7
-
8
- const logger = new Logger(version);
9
- function getChecksumAddress(address) {
10
- if (!isHexString(address, 20)) {
11
- logger.throwArgumentError("invalid address", "address", address);
12
- }
13
- address = address.toLowerCase();
14
- const chars = address.substring(2).split("");
15
- const expanded = new Uint8Array(40);
16
- for (let i = 0; i < 40; i++) {
17
- expanded[i] = chars[i].charCodeAt(0);
18
- }
19
- const hashed = arrayify(keccak256(expanded));
20
- for (let i = 0; i < 40; i += 2) {
21
- if ((hashed[i >> 1] >> 4) >= 8) {
22
- chars[i] = chars[i].toUpperCase();
23
- }
24
- if ((hashed[i >> 1] & 0x0f) >= 8) {
25
- chars[i + 1] = chars[i + 1].toUpperCase();
26
- }
27
- }
28
- return "0x" + chars.join("");
29
- }
30
- // Shims for environments that are missing some required constants and functions
31
- const MAX_SAFE_INTEGER = 0x1fffffffffffff;
32
- function log10(x) {
33
- if (Math.log10) {
34
- return Math.log10(x);
35
- }
36
- return Math.log(x) / Math.LN10;
37
- }
38
- // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
39
- // Create lookup table
40
- const ibanLookup = {};
41
- for (let i = 0; i < 10; i++) {
42
- ibanLookup[String(i)] = String(i);
43
- }
44
- for (let i = 0; i < 26; i++) {
45
- ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
46
- }
47
- // How many decimal digits can we process? (for 64-bit float, this is 15)
48
- const safeDigits = Math.floor(log10(MAX_SAFE_INTEGER));
49
- function ibanChecksum(address) {
50
- address = address.toUpperCase();
51
- address = address.substring(4) + address.substring(0, 2) + "00";
52
- let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join("");
53
- // Javascript can handle integers safely up to 15 (decimal) digits
54
- while (expanded.length >= safeDigits) {
55
- let block = expanded.substring(0, safeDigits);
56
- expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
57
- }
58
- let checksum = String(98 - (parseInt(expanded, 10) % 97));
59
- while (checksum.length < 2) {
60
- checksum = "0" + checksum;
61
- }
62
- return checksum;
63
- }
64
- function getAddress(address) {
65
- let result = null;
66
- if (typeof (address) !== "string") {
67
- logger.throwArgumentError("invalid address", "address", address);
68
- }
69
- if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
70
- // Missing the 0x prefix
71
- if (address.substring(0, 2) !== "0x") {
72
- address = "0x" + address;
73
- }
74
- result = getChecksumAddress(address);
75
- // It is a checksummed address with a bad checksum
76
- if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
77
- logger.throwArgumentError("bad address checksum", "address", address);
78
- }
79
- // Maybe ICAP? (we only support direct mode)
80
- }
81
- else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
82
- // It is an ICAP address with a bad checksum
83
- if (address.substring(2, 4) !== ibanChecksum(address)) {
84
- logger.throwArgumentError("bad icap checksum", "address", address);
85
- }
86
- result = _base36To16(address.substring(4));
87
- while (result.length < 40) {
88
- result = "0" + result;
89
- }
90
- result = getChecksumAddress("0x" + result);
91
- }
92
- else {
93
- logger.throwArgumentError("invalid address", "address", address);
94
- }
95
- return result;
96
- }
97
- // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
98
- function getContractAddress(transaction) {
99
- let from = null;
100
- try {
101
- from = getAddress(transaction.from);
102
- }
103
- catch (error) {
104
- logger.throwArgumentError("missing from address", "transaction", transaction);
105
- }
106
- const nonce = stripZeros(arrayify(BigNumber.from(transaction.nonce).toHexString()));
107
- return getAddress(hexDataSlice(keccak256(encode([from, nonce])), 12));
108
- }
109
-
110
- export { getAddress, getContractAddress };
@@ -1,20 +0,0 @@
1
- import { arrayify } from '../../bytes/lib.esm/index.js';
2
-
3
- function decode(textData) {
4
- textData = atob(textData);
5
- const data = [];
6
- for (let i = 0; i < textData.length; i++) {
7
- data.push(textData.charCodeAt(i));
8
- }
9
- return arrayify(data);
10
- }
11
- function encode(data) {
12
- data = arrayify(data);
13
- let textData = "";
14
- for (let i = 0; i < data.length; i++) {
15
- textData += String.fromCharCode(data[i]);
16
- }
17
- return btoa(textData);
18
- }
19
-
20
- export { decode, encode };
@@ -1,120 +0,0 @@
1
- import { arrayify } from '../../bytes/lib.esm/index.js';
2
- import { defineReadOnly } from '../../properties/lib.esm/index.js';
3
-
4
- /**
5
- * var basex = require("base-x");
6
- *
7
- * This implementation is heavily based on base-x. The main reason to
8
- * deviate was to prevent the dependency of Buffer.
9
- *
10
- * Contributors:
11
- *
12
- * base-x encoding
13
- * Forked from https://github.com/cryptocoinjs/bs58
14
- * Originally written by Mike Hearn for BitcoinJ
15
- * Copyright (c) 2011 Google Inc
16
- * Ported to JavaScript by Stefan Thomas
17
- * Merged Buffer refactorings from base58-native by Stephen Pair
18
- * Copyright (c) 2013 BitPay Inc
19
- *
20
- * The MIT License (MIT)
21
- *
22
- * Copyright base-x contributors (c) 2016
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining a
25
- * copy of this software and associated documentation files (the "Software"),
26
- * to deal in the Software without restriction, including without limitation
27
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28
- * and/or sell copies of the Software, and to permit persons to whom the
29
- * Software is furnished to do so, subject to the following conditions:
30
- *
31
- * The above copyright notice and this permission notice shall be included in
32
- * all copies or substantial portions of the Software.
33
-
34
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
40
- * IN THE SOFTWARE.
41
- *
42
- */
43
- class BaseX {
44
- constructor(alphabet) {
45
- defineReadOnly(this, "alphabet", alphabet);
46
- defineReadOnly(this, "base", alphabet.length);
47
- defineReadOnly(this, "_alphabetMap", {});
48
- defineReadOnly(this, "_leader", alphabet.charAt(0));
49
- // pre-compute lookup table
50
- for (let i = 0; i < alphabet.length; i++) {
51
- this._alphabetMap[alphabet.charAt(i)] = i;
52
- }
53
- }
54
- encode(value) {
55
- let source = arrayify(value);
56
- if (source.length === 0) {
57
- return "";
58
- }
59
- let digits = [0];
60
- for (let i = 0; i < source.length; ++i) {
61
- let carry = source[i];
62
- for (let j = 0; j < digits.length; ++j) {
63
- carry += digits[j] << 8;
64
- digits[j] = carry % this.base;
65
- carry = (carry / this.base) | 0;
66
- }
67
- while (carry > 0) {
68
- digits.push(carry % this.base);
69
- carry = (carry / this.base) | 0;
70
- }
71
- }
72
- let string = "";
73
- // deal with leading zeros
74
- for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) {
75
- string += this._leader;
76
- }
77
- // convert digits to a string
78
- for (let q = digits.length - 1; q >= 0; --q) {
79
- string += this.alphabet[digits[q]];
80
- }
81
- return string;
82
- }
83
- decode(value) {
84
- if (typeof (value) !== "string") {
85
- throw new TypeError("Expected String");
86
- }
87
- let bytes = [];
88
- if (value.length === 0) {
89
- return new Uint8Array(bytes);
90
- }
91
- bytes.push(0);
92
- for (let i = 0; i < value.length; i++) {
93
- let byte = this._alphabetMap[value[i]];
94
- if (byte === undefined) {
95
- throw new Error("Non-base" + this.base + " character");
96
- }
97
- let carry = byte;
98
- for (let j = 0; j < bytes.length; ++j) {
99
- carry += bytes[j] * this.base;
100
- bytes[j] = carry & 0xff;
101
- carry >>= 8;
102
- }
103
- while (carry > 0) {
104
- bytes.push(carry & 0xff);
105
- carry >>= 8;
106
- }
107
- }
108
- // deal with leading zeros
109
- for (let k = 0; value[k] === this._leader && k < value.length - 1; ++k) {
110
- bytes.push(0);
111
- }
112
- return arrayify(new Uint8Array(bytes.reverse()));
113
- }
114
- }
115
- new BaseX("abcdefghijklmnopqrstuvwxyz234567");
116
- const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
117
- //console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))
118
- //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")))
119
-
120
- export { Base58, BaseX };
@@ -1,3 +0,0 @@
1
- const version = "bignumber/5.7.0";
2
-
3
- export { version };