@waku/rln 0.1.5-9901863.0 → 0.1.5-a824fff.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 (142) hide show
  1. package/bundle/index.js +2 -1
  2. package/bundle/packages/rln/dist/contract/constants.js +2 -1
  3. package/bundle/packages/rln/dist/contract/rln_base_contract.js +70 -65
  4. package/bundle/packages/rln/dist/contract/rln_contract.js +1 -1
  5. package/bundle/packages/rln/dist/credentials_manager.js +10 -28
  6. package/bundle/packages/rln/dist/identity.js +0 -8
  7. package/bundle/packages/rln/dist/keystore/keystore.js +28 -15
  8. package/bundle/packages/rln/dist/utils/metamask.js +2 -2
  9. package/bundle/packages/rln/dist/zerokit.js +5 -5
  10. package/dist/.tsbuildinfo +1 -1
  11. package/dist/contract/constants.d.ts +1 -1
  12. package/dist/contract/constants.js +1 -1
  13. package/dist/contract/constants.js.map +1 -1
  14. package/dist/contract/index.d.ts +1 -0
  15. package/dist/contract/index.js +1 -0
  16. package/dist/contract/index.js.map +1 -1
  17. package/dist/contract/rln_base_contract.d.ts +5 -11
  18. package/dist/contract/rln_base_contract.js +68 -63
  19. package/dist/contract/rln_base_contract.js.map +1 -1
  20. package/dist/contract/types.d.ts +5 -0
  21. package/dist/contract/types.js.map +1 -1
  22. package/dist/credentials_manager.d.ts +3 -9
  23. package/dist/credentials_manager.js +10 -28
  24. package/dist/credentials_manager.js.map +1 -1
  25. package/dist/identity.d.ts +0 -1
  26. package/dist/identity.js +0 -8
  27. package/dist/identity.js.map +1 -1
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/keystore/keystore.d.ts +1 -0
  32. package/dist/keystore/keystore.js +28 -15
  33. package/dist/keystore/keystore.js.map +1 -1
  34. package/dist/keystore/types.d.ts +2 -2
  35. package/dist/rln.js.map +1 -1
  36. package/dist/zerokit.d.ts +3 -3
  37. package/dist/zerokit.js +5 -5
  38. package/dist/zerokit.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/contract/constants.ts +1 -1
  41. package/src/contract/index.ts +1 -0
  42. package/src/contract/rln_base_contract.ts +100 -93
  43. package/src/contract/types.ts +5 -0
  44. package/src/credentials_manager.ts +10 -34
  45. package/src/identity.ts +0 -9
  46. package/src/index.ts +3 -1
  47. package/src/keystore/keystore.ts +54 -29
  48. package/src/keystore/types.ts +2 -2
  49. package/src/rln.ts +1 -0
  50. package/src/zerokit.ts +3 -3
  51. package/bundle/_virtual/__node-resolve_empty.js +0 -6
  52. package/bundle/_virtual/_node-resolve_empty.js +0 -3
  53. package/bundle/_virtual/bn.js +0 -3
  54. package/bundle/_virtual/common.js +0 -3
  55. package/bundle/_virtual/common2.js +0 -3
  56. package/bundle/_virtual/hash.js +0 -3
  57. package/bundle/_virtual/inherits_browser.js +0 -3
  58. package/bundle/_virtual/ripemd.js +0 -3
  59. package/bundle/_virtual/sha.js +0 -3
  60. package/bundle/_virtual/sha3.js +0 -3
  61. package/bundle/_virtual/utils3.js +0 -3
  62. package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +0 -3
  63. package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +0 -96
  64. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +0 -148
  65. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +0 -26
  66. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +0 -20
  67. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +0 -210
  68. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +0 -18
  69. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +0 -30
  70. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +0 -26
  71. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +0 -22
  72. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +0 -43
  73. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +0 -19
  74. package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +0 -58
  75. package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +0 -854
  76. package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +0 -609
  77. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +0 -3
  78. package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +0 -66
  79. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +0 -3
  80. package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +0 -302
  81. package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +0 -3
  82. package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +0 -110
  83. package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +0 -20
  84. package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +0 -120
  85. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +0 -3
  86. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +0 -287
  87. package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +0 -3
  88. package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +0 -402
  89. package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +0 -3
  90. package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +0 -8
  91. package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +0 -3
  92. package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +0 -3
  93. package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +0 -893
  94. package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +0 -3
  95. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +0 -256
  96. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +0 -36
  97. package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +0 -135
  98. package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +0 -8
  99. package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +0 -64
  100. package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +0 -443
  101. package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +0 -8
  102. package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +0 -660
  103. package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +0 -3
  104. package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +0 -352
  105. package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +0 -3
  106. package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +0 -248
  107. package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +0 -3
  108. package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +0 -127
  109. package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +0 -3
  110. package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +0 -2007
  111. package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +0 -422
  112. package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +0 -674
  113. package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +0 -132
  114. package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +0 -3
  115. package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +0 -120
  116. package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +0 -8
  117. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +0 -3
  118. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +0 -2430
  119. package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +0 -76
  120. package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +0 -3
  121. package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +0 -219
  122. package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +0 -3
  123. package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +0 -279
  124. package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +0 -3
  125. package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +0 -69
  126. package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +0 -404
  127. package/bundle/node_modules/bech32/index.js +0 -187
  128. package/bundle/node_modules/bn.js/lib/bn.js +0 -3361
  129. package/bundle/node_modules/hash.js/lib/hash/common.js +0 -97
  130. package/bundle/node_modules/hash.js/lib/hash/hmac.js +0 -51
  131. package/bundle/node_modules/hash.js/lib/hash/ripemd.js +0 -152
  132. package/bundle/node_modules/hash.js/lib/hash/sha/1.js +0 -81
  133. package/bundle/node_modules/hash.js/lib/hash/sha/224.js +0 -33
  134. package/bundle/node_modules/hash.js/lib/hash/sha/256.js +0 -113
  135. package/bundle/node_modules/hash.js/lib/hash/sha/384.js +0 -39
  136. package/bundle/node_modules/hash.js/lib/hash/sha/512.js +0 -336
  137. package/bundle/node_modules/hash.js/lib/hash/sha/common.js +0 -53
  138. package/bundle/node_modules/hash.js/lib/hash/sha.js +0 -14
  139. package/bundle/node_modules/hash.js/lib/hash/utils.js +0 -282
  140. package/bundle/node_modules/hash.js/lib/hash.js +0 -33
  141. package/bundle/node_modules/inherits/inherits_browser.js +0 -33
  142. package/bundle/node_modules/minimalistic-assert/index.js +0 -13
@@ -1,76 +0,0 @@
1
- import { EC as EC$1 } from './elliptic.js';
2
- import { splitSignature, arrayify, hexlify, hexDataLength, hexZeroPad } from '../../bytes/lib.esm/index.js';
3
- import { defineReadOnly } from '../../properties/lib.esm/index.js';
4
- import { Logger } from '../../logger/lib.esm/index.js';
5
- import { version } from './_version.js';
6
-
7
- const logger = new Logger(version);
8
- let _curve = null;
9
- function getCurve() {
10
- if (!_curve) {
11
- _curve = new EC$1("secp256k1");
12
- }
13
- return _curve;
14
- }
15
- class SigningKey {
16
- constructor(privateKey) {
17
- defineReadOnly(this, "curve", "secp256k1");
18
- defineReadOnly(this, "privateKey", hexlify(privateKey));
19
- if (hexDataLength(this.privateKey) !== 32) {
20
- logger.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]");
21
- }
22
- const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
23
- defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex"));
24
- defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex"));
25
- defineReadOnly(this, "_isSigningKey", true);
26
- }
27
- _addPoint(other) {
28
- const p0 = getCurve().keyFromPublic(arrayify(this.publicKey));
29
- const p1 = getCurve().keyFromPublic(arrayify(other));
30
- return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex");
31
- }
32
- signDigest(digest) {
33
- const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
34
- const digestBytes = arrayify(digest);
35
- if (digestBytes.length !== 32) {
36
- logger.throwArgumentError("bad digest length", "digest", digest);
37
- }
38
- const signature = keyPair.sign(digestBytes, { canonical: true });
39
- return splitSignature({
40
- recoveryParam: signature.recoveryParam,
41
- r: hexZeroPad("0x" + signature.r.toString(16), 32),
42
- s: hexZeroPad("0x" + signature.s.toString(16), 32),
43
- });
44
- }
45
- computeSharedSecret(otherKey) {
46
- const keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey));
47
- const otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey)));
48
- return hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32);
49
- }
50
- static isSigningKey(value) {
51
- return !!(value && value._isSigningKey);
52
- }
53
- }
54
- function recoverPublicKey(digest, signature) {
55
- const sig = splitSignature(signature);
56
- const rs = { r: arrayify(sig.r), s: arrayify(sig.s) };
57
- return "0x" + getCurve().recoverPubKey(arrayify(digest), rs, sig.recoveryParam).encode("hex", false);
58
- }
59
- function computePublicKey(key, compressed) {
60
- const bytes = arrayify(key);
61
- if (bytes.length === 32) {
62
- const signingKey = new SigningKey(bytes);
63
- return signingKey.publicKey;
64
- }
65
- else if (bytes.length === 33) {
66
- return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex");
67
- }
68
- else if (bytes.length === 65) {
69
- {
70
- return hexlify(bytes);
71
- }
72
- }
73
- return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]");
74
- }
75
-
76
- export { SigningKey, computePublicKey, recoverPublicKey };
@@ -1,3 +0,0 @@
1
- const version = "strings/5.7.0";
2
-
3
- export { version };
@@ -1,219 +0,0 @@
1
- import { arrayify } from '../../bytes/lib.esm/index.js';
2
- import { Logger } from '../../logger/lib.esm/index.js';
3
- import { version } from './_version.js';
4
-
5
- const logger = new Logger(version);
6
- ///////////////////////////////
7
- var UnicodeNormalizationForm;
8
- (function (UnicodeNormalizationForm) {
9
- UnicodeNormalizationForm["current"] = "";
10
- UnicodeNormalizationForm["NFC"] = "NFC";
11
- UnicodeNormalizationForm["NFD"] = "NFD";
12
- UnicodeNormalizationForm["NFKC"] = "NFKC";
13
- UnicodeNormalizationForm["NFKD"] = "NFKD";
14
- })(UnicodeNormalizationForm || (UnicodeNormalizationForm = {}));
15
- var Utf8ErrorReason;
16
- (function (Utf8ErrorReason) {
17
- // A continuation byte was present where there was nothing to continue
18
- // - offset = the index the codepoint began in
19
- Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte";
20
- // An invalid (non-continuation) byte to start a UTF-8 codepoint was found
21
- // - offset = the index the codepoint began in
22
- Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix";
23
- // The string is too short to process the expected codepoint
24
- // - offset = the index the codepoint began in
25
- Utf8ErrorReason["OVERRUN"] = "string overrun";
26
- // A missing continuation byte was expected but not found
27
- // - offset = the index the continuation byte was expected at
28
- Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte";
29
- // The computed code point is outside the range for UTF-8
30
- // - offset = start of this codepoint
31
- // - badCodepoint = the computed codepoint; outside the UTF-8 range
32
- Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range";
33
- // UTF-8 strings may not contain UTF-16 surrogate pairs
34
- // - offset = start of this codepoint
35
- // - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range
36
- Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate";
37
- // The string is an overlong representation
38
- // - offset = start of this codepoint
39
- // - badCodepoint = the computed codepoint; already bounds checked
40
- Utf8ErrorReason["OVERLONG"] = "overlong representation";
41
- })(Utf8ErrorReason || (Utf8ErrorReason = {}));
42
- function errorFunc(reason, offset, bytes, output, badCodepoint) {
43
- return logger.throwArgumentError(`invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes);
44
- }
45
- function ignoreFunc(reason, offset, bytes, output, badCodepoint) {
46
- // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes
47
- if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) {
48
- let i = 0;
49
- for (let o = offset + 1; o < bytes.length; o++) {
50
- if (bytes[o] >> 6 !== 0x02) {
51
- break;
52
- }
53
- i++;
54
- }
55
- return i;
56
- }
57
- // This byte runs us past the end of the string, so just jump to the end
58
- // (but the first byte was read already read and therefore skipped)
59
- if (reason === Utf8ErrorReason.OVERRUN) {
60
- return bytes.length - offset - 1;
61
- }
62
- // Nothing to skip
63
- return 0;
64
- }
65
- function replaceFunc(reason, offset, bytes, output, badCodepoint) {
66
- // Overlong representations are otherwise "valid" code points; just non-deistingtished
67
- if (reason === Utf8ErrorReason.OVERLONG) {
68
- output.push(badCodepoint);
69
- return 0;
70
- }
71
- // Put the replacement character into the output
72
- output.push(0xfffd);
73
- // Otherwise, process as if ignoring errors
74
- return ignoreFunc(reason, offset, bytes);
75
- }
76
- // Common error handing strategies
77
- const Utf8ErrorFuncs = Object.freeze({
78
- error: errorFunc,
79
- ignore: ignoreFunc,
80
- replace: replaceFunc
81
- });
82
- // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499
83
- function getUtf8CodePoints(bytes, onError) {
84
- if (onError == null) {
85
- onError = Utf8ErrorFuncs.error;
86
- }
87
- bytes = arrayify(bytes);
88
- const result = [];
89
- let i = 0;
90
- // Invalid bytes are ignored
91
- while (i < bytes.length) {
92
- const c = bytes[i++];
93
- // 0xxx xxxx
94
- if (c >> 7 === 0) {
95
- result.push(c);
96
- continue;
97
- }
98
- // Multibyte; how many bytes left for this character?
99
- let extraLength = null;
100
- let overlongMask = null;
101
- // 110x xxxx 10xx xxxx
102
- if ((c & 0xe0) === 0xc0) {
103
- extraLength = 1;
104
- overlongMask = 0x7f;
105
- // 1110 xxxx 10xx xxxx 10xx xxxx
106
- }
107
- else if ((c & 0xf0) === 0xe0) {
108
- extraLength = 2;
109
- overlongMask = 0x7ff;
110
- // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
111
- }
112
- else if ((c & 0xf8) === 0xf0) {
113
- extraLength = 3;
114
- overlongMask = 0xffff;
115
- }
116
- else {
117
- if ((c & 0xc0) === 0x80) {
118
- i += onError(Utf8ErrorReason.UNEXPECTED_CONTINUE, i - 1, bytes, result);
119
- }
120
- else {
121
- i += onError(Utf8ErrorReason.BAD_PREFIX, i - 1, bytes, result);
122
- }
123
- continue;
124
- }
125
- // Do we have enough bytes in our data?
126
- if (i - 1 + extraLength >= bytes.length) {
127
- i += onError(Utf8ErrorReason.OVERRUN, i - 1, bytes, result);
128
- continue;
129
- }
130
- // Remove the length prefix from the char
131
- let res = c & ((1 << (8 - extraLength - 1)) - 1);
132
- for (let j = 0; j < extraLength; j++) {
133
- let nextChar = bytes[i];
134
- // Invalid continuation byte
135
- if ((nextChar & 0xc0) != 0x80) {
136
- i += onError(Utf8ErrorReason.MISSING_CONTINUE, i, bytes, result);
137
- res = null;
138
- break;
139
- }
140
- res = (res << 6) | (nextChar & 0x3f);
141
- i++;
142
- }
143
- // See above loop for invalid continuation byte
144
- if (res === null) {
145
- continue;
146
- }
147
- // Maximum code point
148
- if (res > 0x10ffff) {
149
- i += onError(Utf8ErrorReason.OUT_OF_RANGE, i - 1 - extraLength, bytes, result, res);
150
- continue;
151
- }
152
- // Reserved for UTF-16 surrogate halves
153
- if (res >= 0xd800 && res <= 0xdfff) {
154
- i += onError(Utf8ErrorReason.UTF16_SURROGATE, i - 1 - extraLength, bytes, result, res);
155
- continue;
156
- }
157
- // Check for overlong sequences (more bytes than needed)
158
- if (res <= overlongMask) {
159
- i += onError(Utf8ErrorReason.OVERLONG, i - 1 - extraLength, bytes, result, res);
160
- continue;
161
- }
162
- result.push(res);
163
- }
164
- return result;
165
- }
166
- // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
167
- function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) {
168
- if (form != UnicodeNormalizationForm.current) {
169
- logger.checkNormalize();
170
- str = str.normalize(form);
171
- }
172
- let result = [];
173
- for (let i = 0; i < str.length; i++) {
174
- const c = str.charCodeAt(i);
175
- if (c < 0x80) {
176
- result.push(c);
177
- }
178
- else if (c < 0x800) {
179
- result.push((c >> 6) | 0xc0);
180
- result.push((c & 0x3f) | 0x80);
181
- }
182
- else if ((c & 0xfc00) == 0xd800) {
183
- i++;
184
- const c2 = str.charCodeAt(i);
185
- if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) {
186
- throw new Error("invalid utf-8 string");
187
- }
188
- // Surrogate Pair
189
- const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff);
190
- result.push((pair >> 18) | 0xf0);
191
- result.push(((pair >> 12) & 0x3f) | 0x80);
192
- result.push(((pair >> 6) & 0x3f) | 0x80);
193
- result.push((pair & 0x3f) | 0x80);
194
- }
195
- else {
196
- result.push((c >> 12) | 0xe0);
197
- result.push(((c >> 6) & 0x3f) | 0x80);
198
- result.push((c & 0x3f) | 0x80);
199
- }
200
- }
201
- return arrayify(result);
202
- }
203
- function _toUtf8String(codePoints) {
204
- return codePoints.map((codePoint) => {
205
- if (codePoint <= 0xffff) {
206
- return String.fromCharCode(codePoint);
207
- }
208
- codePoint -= 0x10000;
209
- return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00));
210
- }).join("");
211
- }
212
- function toUtf8String(bytes, onError) {
213
- return _toUtf8String(getUtf8CodePoints(bytes, onError));
214
- }
215
- function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) {
216
- return getUtf8CodePoints(toUtf8Bytes(str, form));
217
- }
218
-
219
- export { UnicodeNormalizationForm, Utf8ErrorFuncs, Utf8ErrorReason, _toUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String };
@@ -1,3 +0,0 @@
1
- const version = "transactions/5.7.0";
2
-
3
- export { version };
@@ -1,279 +0,0 @@
1
- import { getAddress } from '../../address/lib.esm/index.js';
2
- import { hexDataLength, arrayify, hexZeroPad, hexlify, hexDataSlice, splitSignature, stripZeros, hexConcat } from '../../bytes/lib.esm/index.js';
3
- import { keccak256 } from '../../keccak256/lib.esm/index.js';
4
- import { decode, encode } from '../../rlp/lib.esm/index.js';
5
- import { recoverPublicKey, computePublicKey } from '../../signing-key/lib.esm/index.js';
6
- import { Logger } from '../../logger/lib.esm/index.js';
7
- import { version } from './_version.js';
8
- import { BigNumber } from '../../bignumber/lib.esm/bignumber.js';
9
- import { Zero } from '../../constants/lib.esm/bignumbers.js';
10
-
11
- const logger = new Logger(version);
12
- var TransactionTypes;
13
- (function (TransactionTypes) {
14
- TransactionTypes[TransactionTypes["legacy"] = 0] = "legacy";
15
- TransactionTypes[TransactionTypes["eip2930"] = 1] = "eip2930";
16
- TransactionTypes[TransactionTypes["eip1559"] = 2] = "eip1559";
17
- })(TransactionTypes || (TransactionTypes = {}));
18
- ///////////////////////////////
19
- function handleAddress(value) {
20
- if (value === "0x") {
21
- return null;
22
- }
23
- return getAddress(value);
24
- }
25
- function handleNumber(value) {
26
- if (value === "0x") {
27
- return Zero;
28
- }
29
- return BigNumber.from(value);
30
- }
31
- function computeAddress(key) {
32
- const publicKey = computePublicKey(key);
33
- return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12));
34
- }
35
- function recoverAddress(digest, signature) {
36
- return computeAddress(recoverPublicKey(arrayify(digest), signature));
37
- }
38
- function formatNumber(value, name) {
39
- const result = stripZeros(BigNumber.from(value).toHexString());
40
- if (result.length > 32) {
41
- logger.throwArgumentError("invalid length for " + name, ("transaction:" + name), value);
42
- }
43
- return result;
44
- }
45
- function accessSetify(addr, storageKeys) {
46
- return {
47
- address: getAddress(addr),
48
- storageKeys: (storageKeys || []).map((storageKey, index) => {
49
- if (hexDataLength(storageKey) !== 32) {
50
- logger.throwArgumentError("invalid access list storageKey", `accessList[${addr}:${index}]`, storageKey);
51
- }
52
- return storageKey.toLowerCase();
53
- })
54
- };
55
- }
56
- function accessListify(value) {
57
- if (Array.isArray(value)) {
58
- return value.map((set, index) => {
59
- if (Array.isArray(set)) {
60
- if (set.length > 2) {
61
- logger.throwArgumentError("access list expected to be [ address, storageKeys[] ]", `value[${index}]`, set);
62
- }
63
- return accessSetify(set[0], set[1]);
64
- }
65
- return accessSetify(set.address, set.storageKeys);
66
- });
67
- }
68
- const result = Object.keys(value).map((addr) => {
69
- const storageKeys = value[addr].reduce((accum, storageKey) => {
70
- accum[storageKey] = true;
71
- return accum;
72
- }, {});
73
- return accessSetify(addr, Object.keys(storageKeys).sort());
74
- });
75
- result.sort((a, b) => (a.address.localeCompare(b.address)));
76
- return result;
77
- }
78
- function formatAccessList(value) {
79
- return accessListify(value).map((set) => [set.address, set.storageKeys]);
80
- }
81
- function _serializeEip1559(transaction, signature) {
82
- // If there is an explicit gasPrice, make sure it matches the
83
- // EIP-1559 fees; otherwise they may not understand what they
84
- // think they are setting in terms of fee.
85
- if (transaction.gasPrice != null) {
86
- const gasPrice = BigNumber.from(transaction.gasPrice);
87
- const maxFeePerGas = BigNumber.from(transaction.maxFeePerGas || 0);
88
- if (!gasPrice.eq(maxFeePerGas)) {
89
- logger.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas", "tx", {
90
- gasPrice, maxFeePerGas
91
- });
92
- }
93
- }
94
- const fields = [
95
- formatNumber(transaction.chainId || 0, "chainId"),
96
- formatNumber(transaction.nonce || 0, "nonce"),
97
- formatNumber(transaction.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),
98
- formatNumber(transaction.maxFeePerGas || 0, "maxFeePerGas"),
99
- formatNumber(transaction.gasLimit || 0, "gasLimit"),
100
- ((transaction.to != null) ? getAddress(transaction.to) : "0x"),
101
- formatNumber(transaction.value || 0, "value"),
102
- (transaction.data || "0x"),
103
- (formatAccessList(transaction.accessList || []))
104
- ];
105
- if (signature) {
106
- const sig = splitSignature(signature);
107
- fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
108
- fields.push(stripZeros(sig.r));
109
- fields.push(stripZeros(sig.s));
110
- }
111
- return hexConcat(["0x02", encode(fields)]);
112
- }
113
- function _serializeEip2930(transaction, signature) {
114
- const fields = [
115
- formatNumber(transaction.chainId || 0, "chainId"),
116
- formatNumber(transaction.nonce || 0, "nonce"),
117
- formatNumber(transaction.gasPrice || 0, "gasPrice"),
118
- formatNumber(transaction.gasLimit || 0, "gasLimit"),
119
- ((transaction.to != null) ? getAddress(transaction.to) : "0x"),
120
- formatNumber(transaction.value || 0, "value"),
121
- (transaction.data || "0x"),
122
- (formatAccessList(transaction.accessList || []))
123
- ];
124
- if (signature) {
125
- const sig = splitSignature(signature);
126
- fields.push(formatNumber(sig.recoveryParam, "recoveryParam"));
127
- fields.push(stripZeros(sig.r));
128
- fields.push(stripZeros(sig.s));
129
- }
130
- return hexConcat(["0x01", encode(fields)]);
131
- }
132
- function _parseEipSignature(tx, fields, serialize) {
133
- try {
134
- const recid = handleNumber(fields[0]).toNumber();
135
- if (recid !== 0 && recid !== 1) {
136
- throw new Error("bad recid");
137
- }
138
- tx.v = recid;
139
- }
140
- catch (error) {
141
- logger.throwArgumentError("invalid v for transaction type: 1", "v", fields[0]);
142
- }
143
- tx.r = hexZeroPad(fields[1], 32);
144
- tx.s = hexZeroPad(fields[2], 32);
145
- try {
146
- const digest = keccak256(serialize(tx));
147
- tx.from = recoverAddress(digest, { r: tx.r, s: tx.s, recoveryParam: tx.v });
148
- }
149
- catch (error) { }
150
- }
151
- function _parseEip1559(payload) {
152
- const transaction = decode(payload.slice(1));
153
- if (transaction.length !== 9 && transaction.length !== 12) {
154
- logger.throwArgumentError("invalid component count for transaction type: 2", "payload", hexlify(payload));
155
- }
156
- const maxPriorityFeePerGas = handleNumber(transaction[2]);
157
- const maxFeePerGas = handleNumber(transaction[3]);
158
- const tx = {
159
- type: 2,
160
- chainId: handleNumber(transaction[0]).toNumber(),
161
- nonce: handleNumber(transaction[1]).toNumber(),
162
- maxPriorityFeePerGas: maxPriorityFeePerGas,
163
- maxFeePerGas: maxFeePerGas,
164
- gasPrice: null,
165
- gasLimit: handleNumber(transaction[4]),
166
- to: handleAddress(transaction[5]),
167
- value: handleNumber(transaction[6]),
168
- data: transaction[7],
169
- accessList: accessListify(transaction[8]),
170
- };
171
- // Unsigned EIP-1559 Transaction
172
- if (transaction.length === 9) {
173
- return tx;
174
- }
175
- tx.hash = keccak256(payload);
176
- _parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
177
- return tx;
178
- }
179
- function _parseEip2930(payload) {
180
- const transaction = decode(payload.slice(1));
181
- if (transaction.length !== 8 && transaction.length !== 11) {
182
- logger.throwArgumentError("invalid component count for transaction type: 1", "payload", hexlify(payload));
183
- }
184
- const tx = {
185
- type: 1,
186
- chainId: handleNumber(transaction[0]).toNumber(),
187
- nonce: handleNumber(transaction[1]).toNumber(),
188
- gasPrice: handleNumber(transaction[2]),
189
- gasLimit: handleNumber(transaction[3]),
190
- to: handleAddress(transaction[4]),
191
- value: handleNumber(transaction[5]),
192
- data: transaction[6],
193
- accessList: accessListify(transaction[7])
194
- };
195
- // Unsigned EIP-2930 Transaction
196
- if (transaction.length === 8) {
197
- return tx;
198
- }
199
- tx.hash = keccak256(payload);
200
- _parseEipSignature(tx, transaction.slice(8), _serializeEip2930);
201
- return tx;
202
- }
203
- // Legacy Transactions and EIP-155
204
- function _parse(rawTransaction) {
205
- const transaction = decode(rawTransaction);
206
- if (transaction.length !== 9 && transaction.length !== 6) {
207
- logger.throwArgumentError("invalid raw transaction", "rawTransaction", rawTransaction);
208
- }
209
- const tx = {
210
- nonce: handleNumber(transaction[0]).toNumber(),
211
- gasPrice: handleNumber(transaction[1]),
212
- gasLimit: handleNumber(transaction[2]),
213
- to: handleAddress(transaction[3]),
214
- value: handleNumber(transaction[4]),
215
- data: transaction[5],
216
- chainId: 0
217
- };
218
- // Legacy unsigned transaction
219
- if (transaction.length === 6) {
220
- return tx;
221
- }
222
- try {
223
- tx.v = BigNumber.from(transaction[6]).toNumber();
224
- }
225
- catch (error) {
226
- // @TODO: What makes snese to do? The v is too big
227
- return tx;
228
- }
229
- tx.r = hexZeroPad(transaction[7], 32);
230
- tx.s = hexZeroPad(transaction[8], 32);
231
- if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) {
232
- // EIP-155 unsigned transaction
233
- tx.chainId = tx.v;
234
- tx.v = 0;
235
- }
236
- else {
237
- // Signed Transaction
238
- tx.chainId = Math.floor((tx.v - 35) / 2);
239
- if (tx.chainId < 0) {
240
- tx.chainId = 0;
241
- }
242
- let recoveryParam = tx.v - 27;
243
- const raw = transaction.slice(0, 6);
244
- if (tx.chainId !== 0) {
245
- raw.push(hexlify(tx.chainId));
246
- raw.push("0x");
247
- raw.push("0x");
248
- recoveryParam -= tx.chainId * 2 + 8;
249
- }
250
- const digest = keccak256(encode(raw));
251
- try {
252
- tx.from = recoverAddress(digest, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam: recoveryParam });
253
- }
254
- catch (error) { }
255
- tx.hash = keccak256(rawTransaction);
256
- }
257
- tx.type = null;
258
- return tx;
259
- }
260
- function parse(rawTransaction) {
261
- const payload = arrayify(rawTransaction);
262
- // Legacy and EIP-155 Transactions
263
- if (payload[0] > 0x7f) {
264
- return _parse(payload);
265
- }
266
- // Typed Transaction (EIP-2718)
267
- switch (payload[0]) {
268
- case 1:
269
- return _parseEip2930(payload);
270
- case 2:
271
- return _parseEip1559(payload);
272
- }
273
- return logger.throwError(`unsupported transaction type: ${payload[0]}`, Logger.errors.UNSUPPORTED_OPERATION, {
274
- operation: "parseTransaction",
275
- transactionType: payload[0]
276
- });
277
- }
278
-
279
- export { TransactionTypes, accessListify, computeAddress, parse, recoverAddress };
@@ -1,3 +0,0 @@
1
- const version = "web/5.7.1";
2
-
3
- export { version };
@@ -1,69 +0,0 @@
1
- import { arrayify } from '../../bytes/lib.esm/index.js';
2
-
3
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- function getUrl(href, options) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- if (options == null) {
15
- options = {};
16
- }
17
- const request = {
18
- method: (options.method || "GET"),
19
- headers: (options.headers || {}),
20
- body: (options.body || undefined),
21
- };
22
- if (options.skipFetchSetup !== true) {
23
- request.mode = "cors"; // no-cors, cors, *same-origin
24
- request.cache = "no-cache"; // *default, no-cache, reload, force-cache, only-if-cached
25
- request.credentials = "same-origin"; // include, *same-origin, omit
26
- request.redirect = "follow"; // manual, *follow, error
27
- request.referrer = "client"; // no-referrer, *client
28
- }
29
- if (options.fetchOptions != null) {
30
- const opts = options.fetchOptions;
31
- if (opts.mode) {
32
- request.mode = (opts.mode);
33
- }
34
- if (opts.cache) {
35
- request.cache = (opts.cache);
36
- }
37
- if (opts.credentials) {
38
- request.credentials = (opts.credentials);
39
- }
40
- if (opts.redirect) {
41
- request.redirect = (opts.redirect);
42
- }
43
- if (opts.referrer) {
44
- request.referrer = opts.referrer;
45
- }
46
- }
47
- const response = yield fetch(href, request);
48
- const body = yield response.arrayBuffer();
49
- const headers = {};
50
- if (response.headers.forEach) {
51
- response.headers.forEach((value, key) => {
52
- headers[key.toLowerCase()] = value;
53
- });
54
- }
55
- else {
56
- ((response.headers).keys)().forEach((key) => {
57
- headers[key.toLowerCase()] = response.headers.get(key);
58
- });
59
- }
60
- return {
61
- headers: headers,
62
- statusCode: response.status,
63
- statusMessage: response.statusText,
64
- body: arrayify(new Uint8Array(body)),
65
- };
66
- });
67
- }
68
-
69
- export { getUrl };