quantumcoin 6.14.2 → 6.14.5

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 (317) hide show
  1. package/CHANGELOG.md +442 -442
  2. package/FUNDING.json +10 -10
  3. package/LICENSE.md +21 -21
  4. package/README.md +132 -142
  5. package/SECURITY.md +34 -34
  6. package/dist/README.md +22 -22
  7. package/dist/quantumcoin.js +1127 -1324
  8. package/dist/quantumcoin.js.map +1 -1
  9. package/dist/quantumcoin.min.js +1 -1
  10. package/dist/quantumcoin.umd.js +1128 -1327
  11. package/dist/quantumcoin.umd.js.map +1 -1
  12. package/dist/quantumcoin.umd.min.js +1 -1
  13. package/dist/wordlists-extra.js +1 -1
  14. package/dist/wordlists-extra.js.map +1 -1
  15. package/dist/wordlists-extra.min.js +1 -1
  16. package/lib.commonjs/README.md +16 -16
  17. package/lib.commonjs/_version.js +1 -1
  18. package/lib.commonjs/crypto/signature.d.ts +3 -76
  19. package/lib.commonjs/crypto/signature.d.ts.map +1 -1
  20. package/lib.commonjs/crypto/signature.js +15 -199
  21. package/lib.commonjs/crypto/signature.js.map +1 -1
  22. package/lib.commonjs/crypto/signing-key.d.ts +1 -1
  23. package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
  24. package/lib.commonjs/crypto/signing-key.js +19 -10
  25. package/lib.commonjs/crypto/signing-key.js.map +1 -1
  26. package/lib.commonjs/package.json +12 -12
  27. package/lib.commonjs/providers/provider-jsonrpc.d.ts +0 -1
  28. package/lib.commonjs/providers/provider-jsonrpc.d.ts.map +1 -1
  29. package/lib.commonjs/providers/provider-jsonrpc.js +0 -1
  30. package/lib.commonjs/providers/provider-jsonrpc.js.map +1 -1
  31. package/lib.commonjs/quantumcoin.d.ts +2 -0
  32. package/lib.commonjs/quantumcoin.d.ts.map +1 -1
  33. package/lib.commonjs/quantumcoin.js +11 -5
  34. package/lib.commonjs/quantumcoin.js.map +1 -1
  35. package/lib.commonjs/transaction/address.d.ts.map +1 -1
  36. package/lib.commonjs/transaction/address.js +8 -3
  37. package/lib.commonjs/transaction/address.js.map +1 -1
  38. package/lib.commonjs/transaction/transaction.d.ts.map +1 -1
  39. package/lib.commonjs/transaction/transaction.js +7 -40
  40. package/lib.commonjs/transaction/transaction.js.map +1 -1
  41. package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
  42. package/lib.commonjs/wallet/json-keystore.js +7 -7
  43. package/lib.commonjs/wallet/json-keystore.js.map +1 -1
  44. package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
  45. package/lib.commonjs/wallet/wallet.js +2 -2
  46. package/lib.commonjs/wallet/wallet.js.map +1 -1
  47. package/lib.esm/README.md +16 -16
  48. package/lib.esm/_version.js +1 -1
  49. package/lib.esm/crypto/signature.d.ts +3 -76
  50. package/lib.esm/crypto/signature.d.ts.map +1 -1
  51. package/lib.esm/crypto/signature.js +16 -202
  52. package/lib.esm/crypto/signature.js.map +1 -1
  53. package/lib.esm/crypto/signing-key.d.ts +1 -1
  54. package/lib.esm/crypto/signing-key.d.ts.map +1 -1
  55. package/lib.esm/crypto/signing-key.js +20 -9
  56. package/lib.esm/crypto/signing-key.js.map +1 -1
  57. package/lib.esm/package.json +12 -12
  58. package/lib.esm/providers/provider-jsonrpc.d.ts +0 -1
  59. package/lib.esm/providers/provider-jsonrpc.d.ts.map +1 -1
  60. package/lib.esm/providers/provider-jsonrpc.js +0 -1
  61. package/lib.esm/providers/provider-jsonrpc.js.map +1 -1
  62. package/lib.esm/quantumcoin.d.ts +2 -0
  63. package/lib.esm/quantumcoin.d.ts.map +1 -1
  64. package/lib.esm/quantumcoin.js +6 -0
  65. package/lib.esm/quantumcoin.js.map +1 -1
  66. package/lib.esm/transaction/address.d.ts.map +1 -1
  67. package/lib.esm/transaction/address.js +8 -2
  68. package/lib.esm/transaction/address.js.map +1 -1
  69. package/lib.esm/transaction/transaction.d.ts.map +1 -1
  70. package/lib.esm/transaction/transaction.js +7 -40
  71. package/lib.esm/transaction/transaction.js.map +1 -1
  72. package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
  73. package/lib.esm/wallet/json-keystore.js +11 -5
  74. package/lib.esm/wallet/json-keystore.js.map +1 -1
  75. package/lib.esm/wallet/wallet.d.ts.map +1 -1
  76. package/lib.esm/wallet/wallet.js +3 -1
  77. package/lib.esm/wallet/wallet.js.map +1 -1
  78. package/package.json +6 -5
  79. package/rollup.config.mjs +50 -50
  80. package/src.ts/_version.ts +1 -1
  81. package/src.ts/abi/abi-coder.ts +237 -237
  82. package/src.ts/abi/bytes32.ts +45 -45
  83. package/src.ts/abi/coders/abstract-coder.ts +541 -541
  84. package/src.ts/abi/coders/address.ts +36 -36
  85. package/src.ts/abi/coders/anonymous.ts +29 -29
  86. package/src.ts/abi/coders/array.ts +199 -199
  87. package/src.ts/abi/coders/boolean.ts +27 -27
  88. package/src.ts/abi/coders/bytes.ts +43 -43
  89. package/src.ts/abi/coders/fixed-bytes.ts +37 -37
  90. package/src.ts/abi/coders/null.ts +28 -28
  91. package/src.ts/abi/coders/number.ts +63 -63
  92. package/src.ts/abi/coders/string.ts +29 -29
  93. package/src.ts/abi/coders/tuple.ts +69 -69
  94. package/src.ts/abi/fragments.ts +1617 -1617
  95. package/src.ts/abi/index.ts +41 -41
  96. package/src.ts/abi/interface.ts +1271 -1271
  97. package/src.ts/abi/typed.ts +796 -796
  98. package/src.ts/address/address.ts +148 -148
  99. package/src.ts/address/checks.ts +123 -123
  100. package/src.ts/address/contract-address.ts +80 -80
  101. package/src.ts/address/index.ts +57 -57
  102. package/src.ts/constants/addresses.ts +8 -8
  103. package/src.ts/constants/hashes.ts +7 -7
  104. package/src.ts/constants/index.ts +16 -16
  105. package/src.ts/constants/numbers.ts +35 -35
  106. package/src.ts/constants/strings.ts +16 -16
  107. package/src.ts/contract/contract.ts +1120 -1120
  108. package/src.ts/contract/factory.ts +143 -143
  109. package/src.ts/contract/index.ts +31 -31
  110. package/src.ts/contract/types.ts +236 -236
  111. package/src.ts/contract/wrappers.ts +225 -225
  112. package/src.ts/crypto/crypto-browser.ts +64 -64
  113. package/src.ts/crypto/crypto.ts +4 -4
  114. package/src.ts/crypto/hmac.ts +51 -51
  115. package/src.ts/crypto/index.ts +59 -59
  116. package/src.ts/crypto/keccak.ts +54 -54
  117. package/src.ts/crypto/pbkdf2.ts +55 -55
  118. package/src.ts/crypto/random.ts +36 -36
  119. package/src.ts/crypto/ripemd160.ts +43 -43
  120. package/src.ts/crypto/scrypt.ts +114 -114
  121. package/src.ts/crypto/sha2.ts +78 -78
  122. package/src.ts/crypto/signature.ts +145 -349
  123. package/src.ts/crypto/signing-key.ts +126 -118
  124. package/src.ts/hash/authorization.ts +38 -38
  125. package/src.ts/hash/id.ts +17 -17
  126. package/src.ts/hash/index.ts +18 -18
  127. package/src.ts/hash/message.ts +51 -51
  128. package/src.ts/hash/namehash.ts +101 -101
  129. package/src.ts/hash/solidity.ts +117 -117
  130. package/src.ts/hash/typed-data.ts +658 -658
  131. package/src.ts/index.ts +12 -12
  132. package/src.ts/providers/abstract-provider.ts +1761 -1761
  133. package/src.ts/providers/abstract-signer.ts +314 -314
  134. package/src.ts/providers/community.ts +49 -49
  135. package/src.ts/providers/contracts.ts +42 -42
  136. package/src.ts/providers/default-provider.ts +96 -96
  137. package/src.ts/providers/ens-resolver.ts +606 -606
  138. package/src.ts/providers/format.ts +320 -320
  139. package/src.ts/providers/formatting.ts +418 -418
  140. package/src.ts/providers/index.ts +125 -125
  141. package/src.ts/providers/network.ts +327 -327
  142. package/src.ts/providers/pagination.ts +8 -8
  143. package/src.ts/providers/plugin-fallback.ts +35 -35
  144. package/src.ts/providers/plugins-network.ts +281 -281
  145. package/src.ts/providers/provider-browser.ts +334 -334
  146. package/src.ts/providers/provider-fallback.ts +801 -801
  147. package/src.ts/providers/provider-ipcsocket-browser.ts +3 -3
  148. package/src.ts/providers/provider-ipcsocket.ts +81 -81
  149. package/src.ts/providers/provider-jsonrpc.ts +1334 -1335
  150. package/src.ts/providers/provider-socket.ts +352 -352
  151. package/src.ts/providers/provider-websocket.ts +103 -103
  152. package/src.ts/providers/provider.ts +2136 -2136
  153. package/src.ts/providers/signer-noncemanager.ts +98 -98
  154. package/src.ts/providers/signer.ts +166 -166
  155. package/src.ts/providers/subscriber-connection.ts +74 -74
  156. package/src.ts/providers/subscriber-filterid.ts +199 -199
  157. package/src.ts/providers/subscriber-polling.ts +321 -321
  158. package/src.ts/providers/ws-browser.ts +11 -11
  159. package/src.ts/providers/ws.ts +3 -3
  160. package/src.ts/quantumcoin.ts +219 -211
  161. package/src.ts/thirdparty.d.ts +16 -16
  162. package/src.ts/transaction/accesslist.ts +43 -43
  163. package/src.ts/transaction/address.ts +35 -31
  164. package/src.ts/transaction/authorization.ts +14 -14
  165. package/src.ts/transaction/index.ts +51 -51
  166. package/src.ts/transaction/transaction.ts +1349 -1379
  167. package/src.ts/utils/base58.ts +73 -73
  168. package/src.ts/utils/base64-browser.ts +25 -25
  169. package/src.ts/utils/base64.ts +56 -56
  170. package/src.ts/utils/data.ts +199 -199
  171. package/src.ts/utils/errors.ts +793 -793
  172. package/src.ts/utils/events.ts +105 -105
  173. package/src.ts/utils/fetch.ts +970 -970
  174. package/src.ts/utils/fixednumber.ts +643 -643
  175. package/src.ts/utils/geturl-browser.ts +81 -81
  176. package/src.ts/utils/geturl.ts +134 -134
  177. package/src.ts/utils/index.ts +95 -95
  178. package/src.ts/utils/maths.ts +240 -240
  179. package/src.ts/utils/properties.ts +60 -60
  180. package/src.ts/utils/rlp-decode.ts +104 -104
  181. package/src.ts/utils/rlp-encode.ts +64 -64
  182. package/src.ts/utils/rlp.ts +20 -20
  183. package/src.ts/utils/units.ts +91 -91
  184. package/src.ts/utils/utf8.ts +325 -325
  185. package/src.ts/utils/uuid.ts +36 -36
  186. package/src.ts/wallet/base-wallet.ts +160 -160
  187. package/src.ts/wallet/index.ts +32 -32
  188. package/src.ts/wallet/json-keystore.ts +108 -106
  189. package/src.ts/wallet/utils.ts +147 -147
  190. package/src.ts/wallet/wallet.ts +138 -139
  191. package/src.ts/wordlists/bit-reader.ts +35 -35
  192. package/src.ts/wordlists/decode-owl.ts +58 -58
  193. package/src.ts/wordlists/decode-owla.ts +33 -33
  194. package/src.ts/wordlists/generation/encode-latin.ts +370 -370
  195. package/src.ts/wordlists/index.ts +26 -26
  196. package/src.ts/wordlists/lang-cz.ts +33 -33
  197. package/src.ts/wordlists/lang-en.ts +33 -33
  198. package/src.ts/wordlists/lang-es.ts +35 -35
  199. package/src.ts/wordlists/lang-fr.ts +34 -34
  200. package/src.ts/wordlists/lang-it.ts +33 -33
  201. package/src.ts/wordlists/lang-ja.ts +181 -181
  202. package/src.ts/wordlists/lang-ko.ts +104 -104
  203. package/src.ts/wordlists/lang-pt.ts +34 -34
  204. package/src.ts/wordlists/lang-zh.ts +112 -112
  205. package/src.ts/wordlists/wordlist-owl.ts +77 -77
  206. package/src.ts/wordlists/wordlist-owla.ts +41 -41
  207. package/src.ts/wordlists/wordlist.ts +59 -59
  208. package/src.ts/wordlists/wordlists-browser.ts +8 -8
  209. package/src.ts/wordlists/wordlists-extra.ts +9 -9
  210. package/src.ts/wordlists/wordlists.ts +38 -38
  211. package/dist/quantumcoin.min.js'.gz' +0 -0
  212. package/dist/quantumcoin.umd.min.js'.gz' +0 -0
  213. package/dist/wordlists-extra.min.js'.gz' +0 -0
  214. package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
  215. package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
  216. package/lib.commonjs/providers/provider-alchemy.js +0 -151
  217. package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
  218. package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
  219. package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
  220. package/lib.commonjs/providers/provider-ankr.js +0 -137
  221. package/lib.commonjs/providers/provider-ankr.js.map +0 -1
  222. package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
  223. package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
  224. package/lib.commonjs/providers/provider-blockscout.js +0 -145
  225. package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
  226. package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
  227. package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
  228. package/lib.commonjs/providers/provider-chainstack.js +0 -102
  229. package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
  230. package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
  231. package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
  232. package/lib.commonjs/providers/provider-cloudflare.js +0 -26
  233. package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
  234. package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
  235. package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
  236. package/lib.commonjs/providers/provider-etherscan.js +0 -587
  237. package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
  238. package/lib.commonjs/providers/provider-infura.d.ts +0 -101
  239. package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
  240. package/lib.commonjs/providers/provider-infura.js +0 -206
  241. package/lib.commonjs/providers/provider-infura.js.map +0 -1
  242. package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
  243. package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
  244. package/lib.commonjs/providers/provider-pocket.js +0 -109
  245. package/lib.commonjs/providers/provider-pocket.js.map +0 -1
  246. package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
  247. package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
  248. package/lib.commonjs/providers/provider-quicknode.js +0 -163
  249. package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
  250. package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
  251. package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
  252. package/lib.commonjs/wallet/hdwallet.js +0 -505
  253. package/lib.commonjs/wallet/hdwallet.js.map +0 -1
  254. package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
  255. package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
  256. package/lib.commonjs/wallet/json-crowdsale.js +0 -60
  257. package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
  258. package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
  259. package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
  260. package/lib.commonjs/wallet/mnemonic.js +0 -169
  261. package/lib.commonjs/wallet/mnemonic.js.map +0 -1
  262. package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
  263. package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
  264. package/lib.commonjs/wallet/seedwallet.js +0 -8
  265. package/lib.commonjs/wallet/seedwallet.js.map +0 -1
  266. package/lib.esm/providers/provider-alchemy.d.ts +0 -50
  267. package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
  268. package/lib.esm/providers/provider-alchemy.js +0 -147
  269. package/lib.esm/providers/provider-alchemy.js.map +0 -1
  270. package/lib.esm/providers/provider-ankr.d.ts +0 -61
  271. package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
  272. package/lib.esm/providers/provider-ankr.js +0 -133
  273. package/lib.esm/providers/provider-ankr.js.map +0 -1
  274. package/lib.esm/providers/provider-blockscout.d.ts +0 -59
  275. package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
  276. package/lib.esm/providers/provider-blockscout.js +0 -141
  277. package/lib.esm/providers/provider-blockscout.js.map +0 -1
  278. package/lib.esm/providers/provider-chainstack.d.ts +0 -46
  279. package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
  280. package/lib.esm/providers/provider-chainstack.js +0 -98
  281. package/lib.esm/providers/provider-chainstack.js.map +0 -1
  282. package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
  283. package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
  284. package/lib.esm/providers/provider-cloudflare.js +0 -22
  285. package/lib.esm/providers/provider-cloudflare.js.map +0 -1
  286. package/lib.esm/providers/provider-etherscan.d.ts +0 -147
  287. package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
  288. package/lib.esm/providers/provider-etherscan.js +0 -584
  289. package/lib.esm/providers/provider-etherscan.js.map +0 -1
  290. package/lib.esm/providers/provider-infura.d.ts +0 -101
  291. package/lib.esm/providers/provider-infura.d.ts.map +0 -1
  292. package/lib.esm/providers/provider-infura.js +0 -201
  293. package/lib.esm/providers/provider-infura.js.map +0 -1
  294. package/lib.esm/providers/provider-pocket.d.ts +0 -54
  295. package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
  296. package/lib.esm/providers/provider-pocket.js +0 -105
  297. package/lib.esm/providers/provider-pocket.js.map +0 -1
  298. package/lib.esm/providers/provider-quicknode.d.ts +0 -59
  299. package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
  300. package/lib.esm/providers/provider-quicknode.js +0 -159
  301. package/lib.esm/providers/provider-quicknode.js.map +0 -1
  302. package/lib.esm/wallet/hdwallet.d.ts +0 -248
  303. package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
  304. package/lib.esm/wallet/hdwallet.js +0 -498
  305. package/lib.esm/wallet/hdwallet.js.map +0 -1
  306. package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
  307. package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
  308. package/lib.esm/wallet/json-crowdsale.js +0 -55
  309. package/lib.esm/wallet/json-crowdsale.js.map +0 -1
  310. package/lib.esm/wallet/mnemonic.d.ts +0 -65
  311. package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
  312. package/lib.esm/wallet/mnemonic.js +0 -165
  313. package/lib.esm/wallet/mnemonic.js.map +0 -1
  314. package/lib.esm/wallet/seedwallet.d.ts +0 -4
  315. package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
  316. package/lib.esm/wallet/seedwallet.js +0 -4
  317. package/lib.esm/wallet/seedwallet.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
  const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !== 'undefined' ? window: typeof global !== 'undefined' ? global: typeof self !== 'undefined' ? self: {});
2
2
  (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
5
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ethers = {}));
6
- })(this, (function (exports) { 'use strict';
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('quantum-coin-js-sdk'), require('quantum-coin-pqc-js-sdk')) :
4
+ typeof define === 'function' && define.amd ? define(['exports', 'quantum-coin-js-sdk', 'quantum-coin-pqc-js-sdk'], factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ethers = {}, global.quantumCoinJsSdk, global.quantumCoinPqcJsSdk));
6
+ })(this, (function (exports, quantumCoinJsSdk, quantumCoinPqcJsSdk) { 'use strict';
7
7
 
8
8
  /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
9
9
  /**
10
10
  * The current version of Ethers.
11
11
  */
12
- const version = "6.14.1";
12
+ const version = "6.14.3";
13
13
 
14
14
  /**
15
15
  * Property helper functions.
@@ -461,7 +461,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
461
461
  *
462
462
  * @_subsection: api/utils:Math Helpers [about-maths]
463
463
  */
464
- const BN_0$a = BigInt(0);
464
+ const BN_0$9 = BigInt(0);
465
465
  const BN_1$4 = BigInt(1);
466
466
  //const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
467
467
  // IEEE 754 support 53-bits of mantissa
@@ -475,7 +475,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
475
475
  function fromTwos(_value, _width) {
476
476
  const value = getUint(_value, "value");
477
477
  const width = BigInt(getNumber(_width, "width"));
478
- assert((value >> width) === BN_0$a, "overflow", "NUMERIC_FAULT", {
478
+ assert((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
479
479
  operation: "fromTwos", fault: "overflow", value: _value
480
480
  });
481
481
  // Top bit set; treat as a negative value
@@ -495,7 +495,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
495
495
  let value = getBigInt(_value, "value");
496
496
  const width = BigInt(getNumber(_width, "width"));
497
497
  const limit = (BN_1$4 << (width - BN_1$4));
498
- if (value < BN_0$a) {
498
+ if (value < BN_0$9) {
499
499
  value = -value;
500
500
  assert(value <= limit, "too low", "NUMERIC_FAULT", {
501
501
  operation: "toTwos", fault: "overflow", value: _value
@@ -551,7 +551,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
551
551
  */
552
552
  function getUint(value, name) {
553
553
  const result = getBigInt(value, name);
554
- assert(result >= BN_0$a, "unsigned value cannot be negative", "NUMERIC_FAULT", {
554
+ assert(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
555
555
  fault: "overflow", operation: "getUint", value
556
556
  });
557
557
  return result;
@@ -637,7 +637,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
637
637
  */
638
638
  function toBeArray(_value) {
639
639
  const value = getUint(_value, "value");
640
- if (value === BN_0$a) {
640
+ if (value === BN_0$9) {
641
641
  return new Uint8Array([]);
642
642
  }
643
643
  let hex = value.toString(16);
@@ -695,7 +695,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
695
695
  assertArgument(result != null, `invalid base58 value`, "letter", letter);
696
696
  return result;
697
697
  }
698
- const BN_0$9 = BigInt(0);
698
+ const BN_0$8 = BigInt(0);
699
699
  const BN_58 = BigInt(58);
700
700
  /**
701
701
  * Encode %%value%% as a Base58-encoded string.
@@ -721,7 +721,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
721
721
  * Decode the Base58-encoded %%value%%.
722
722
  */
723
723
  function decodeBase58(value) {
724
- let result = BN_0$9;
724
+ let result = BN_0$8;
725
725
  for (let i = 0; i < value.length; i++) {
726
726
  result *= BN_58;
727
727
  result += getAlpha(value[i]);
@@ -1915,7 +1915,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
1915
1915
  * @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
1916
1916
  */
1917
1917
  const BN_N1 = BigInt(-1);
1918
- const BN_0$8 = BigInt(0);
1918
+ const BN_0$7 = BigInt(0);
1919
1919
  const BN_1$3 = BigInt(1);
1920
1920
  const BN_5 = BigInt(5);
1921
1921
  const _guard$3 = {};
@@ -1939,7 +1939,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
1939
1939
  assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
1940
1940
  operation: safeOp, fault: "overflow", value: val
1941
1941
  });
1942
- if (val > BN_0$8) {
1942
+ if (val > BN_0$7) {
1943
1943
  val = fromTwos(mask(val, width), width);
1944
1944
  }
1945
1945
  else {
@@ -1997,7 +1997,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
1997
1997
  }
1998
1998
  function toString(val, decimals) {
1999
1999
  let negative = "";
2000
- if (val < BN_0$8) {
2000
+ if (val < BN_0$7) {
2001
2001
  negative = "-";
2002
2002
  val *= BN_N1;
2003
2003
  }
@@ -2188,13 +2188,13 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2188
2188
  mulSignal(other) {
2189
2189
  this.#checkFormat(other);
2190
2190
  const value = this.#val * other.#val;
2191
- assert((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", {
2191
+ assert((value % this.#tens) === BN_0$7, "precision lost during signalling mul", "NUMERIC_FAULT", {
2192
2192
  operation: "mulSignal", fault: "underflow", value: this
2193
2193
  });
2194
2194
  return this.#checkValue(value / this.#tens, "mulSignal");
2195
2195
  }
2196
2196
  #div(o, safeOp) {
2197
- assert(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
2197
+ assert(o.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
2198
2198
  operation: "div", fault: "divide-by-zero", value: this
2199
2199
  });
2200
2200
  this.#checkFormat(o);
@@ -2218,12 +2218,12 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2218
2218
  * (precision loss) occurs.
2219
2219
  */
2220
2220
  divSignal(other) {
2221
- assert(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
2221
+ assert(other.#val !== BN_0$7, "division by zero", "NUMERIC_FAULT", {
2222
2222
  operation: "div", fault: "divide-by-zero", value: this
2223
2223
  });
2224
2224
  this.#checkFormat(other);
2225
2225
  const value = (this.#val * this.#tens);
2226
- assert((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", {
2226
+ assert((value % other.#val) === BN_0$7, "precision lost during signalling div", "NUMERIC_FAULT", {
2227
2227
  operation: "divSignal", fault: "underflow", value: this
2228
2228
  });
2229
2229
  return this.#checkValue(value / other.#val, "divSignal");
@@ -2282,7 +2282,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2282
2282
  */
2283
2283
  floor() {
2284
2284
  let val = this.#val;
2285
- if (this.#val < BN_0$8) {
2285
+ if (this.#val < BN_0$7) {
2286
2286
  val -= this.#tens - BN_1$3;
2287
2287
  }
2288
2288
  val = (this.#val / this.#tens) * this.#tens;
@@ -2296,7 +2296,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2296
2296
  */
2297
2297
  ceiling() {
2298
2298
  let val = this.#val;
2299
- if (this.#val > BN_0$8) {
2299
+ if (this.#val > BN_0$7) {
2300
2300
  val += this.#tens - BN_1$3;
2301
2301
  }
2302
2302
  val = (this.#val / this.#tens) * this.#tens;
@@ -2325,11 +2325,11 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2325
2325
  /**
2326
2326
  * Returns true if %%this%% is equal to ``0``.
2327
2327
  */
2328
- isZero() { return (this.#val === BN_0$8); }
2328
+ isZero() { return (this.#val === BN_0$7); }
2329
2329
  /**
2330
2330
  * Returns true if %%this%% is less than ``0``.
2331
2331
  */
2332
- isNegative() { return (this.#val < BN_0$8); }
2332
+ isNegative() { return (this.#val < BN_0$7); }
2333
2333
  /**
2334
2334
  * Returns the string representation of %%this%%.
2335
2335
  */
@@ -2366,7 +2366,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
2366
2366
  const delta = decimals - format.decimals;
2367
2367
  if (delta > 0) {
2368
2368
  const tens = getTens(delta);
2369
- assert((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", {
2369
+ assert((value % tens) === BN_0$7, "value loses precision for format", "NUMERIC_FAULT", {
2370
2370
  operation: "fromValue", fault: "underflow", value: _value
2371
2371
  });
2372
2372
  value /= tens;
@@ -4779,11 +4779,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
4779
4779
  const MessagePrefix = "\x19Ethereum Signed Message:\n";
4780
4780
 
4781
4781
  // Constants
4782
- const BN_0$7 = BigInt(0);
4783
- //const BN_1 = BigInt(1);
4784
- const BN_2$3 = BigInt(2);
4785
- const BN_28$1 = BigInt(28);
4786
- const BN_35$1 = BigInt(35);
4787
4782
  const _guard$1 = {};
4788
4783
  /*
4789
4784
  function toUint256(value: BigNumberish): string {
@@ -4799,7 +4794,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
4799
4794
  #r;
4800
4795
  #s;
4801
4796
  #v;
4802
- #networkV;
4803
4797
  /**
4804
4798
  * The ``r`` value for a signature.
4805
4799
  *
@@ -4820,67 +4814,22 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
4820
4814
  }
4821
4815
  /**
4822
4816
  * The ``v`` value for a signature.
4823
- *
4824
- * Since a given ``x`` value for ``r`` has two possible values for
4825
- * its correspondin ``y``, the ``v`` indicates which of the two ``y``
4826
- * values to use.
4827
- *
4828
- * It is normalized to the values ``28`` or ``28`` for legacy
4829
- * purposes.
4830
4817
  */
4831
4818
  get v() { return this.#v; }
4832
4819
  set v(value) {
4833
4820
  const v = getNumber(value, "value");
4834
- assertArgument(v === 28, "invalid v", "v", value);
4821
+ assertArgument(v === 1, "invalid v", "v", value);
4835
4822
  this.#v = v;
4836
4823
  }
4837
- /**
4838
- * The EIP-155 ``v`` for legacy transactions. For non-legacy
4839
- * transactions, this value is ``null``.
4840
- */
4841
- get networkV() { return this.#networkV; }
4842
- /**
4843
- * The chain ID for EIP-155 legacy transactions. For non-legacy
4844
- * transactions, this value is ``null``.
4845
- */
4846
- get legacyChainId() {
4847
- const v = this.networkV;
4848
- if (v == null) {
4849
- return null;
4850
- }
4851
- return Signature.getChainId(v);
4852
- }
4853
- /**
4854
- * The ``yParity`` for the signature.
4855
- *
4856
- * See ``v`` for more details on how this value is used.
4857
- */
4858
- get yParity() {
4859
- return (this.v === 28) ? 0 : 1;
4860
- }
4861
- /**
4862
- * The [[link-eip-2098]] compact representation of the ``yParity``
4863
- * and ``s`` compacted into a single ``bytes32``.
4864
- */
4865
- get yParityAndS() {
4866
- // The EIP-2098 compact representation
4867
- const yParityAndS = getBytes(this.s);
4868
- if (this.yParity) {
4869
- yParityAndS[0] |= 0x80;
4870
- }
4871
- return hexlify(yParityAndS);
4872
- }
4873
- /**
4874
- * The [[link-eip-2098]] compact representation.
4875
- */
4876
- get compactSerialized() {
4877
- return concat([this.r, this.yParityAndS]);
4878
- }
4879
4824
  /**
4880
4825
  * The serialized representation.
4881
4826
  */
4882
4827
  get serialized() {
4883
- return concat([this.r, this.s, (this.yParity ? "0x1c" : "0x1b")]);
4828
+ return JSON.stringify({
4829
+ r: this.r,
4830
+ s: this.s,
4831
+ v: this.v
4832
+ });
4884
4833
  }
4885
4834
  /**
4886
4835
  * @private
@@ -4890,94 +4839,26 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
4890
4839
  this.#r = r;
4891
4840
  this.#s = s;
4892
4841
  this.#v = v;
4893
- this.#networkV = null;
4894
4842
  }
4895
4843
  [Symbol.for('nodejs.util.inspect.custom')]() {
4896
- return `Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`;
4844
+ return `Signature { r: "${this.r}", s: "${this.s}" }`;
4897
4845
  }
4898
4846
  /**
4899
4847
  * Returns a new identical [[Signature]].
4900
4848
  */
4901
4849
  clone() {
4902
4850
  const clone = new Signature(_guard$1, this.r, this.s, this.v);
4903
- if (this.networkV) {
4904
- clone.#networkV = this.networkV;
4905
- }
4906
4851
  return clone;
4907
4852
  }
4908
4853
  /**
4909
4854
  * Returns a representation that is compatible with ``JSON.stringify``.
4910
4855
  */
4911
4856
  toJSON() {
4912
- const networkV = this.networkV;
4913
4857
  return {
4914
4858
  _type: "signature",
4915
- networkV: ((networkV != null) ? networkV.toString() : null),
4916
4859
  r: this.r, s: this.s, v: this.v,
4917
4860
  };
4918
4861
  }
4919
- /**
4920
- * Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.
4921
- *
4922
- * @example:
4923
- * Signature.getChainId(45)
4924
- * //_result:
4925
- *
4926
- * Signature.getChainId(46)
4927
- * //_result:
4928
- */
4929
- static getChainId(v) {
4930
- const bv = getBigInt(v, "v");
4931
- // The v is not an EIP-155 v, so it is the unspecified chain ID
4932
- if ((bv == BN_28$1) || (bv == BN_28$1)) {
4933
- return BN_0$7;
4934
- }
4935
- // Bad value for an EIP-155 v
4936
- assertArgument(bv >= BN_35$1, "invalid EIP-155 v", "v", v);
4937
- return (bv - BN_35$1) / BN_2$3;
4938
- }
4939
- /**
4940
- * Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.
4941
- *
4942
- * Legacy transactions which use [[link-eip-155]] hijack the ``v``
4943
- * property to include the chain ID.
4944
- *
4945
- * @example:
4946
- *
4947
- * Signature.getChainIdV(5, 28)
4948
- * //_result:
4949
- *
4950
- */
4951
- static getChainIdV(chainId, v) {
4952
- return (getBigInt(chainId) * BN_2$3) + BigInt(35 + v - 28);
4953
- }
4954
- /**
4955
- * Compute the normalized legacy transaction ``v`` from a ``yParirty``,
4956
- * a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.
4957
- *
4958
- * @example:
4959
- * // The values 0 and 1 imply v is actually yParity
4960
- * Signature.getNormalizedV(0)
4961
- * //_result:
4962
- *
4963
- * // Legacy EIP-155 transaction (i.e. >= 35)
4964
- * Signature.getNormalizedV(46)
4965
- * //_result:
4966
- *
4967
- * // Invalid values throw
4968
- * Signature.getNormalizedV(5)
4969
- * //_error:
4970
- */
4971
- /*static getNormalizedV(v: BigNumberish): 28 {
4972
- const bv = getBigInt(v);
4973
-
4974
- if (bv === BN_1 || bv === BN_28) { return 28; }
4975
-
4976
- assertArgument(bv >= BN_35, "invalid v", "v", v);
4977
-
4978
- // Otherwise, EIP-155 v means odd is 28 and even is 28
4979
- return (bv & BN_1) ? 28: 28;
4980
- }*/
4981
4862
  /**
4982
4863
  * Creates a new [[Signature]].
4983
4864
  *
@@ -4991,85 +4872,20 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
4991
4872
  assertArgument(check, message, "signature", sig);
4992
4873
  }
4993
4874
  if (sig == null) {
4994
- return new Signature(_guard$1, ZeroHash, ZeroHash, 28);
4875
+ return new Signature(_guard$1, ZeroHash, ZeroHash, 1);
4995
4876
  }
4996
4877
  if (typeof (sig) === "string") {
4997
- /*const bytes = getBytes(sig, "signature");
4998
- if (bytes.length === 64) {
4999
- const r = hexlify(bytes.slice(0, 32));
5000
- const s = bytes.slice(32, 64);
5001
- const v = (s[0] & 0x80) ? 28: 28;
5002
- s[0] &= 0x7f;
5003
- return new Signature(_guard, r, hexlify(s), v);
5004
- }
5005
-
5006
- if (bytes.length === 65) {
5007
- const r = hexlify(bytes.slice(0, 32));
5008
- const s = bytes.slice(32, 64);
5009
- assertError((s[0] & 0x80) === 0, "non-canonical s");
5010
- const v = Signature.getNormalizedV(bytes[64]);
5011
- return new Signature(_guard, r, hexlify(s), v);
5012
- }*/
5013
- assertError(false, "invalid raw signature length");
4878
+ assertError(false, "invalid raw signature");
5014
4879
  }
5015
4880
  if (sig instanceof Signature) {
5016
4881
  return sig.clone();
5017
4882
  }
5018
- return new Signature(_guard$1, ZeroHash, ZeroHash, 28); //todo
5019
- /*// Get r
5020
- const _r = sig.r;
5021
- assertError(_r != null, "missing r");
5022
- const r = toUint256(_r);
5023
-
5024
- // Get s; by any means necessary (we check consistency below)
5025
- const s = (function(s?: string, yParityAndS?: string) {
5026
- if (s != null) { return toUint256(s); }
5027
-
5028
- if (yParityAndS != null) {
5029
- assertError(isHexString(yParityAndS, 32), "invalid yParityAndS");
5030
- const bytes = getBytes(yParityAndS);
5031
- bytes[0] &= 0x7f;
5032
- return hexlify(bytes);
5033
- }
5034
-
5035
- assertError(false, "missing s");
5036
- })(sig.s, sig.yParityAndS);
5037
- assertError((getBytes(s)[0] & 0x80) == 0, "non-canonical s");
5038
-
5039
- // Get v; by any means necessary (we check consistency below)
5040
- const { networkV, v } = (function(_v?: BigNumberish, yParityAndS?: string, yParity?: Numeric): { networkV?: bigint, v: 28 | 28 } {
5041
- if (_v != null) {
5042
- const v = getBigInt(_v);
5043
- return {
5044
- networkV: ((v >= BN_35) ? v: undefined),
5045
- v: Signature.getNormalizedV(v)
5046
- };
5047
- }
5048
-
5049
- if (yParityAndS != null) {
5050
- assertError(isHexString(yParityAndS, 32), "invalid yParityAndS");
5051
- return { v: ((getBytes(yParityAndS)[0] & 0x80) ? 28: 28) };
5052
- }
5053
-
5054
- if (yParity != null) {
5055
- switch (getNumber(yParity, "sig.yParity")) {
5056
- case 0: return { v: 28 };
5057
- case 1: return { v: 28 };
5058
- }
5059
- assertError(false, "invalid yParity");
5060
- }
5061
-
5062
- assertError(false, "missing v");
5063
- })(sig.v, sig.yParityAndS, sig.yParity);
5064
-
5065
- const result = new Signature(_guard, r, s, v);
5066
- if (networkV) { result.#networkV = networkV; }
5067
-
5068
- // If multiple of v, yParity, yParityAndS we given, check they match
5069
- assertError(sig.yParity == null || getNumber(sig.yParity, "sig.yParity") === result.yParity, "yParity mismatch");
5070
- assertError(sig.yParityAndS == null || sig.yParityAndS === result.yParityAndS, "yParityAndS mismatch");
5071
-
5072
- return result;*/
4883
+ assertError(sig.r != null, "missing r");
4884
+ assertError(sig.s != null, "missing s");
4885
+ const _v = sig.v;
4886
+ assertError(_v != null, "missing v");
4887
+ assertArgument(_v === 1, "invalid v", "v", sig.v);
4888
+ return new Signature(_guard$1, sig.r, sig.s, 1);
5073
4889
  }
5074
4890
  }
5075
4891
 
@@ -5080,7 +4896,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
5080
4896
  */
5081
4897
  const CRYPTO_MESSAGE_LENGTH = 32;
5082
4898
  const CRYPTO_SECRETKEY_BYTES = 64 + 2560 + 1312 + 128;
5083
- //const CRYPTO_PUBLICKEY_BYTES = 32 + 1312 + 64;
4899
+ const CRYPTO_PUBLICKEY_BYTES = 32 + 1312 + 64;
5084
4900
  /**
5085
4901
  * A **SigningKey** provides high-level access to cryptography operations and key management.
5086
4902
  */
@@ -5107,9 +4923,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
5107
4923
  */
5108
4924
  sign(digest) {
5109
4925
  assertArgument(dataLength(digest) === CRYPTO_MESSAGE_LENGTH, "invalid digest length", "digest", digest);
5110
- const sig = pqc.cryptoSign(getBytesCopy(digest), getBytesCopy(this.#privateKey));
4926
+ const sig = quantumCoinPqcJsSdk.cryptoSign(getBytesCopy(digest), getBytesCopy(this.#privateKey));
5111
4927
  const pubBytes = getBytes(this.publicKey);
5112
- const combinedSig = qcsdk.combinePublicKeySignature(pubBytes, sig);
4928
+ let combinedSig = quantumCoinJsSdk.combinePublicKeySignature(pubBytes, sig);
4929
+ combinedSig = "0x" + combinedSig;
5113
4930
  return Signature.from({
5114
4931
  r: this.publicKey,
5115
4932
  s: combinedSig,
@@ -5117,7 +4934,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
5117
4934
  });
5118
4935
  }
5119
4936
  /**
5120
- * Compute the public key for a private %%key%%.
4937
+ * Compute the public key for a private %%key%%. If a publicKey is passed, it is returned as is. for backward compatibility.
5121
4938
  *
5122
4939
  *
5123
4940
  * @example:
@@ -5128,9 +4945,17 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
5128
4945
  * //_result:
5129
4946
  */
5130
4947
  static computePublicKey(key) {
5131
- assertArgument(dataLength(key) === CRYPTO_SECRETKEY_BYTES, "invalid private key", "privateKey", "[REDACTED]");
5132
- let priBytes = getBytes(key, "key");
5133
- let pubKey = qcsdk.publicKeyFromPrivateKey(priBytes);
4948
+ let keyBytes = getBytes(key, "key");
4949
+ let pubKey;
4950
+ if (keyBytes.length == CRYPTO_SECRETKEY_BYTES) {
4951
+ pubKey = quantumCoinJsSdk.publicKeyFromPrivateKey(keyBytes);
4952
+ assertArgument(pubKey !== null && pubKey !== undefined, "invalid key", "key", "[REDACTED]");
4953
+ pubKey = '0x' + pubKey;
4954
+ }
4955
+ else if (keyBytes.length == CRYPTO_PUBLICKEY_BYTES) {
4956
+ pubKey = keyBytes;
4957
+ }
4958
+ assertArgument(pubKey !== null && pubKey !== undefined, "invalid key", "key", "[REDACTED]");
5134
4959
  return pubKey;
5135
4960
  }
5136
4961
  /**
@@ -5156,7 +4981,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
5156
4981
  const sig = Signature.from(signature);
5157
4982
  let sigBytes = getBytes(sig.s);
5158
4983
  let digestBytes = digest;
5159
- let publicKey = qcsdk.publicKeyFromSignature(digestBytes, sigBytes);
4984
+ let publicKey = quantumCoinJsSdk.publicKeyFromSignature(digestBytes, sigBytes);
5160
4985
  return publicKey;
5161
4986
  }
5162
4987
  }
@@ -6560,13 +6385,18 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6560
6385
  function computeAddress(key) {
6561
6386
  let pubkey;
6562
6387
  if (typeof (key) === "string") {
6563
- pubkey = SigningKey.computePublicKey(key);
6388
+ if (key.startsWith("0x")) {
6389
+ pubkey = SigningKey.computePublicKey(key);
6390
+ }
6391
+ else {
6392
+ pubkey = SigningKey.computePublicKey("0x" + key);
6393
+ }
6564
6394
  }
6565
6395
  else {
6566
6396
  pubkey = key.publicKey;
6567
6397
  }
6568
6398
  let pubKeyBytes = getBytes(pubkey);
6569
- return qcsdk.addressFromPublicKey(pubKeyBytes);
6399
+ return quantumCoinJsSdk.addressFromPublicKey(pubKeyBytes);
6570
6400
  }
6571
6401
  /**
6572
6402
  * Returns the recovered address for the private key that was
@@ -6663,9 +6493,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6663
6493
  nonce: handleUint(auth[2], "nonce"),
6664
6494
  chainId: handleUint(auth[0], "chainId"),
6665
6495
  signature: Signature.from({
6666
- yParity: handleNumber(auth[3], "yParity"),
6667
- r: zeroPadValue(auth[4], 32),
6668
- s: zeroPadValue(auth[5], 32)
6496
+ r: auth[4],
6497
+ s: auth[5],
6498
+ v: 1
6669
6499
  })
6670
6500
  });
6671
6501
  }
@@ -6704,7 +6534,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6704
6534
  formatNumber(a.chainId, "chainId"),
6705
6535
  a.address,
6706
6536
  formatNumber(a.nonce, "nonce"),
6707
- formatNumber(a.signature.yParity, "yParity"),
6708
6537
  a.signature.r,
6709
6538
  a.signature.s
6710
6539
  ];
@@ -6772,17 +6601,8 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6772
6601
  if (tx.chainId != BN_0$4) {
6773
6602
  // A chainId was provided; if non-zero we'll use EIP-155
6774
6603
  chainId = getBigInt(tx.chainId, "tx.chainId");
6775
- // We have a chainId in the tx and an EIP-155 v in the signature,
6776
- // make sure they agree with each other
6777
- assertArgument(!sig || sig.networkV == null || sig.legacyChainId === chainId, "tx.chainId/sig.v mismatch", "sig", sig);
6778
- }
6779
- else if (tx.signature) {
6780
- // No explicit chainId, but EIP-155 have a derived implicit chainId
6781
- const legacy = tx.signature.legacyChainId;
6782
- if (legacy != null) {
6783
- chainId = legacy;
6784
- }
6785
6604
  }
6605
+ else if (tx.signature) ;
6786
6606
  // Requesting an unsigned transaction
6787
6607
  if (!sig) {
6788
6608
  // We have an EIP-155 transaction (chainId was specified and non-zero)
@@ -6793,17 +6613,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6793
6613
  }
6794
6614
  return encodeRlp(fields);
6795
6615
  }
6796
- // @TODO: We should probably check that tx.signature, chainId, and sig
6797
- // match but that logic could break existing code, so schedule
6798
- // this for the next major bump.
6799
- // Compute the EIP-155 v
6800
- let v = BigInt(27 + sig.yParity);
6801
- if (chainId !== BN_0$4) {
6802
- v = Signature.getChainIdV(chainId, sig.v);
6803
- }
6804
- else if (BigInt(sig.v) !== v) {
6805
- assertArgument(false, "tx.chainId/sig.v mismatch", "sig", sig);
6806
- }
6616
+ let v = sig.v;
6807
6617
  // Add the signature
6808
6618
  fields.push(toBeArray(v));
6809
6619
  fields.push(toBeArray(sig.r));
@@ -6811,19 +6621,9 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6811
6621
  return encodeRlp(fields);
6812
6622
  }
6813
6623
  function _parseEipSignature(tx, fields) {
6814
- let yParity;
6815
- try {
6816
- yParity = handleNumber(fields[0], "yParity");
6817
- if (yParity !== 0 && yParity !== 1) {
6818
- throw new Error("bad yParity");
6819
- }
6820
- }
6821
- catch (error) {
6822
- assertArgument(false, "invalid yParity", "yParity", fields[0]);
6823
- }
6824
- const r = zeroPadValue(fields[1], 32);
6825
- const s = zeroPadValue(fields[2], 32);
6826
- const signature = Signature.from({ r, s, yParity });
6624
+ const r = fields[1];
6625
+ const s = fields[2];
6626
+ const signature = Signature.from({ r, s });
6827
6627
  tx.signature = signature;
6828
6628
  }
6829
6629
  function _parseEip1559(data) {
@@ -6863,7 +6663,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6863
6663
  formatAccessList(tx.accessList || [])
6864
6664
  ];
6865
6665
  if (sig) {
6866
- fields.push(formatNumber(sig.yParity, "yParity"));
6867
6666
  fields.push(toBeArray(sig.r));
6868
6667
  fields.push(toBeArray(sig.s));
6869
6668
  }
@@ -6903,7 +6702,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6903
6702
  formatAccessList(tx.accessList || [])
6904
6703
  ];
6905
6704
  if (sig) {
6906
- fields.push(formatNumber(sig.yParity, "recoveryParam"));
6907
6705
  fields.push(toBeArray(sig.r));
6908
6706
  fields.push(toBeArray(sig.s));
6909
6707
  }
@@ -6981,7 +6779,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
6981
6779
  formatHashes(tx.blobVersionedHashes || [], "blobVersionedHashes")
6982
6780
  ];
6983
6781
  if (sig) {
6984
- fields.push(formatNumber(sig.yParity, "yParity"));
6985
6782
  fields.push(toBeArray(sig.r));
6986
6783
  fields.push(toBeArray(sig.s));
6987
6784
  // We have blobs; return the network wrapped format
@@ -7037,7 +6834,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
7037
6834
  formatAuthorizationList(tx.authorizationList || [])
7038
6835
  ];
7039
6836
  if (sig) {
7040
- fields.push(formatNumber(sig.yParity, "yParity"));
7041
6837
  fields.push(toBeArray(sig.r));
7042
6838
  fields.push(toBeArray(sig.s));
7043
6839
  }
@@ -7758,276 +7554,276 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
7758
7554
  const FENCED = new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);
7759
7555
  const NSM_MAX = 4;
7760
7556
 
7761
- function decode_arithmetic(bytes) {
7762
- let pos = 0;
7763
- function u16() { return (bytes[pos++] << 8) | bytes[pos++]; }
7764
-
7765
- // decode the frequency table
7766
- let symbol_count = u16();
7767
- let total = 1;
7768
- let acc = [0, 1]; // first symbol has frequency 1
7769
- for (let i = 1; i < symbol_count; i++) {
7770
- acc.push(total += u16());
7771
- }
7772
-
7773
- // skip the sized-payload that the last 3 symbols index into
7774
- let skip = u16();
7775
- let pos_payload = pos;
7776
- pos += skip;
7777
-
7778
- let read_width = 0;
7779
- let read_buffer = 0;
7780
- function read_bit() {
7781
- if (read_width == 0) {
7782
- // this will read beyond end of buffer
7783
- // but (undefined|0) => zero pad
7784
- read_buffer = (read_buffer << 8) | bytes[pos++];
7785
- read_width = 8;
7786
- }
7787
- return (read_buffer >> --read_width) & 1;
7788
- }
7789
-
7790
- const N = 31;
7791
- const FULL = 2**N;
7792
- const HALF = FULL >>> 1;
7793
- const QRTR = HALF >> 1;
7794
- const MASK = FULL - 1;
7795
-
7796
- // fill register
7797
- let register = 0;
7798
- for (let i = 0; i < N; i++) register = (register << 1) | read_bit();
7799
-
7800
- let symbols = [];
7801
- let low = 0;
7802
- let range = FULL; // treat like a float
7803
- while (true) {
7804
- let value = Math.floor((((register - low + 1) * total) - 1) / range);
7805
- let start = 0;
7806
- let end = symbol_count;
7807
- while (end - start > 1) { // binary search
7808
- let mid = (start + end) >>> 1;
7809
- if (value < acc[mid]) {
7810
- end = mid;
7811
- } else {
7812
- start = mid;
7813
- }
7814
- }
7815
- if (start == 0) break; // first symbol is end mark
7816
- symbols.push(start);
7817
- let a = low + Math.floor(range * acc[start] / total);
7818
- let b = low + Math.floor(range * acc[start+1] / total) - 1;
7819
- while (((a ^ b) & HALF) == 0) {
7820
- register = (register << 1) & MASK | read_bit();
7821
- a = (a << 1) & MASK;
7822
- b = (b << 1) & MASK | 1;
7823
- }
7824
- while (a & ~b & QRTR) {
7825
- register = (register & HALF) | ((register << 1) & (MASK >>> 1)) | read_bit();
7826
- a = (a << 1) ^ HALF;
7827
- b = ((b ^ HALF) << 1) | HALF | 1;
7828
- }
7829
- low = a;
7830
- range = 1 + b - a;
7831
- }
7832
- let offset = symbol_count - 4;
7833
- return symbols.map(x => { // index into payload
7834
- switch (x - offset) {
7835
- case 3: return offset + 0x10100 + ((bytes[pos_payload++] << 16) | (bytes[pos_payload++] << 8) | bytes[pos_payload++]);
7836
- case 2: return offset + 0x100 + ((bytes[pos_payload++] << 8) | bytes[pos_payload++]);
7837
- case 1: return offset + bytes[pos_payload++];
7838
- default: return x - 1;
7839
- }
7840
- });
7841
- }
7842
-
7843
- // returns an iterator which returns the next symbol
7844
- function read_payload(v) {
7845
- let pos = 0;
7846
- return () => v[pos++];
7847
- }
7848
- function read_compressed_payload(s) {
7849
- return read_payload(decode_arithmetic(unsafe_atob(s)));
7557
+ function decode_arithmetic(bytes) {
7558
+ let pos = 0;
7559
+ function u16() { return (bytes[pos++] << 8) | bytes[pos++]; }
7560
+
7561
+ // decode the frequency table
7562
+ let symbol_count = u16();
7563
+ let total = 1;
7564
+ let acc = [0, 1]; // first symbol has frequency 1
7565
+ for (let i = 1; i < symbol_count; i++) {
7566
+ acc.push(total += u16());
7567
+ }
7568
+
7569
+ // skip the sized-payload that the last 3 symbols index into
7570
+ let skip = u16();
7571
+ let pos_payload = pos;
7572
+ pos += skip;
7573
+
7574
+ let read_width = 0;
7575
+ let read_buffer = 0;
7576
+ function read_bit() {
7577
+ if (read_width == 0) {
7578
+ // this will read beyond end of buffer
7579
+ // but (undefined|0) => zero pad
7580
+ read_buffer = (read_buffer << 8) | bytes[pos++];
7581
+ read_width = 8;
7582
+ }
7583
+ return (read_buffer >> --read_width) & 1;
7584
+ }
7585
+
7586
+ const N = 31;
7587
+ const FULL = 2**N;
7588
+ const HALF = FULL >>> 1;
7589
+ const QRTR = HALF >> 1;
7590
+ const MASK = FULL - 1;
7591
+
7592
+ // fill register
7593
+ let register = 0;
7594
+ for (let i = 0; i < N; i++) register = (register << 1) | read_bit();
7595
+
7596
+ let symbols = [];
7597
+ let low = 0;
7598
+ let range = FULL; // treat like a float
7599
+ while (true) {
7600
+ let value = Math.floor((((register - low + 1) * total) - 1) / range);
7601
+ let start = 0;
7602
+ let end = symbol_count;
7603
+ while (end - start > 1) { // binary search
7604
+ let mid = (start + end) >>> 1;
7605
+ if (value < acc[mid]) {
7606
+ end = mid;
7607
+ } else {
7608
+ start = mid;
7609
+ }
7610
+ }
7611
+ if (start == 0) break; // first symbol is end mark
7612
+ symbols.push(start);
7613
+ let a = low + Math.floor(range * acc[start] / total);
7614
+ let b = low + Math.floor(range * acc[start+1] / total) - 1;
7615
+ while (((a ^ b) & HALF) == 0) {
7616
+ register = (register << 1) & MASK | read_bit();
7617
+ a = (a << 1) & MASK;
7618
+ b = (b << 1) & MASK | 1;
7619
+ }
7620
+ while (a & ~b & QRTR) {
7621
+ register = (register & HALF) | ((register << 1) & (MASK >>> 1)) | read_bit();
7622
+ a = (a << 1) ^ HALF;
7623
+ b = ((b ^ HALF) << 1) | HALF | 1;
7624
+ }
7625
+ low = a;
7626
+ range = 1 + b - a;
7627
+ }
7628
+ let offset = symbol_count - 4;
7629
+ return symbols.map(x => { // index into payload
7630
+ switch (x - offset) {
7631
+ case 3: return offset + 0x10100 + ((bytes[pos_payload++] << 16) | (bytes[pos_payload++] << 8) | bytes[pos_payload++]);
7632
+ case 2: return offset + 0x100 + ((bytes[pos_payload++] << 8) | bytes[pos_payload++]);
7633
+ case 1: return offset + bytes[pos_payload++];
7634
+ default: return x - 1;
7635
+ }
7636
+ });
7637
+ }
7638
+
7639
+ // returns an iterator which returns the next symbol
7640
+ function read_payload(v) {
7641
+ let pos = 0;
7642
+ return () => v[pos++];
7643
+ }
7644
+ function read_compressed_payload(s) {
7645
+ return read_payload(decode_arithmetic(unsafe_atob(s)));
7646
+ }
7647
+
7648
+ // unsafe in the sense:
7649
+ // expected well-formed Base64 w/o padding
7650
+ // 20220922: added for https://github.com/adraffy/ens-normalize.js/issues/4
7651
+ function unsafe_atob(s) {
7652
+ let lookup = [];
7653
+ [...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'].forEach((c, i) => lookup[c.charCodeAt(0)] = i);
7654
+ let n = s.length;
7655
+ let ret = new Uint8Array((6 * n) >> 3);
7656
+ for (let i = 0, pos = 0, width = 0, carry = 0; i < n; i++) {
7657
+ carry = (carry << 6) | lookup[s.charCodeAt(i)];
7658
+ width += 6;
7659
+ if (width >= 8) {
7660
+ ret[pos++] = (carry >> (width -= 8));
7661
+ }
7662
+ }
7663
+ return ret;
7664
+ }
7665
+
7666
+ // eg. [0,1,2,3...] => [0,-1,1,-2,...]
7667
+ function signed(i) {
7668
+ return (i & 1) ? (~i >> 1) : (i >> 1);
7669
+ }
7670
+
7671
+ function read_deltas(n, next) {
7672
+ let v = Array(n);
7673
+ for (let i = 0, x = 0; i < n; i++) v[i] = x += signed(next());
7674
+ return v;
7675
+ }
7676
+
7677
+ // [123][5] => [0 3] [1 1] [0 0]
7678
+ function read_sorted(next, prev = 0) {
7679
+ let ret = [];
7680
+ while (true) {
7681
+ let x = next();
7682
+ let n = next();
7683
+ if (!n) break;
7684
+ prev += x;
7685
+ for (let i = 0; i < n; i++) {
7686
+ ret.push(prev + i);
7687
+ }
7688
+ prev += n + 1;
7689
+ }
7690
+ return ret;
7691
+ }
7692
+
7693
+ function read_sorted_arrays(next) {
7694
+ return read_array_while(() => {
7695
+ let v = read_sorted(next);
7696
+ if (v.length) return v;
7697
+ });
7698
+ }
7699
+
7700
+ // returns map of x => ys
7701
+ function read_mapped(next) {
7702
+ let ret = [];
7703
+ while (true) {
7704
+ let w = next();
7705
+ if (w == 0) break;
7706
+ ret.push(read_linear_table(w, next));
7707
+ }
7708
+ while (true) {
7709
+ let w = next() - 1;
7710
+ if (w < 0) break;
7711
+ ret.push(read_replacement_table(w, next));
7712
+ }
7713
+ return ret.flat();
7714
+ }
7715
+
7716
+ // read until next is falsy
7717
+ // return array of read values
7718
+ function read_array_while(next) {
7719
+ let v = [];
7720
+ while (true) {
7721
+ let x = next(v.length);
7722
+ if (!x) break;
7723
+ v.push(x);
7724
+ }
7725
+ return v;
7726
+ }
7727
+
7728
+ // read w columns of length n
7729
+ // return as n rows of length w
7730
+ function read_transposed(n, w, next) {
7731
+ let m = Array(n).fill().map(() => []);
7732
+ for (let i = 0; i < w; i++) {
7733
+ read_deltas(n, next).forEach((x, j) => m[j].push(x));
7734
+ }
7735
+ return m;
7736
+ }
7737
+
7738
+ // returns [[x, ys], [x+dx, ys+dy], [x+2*dx, ys+2*dy], ...]
7739
+ // where dx/dy = steps, n = run size, w = length of y
7740
+ function read_linear_table(w, next) {
7741
+ let dx = 1 + next();
7742
+ let dy = next();
7743
+ let vN = read_array_while(next);
7744
+ let m = read_transposed(vN.length, 1+w, next);
7745
+ return m.flatMap((v, i) => {
7746
+ let [x, ...ys] = v;
7747
+ return Array(vN[i]).fill().map((_, j) => {
7748
+ let j_dy = j * dy;
7749
+ return [x + j * dx, ys.map(y => y + j_dy)];
7750
+ });
7751
+ });
7752
+ }
7753
+
7754
+ // return [[x, ys...], ...]
7755
+ // where w = length of y
7756
+ function read_replacement_table(w, next) {
7757
+ let n = 1 + next();
7758
+ let m = read_transposed(n, 1+w, next);
7759
+ return m.map(v => [v[0], v.slice(1)]);
7760
+ }
7761
+
7762
+
7763
+ function read_trie(next) {
7764
+ let ret = [];
7765
+ let sorted = read_sorted(next);
7766
+ expand(decode([]), []);
7767
+ return ret; // not sorted
7768
+ function decode(Q) { // characters that lead into this node
7769
+ let S = next(); // state: valid, save, check
7770
+ let B = read_array_while(() => { // buckets leading to new nodes
7771
+ let cps = read_sorted(next).map(i => sorted[i]);
7772
+ if (cps.length) return decode(cps);
7773
+ });
7774
+ return {S, B, Q};
7775
+ }
7776
+ function expand({S, B}, cps, saved) {
7777
+ if (S & 4 && saved === cps[cps.length-1]) return;
7778
+ if (S & 2) saved = cps[cps.length-1];
7779
+ if (S & 1) ret.push(cps);
7780
+ for (let br of B) {
7781
+ for (let cp of br.Q) {
7782
+ expand(br, [...cps, cp], saved);
7783
+ }
7784
+ }
7785
+ }
7850
7786
  }
7851
7787
 
7852
- // unsafe in the sense:
7853
- // expected well-formed Base64 w/o padding
7854
- // 20220922: added for https://github.com/adraffy/ens-normalize.js/issues/4
7855
- function unsafe_atob(s) {
7856
- let lookup = [];
7857
- [...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'].forEach((c, i) => lookup[c.charCodeAt(0)] = i);
7858
- let n = s.length;
7859
- let ret = new Uint8Array((6 * n) >> 3);
7860
- for (let i = 0, pos = 0, width = 0, carry = 0; i < n; i++) {
7861
- carry = (carry << 6) | lookup[s.charCodeAt(i)];
7862
- width += 6;
7863
- if (width >= 8) {
7864
- ret[pos++] = (carry >> (width -= 8));
7865
- }
7866
- }
7867
- return ret;
7868
- }
7869
-
7870
- // eg. [0,1,2,3...] => [0,-1,1,-2,...]
7871
- function signed(i) {
7872
- return (i & 1) ? (~i >> 1) : (i >> 1);
7873
- }
7874
-
7875
- function read_deltas(n, next) {
7876
- let v = Array(n);
7877
- for (let i = 0, x = 0; i < n; i++) v[i] = x += signed(next());
7878
- return v;
7879
- }
7880
-
7881
- // [123][5] => [0 3] [1 1] [0 0]
7882
- function read_sorted(next, prev = 0) {
7883
- let ret = [];
7884
- while (true) {
7885
- let x = next();
7886
- let n = next();
7887
- if (!n) break;
7888
- prev += x;
7889
- for (let i = 0; i < n; i++) {
7890
- ret.push(prev + i);
7891
- }
7892
- prev += n + 1;
7893
- }
7894
- return ret;
7895
- }
7896
-
7897
- function read_sorted_arrays(next) {
7898
- return read_array_while(() => {
7899
- let v = read_sorted(next);
7900
- if (v.length) return v;
7901
- });
7902
- }
7903
-
7904
- // returns map of x => ys
7905
- function read_mapped(next) {
7906
- let ret = [];
7907
- while (true) {
7908
- let w = next();
7909
- if (w == 0) break;
7910
- ret.push(read_linear_table(w, next));
7911
- }
7912
- while (true) {
7913
- let w = next() - 1;
7914
- if (w < 0) break;
7915
- ret.push(read_replacement_table(w, next));
7916
- }
7917
- return ret.flat();
7918
- }
7919
-
7920
- // read until next is falsy
7921
- // return array of read values
7922
- function read_array_while(next) {
7923
- let v = [];
7924
- while (true) {
7925
- let x = next(v.length);
7926
- if (!x) break;
7927
- v.push(x);
7928
- }
7929
- return v;
7930
- }
7931
-
7932
- // read w columns of length n
7933
- // return as n rows of length w
7934
- function read_transposed(n, w, next) {
7935
- let m = Array(n).fill().map(() => []);
7936
- for (let i = 0; i < w; i++) {
7937
- read_deltas(n, next).forEach((x, j) => m[j].push(x));
7938
- }
7939
- return m;
7940
- }
7941
-
7942
- // returns [[x, ys], [x+dx, ys+dy], [x+2*dx, ys+2*dy], ...]
7943
- // where dx/dy = steps, n = run size, w = length of y
7944
- function read_linear_table(w, next) {
7945
- let dx = 1 + next();
7946
- let dy = next();
7947
- let vN = read_array_while(next);
7948
- let m = read_transposed(vN.length, 1+w, next);
7949
- return m.flatMap((v, i) => {
7950
- let [x, ...ys] = v;
7951
- return Array(vN[i]).fill().map((_, j) => {
7952
- let j_dy = j * dy;
7953
- return [x + j * dx, ys.map(y => y + j_dy)];
7954
- });
7955
- });
7956
- }
7957
-
7958
- // return [[x, ys...], ...]
7959
- // where w = length of y
7960
- function read_replacement_table(w, next) {
7961
- let n = 1 + next();
7962
- let m = read_transposed(n, 1+w, next);
7963
- return m.map(v => [v[0], v.slice(1)]);
7964
- }
7965
-
7966
-
7967
- function read_trie(next) {
7968
- let ret = [];
7969
- let sorted = read_sorted(next);
7970
- expand(decode([]), []);
7971
- return ret; // not sorted
7972
- function decode(Q) { // characters that lead into this node
7973
- let S = next(); // state: valid, save, check
7974
- let B = read_array_while(() => { // buckets leading to new nodes
7975
- let cps = read_sorted(next).map(i => sorted[i]);
7976
- if (cps.length) return decode(cps);
7977
- });
7978
- return {S, B, Q};
7979
- }
7980
- function expand({S, B}, cps, saved) {
7981
- if (S & 4 && saved === cps[cps.length-1]) return;
7982
- if (S & 2) saved = cps[cps.length-1];
7983
- if (S & 1) ret.push(cps);
7984
- for (let br of B) {
7985
- for (let cp of br.Q) {
7986
- expand(br, [...cps, cp], saved);
7987
- }
7988
- }
7989
- }
7990
- }
7991
-
7992
- function hex_cp(cp) {
7993
- return cp.toString(16).toUpperCase().padStart(2, '0');
7994
- }
7995
-
7996
- function quote_cp(cp) {
7997
- return `{${hex_cp(cp)}}`; // raffy convention: like "\u{X}" w/o the "\u"
7998
- }
7999
-
8000
- /*
8001
- export function explode_cp(s) {
8002
- return [...s].map(c => c.codePointAt(0));
8003
- }
8004
- */
8005
- function explode_cp(s) { // this is about 2x faster
8006
- let cps = [];
8007
- for (let pos = 0, len = s.length; pos < len; ) {
8008
- let cp = s.codePointAt(pos);
8009
- pos += cp < 0x10000 ? 1 : 2;
8010
- cps.push(cp);
8011
- }
8012
- return cps;
8013
- }
8014
-
8015
- function str_from_cps(cps) {
8016
- const chunk = 4096;
8017
- let len = cps.length;
8018
- if (len < chunk) return String.fromCodePoint(...cps);
8019
- let buf = [];
8020
- for (let i = 0; i < len; ) {
8021
- buf.push(String.fromCodePoint(...cps.slice(i, i += chunk)));
8022
- }
8023
- return buf.join('');
8024
- }
8025
-
8026
- function compare_arrays(a, b) {
8027
- let n = a.length;
8028
- let c = n - b.length;
8029
- for (let i = 0; c == 0 && i < n; i++) c = a[i] - b[i];
8030
- return c;
7788
+ function hex_cp(cp) {
7789
+ return cp.toString(16).toUpperCase().padStart(2, '0');
7790
+ }
7791
+
7792
+ function quote_cp(cp) {
7793
+ return `{${hex_cp(cp)}}`; // raffy convention: like "\u{X}" w/o the "\u"
7794
+ }
7795
+
7796
+ /*
7797
+ export function explode_cp(s) {
7798
+ return [...s].map(c => c.codePointAt(0));
7799
+ }
7800
+ */
7801
+ function explode_cp(s) { // this is about 2x faster
7802
+ let cps = [];
7803
+ for (let pos = 0, len = s.length; pos < len; ) {
7804
+ let cp = s.codePointAt(pos);
7805
+ pos += cp < 0x10000 ? 1 : 2;
7806
+ cps.push(cp);
7807
+ }
7808
+ return cps;
7809
+ }
7810
+
7811
+ function str_from_cps(cps) {
7812
+ const chunk = 4096;
7813
+ let len = cps.length;
7814
+ if (len < chunk) return String.fromCodePoint(...cps);
7815
+ let buf = [];
7816
+ for (let i = 0; i < len; ) {
7817
+ buf.push(String.fromCodePoint(...cps.slice(i, i += chunk)));
7818
+ }
7819
+ return buf.join('');
7820
+ }
7821
+
7822
+ function compare_arrays(a, b) {
7823
+ let n = a.length;
7824
+ let c = n - b.length;
7825
+ for (let i = 0; c == 0 && i < n; i++) c = a[i] - b[i];
7826
+ return c;
8031
7827
  }
8032
7828
 
8033
7829
  // created 2023-09-25T01:01:55.148Z
@@ -8037,786 +7833,786 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
8037
7833
  // SHA-256: a974b6f8541fc29d919bc85118af0a44015851fab5343f8679cb31be2bdb209e
8038
7834
  var COMPRESSED = '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';
8039
7835
 
8040
- // https://unicode.org/reports/tr15/
8041
- // for reference implementation
8042
- // see: /derive/nf.js
8043
-
8044
-
8045
- // algorithmic hangul
8046
- // https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf (page 144)
8047
- const S0 = 0xAC00;
8048
- const L0 = 0x1100;
8049
- const V0 = 0x1161;
8050
- const T0 = 0x11A7;
8051
- const L_COUNT = 19;
8052
- const V_COUNT = 21;
8053
- const T_COUNT = 28;
8054
- const N_COUNT = V_COUNT * T_COUNT;
8055
- const S_COUNT = L_COUNT * N_COUNT;
8056
- const S1 = S0 + S_COUNT;
8057
- const L1 = L0 + L_COUNT;
8058
- const V1 = V0 + V_COUNT;
8059
- const T1 = T0 + T_COUNT;
8060
-
8061
- function unpack_cc(packed) {
8062
- return (packed >> 24) & 0xFF;
8063
- }
8064
- function unpack_cp(packed) {
8065
- return packed & 0xFFFFFF;
8066
- }
8067
-
8068
- let SHIFTED_RANK, EXCLUSIONS, DECOMP, RECOMP;
8069
-
8070
- function init$1() {
8071
- //console.time('nf');
8072
- let r = read_compressed_payload(COMPRESSED);
8073
- SHIFTED_RANK = new Map(read_sorted_arrays(r).flatMap((v, i) => v.map(x => [x, (i+1) << 24]))); // pre-shifted
8074
- EXCLUSIONS = new Set(read_sorted(r));
8075
- DECOMP = new Map();
8076
- RECOMP = new Map();
8077
- for (let [cp, cps] of read_mapped(r)) {
8078
- if (!EXCLUSIONS.has(cp) && cps.length == 2) {
8079
- let [a, b] = cps;
8080
- let bucket = RECOMP.get(a);
8081
- if (!bucket) {
8082
- bucket = new Map();
8083
- RECOMP.set(a, bucket);
8084
- }
8085
- bucket.set(b, cp);
8086
- }
8087
- DECOMP.set(cp, cps.reverse()); // stored reversed
8088
- }
8089
- //console.timeEnd('nf');
8090
- // 20230905: 11ms
8091
- }
8092
-
8093
- function is_hangul(cp) {
8094
- return cp >= S0 && cp < S1;
8095
- }
8096
-
8097
- function compose_pair(a, b) {
8098
- if (a >= L0 && a < L1 && b >= V0 && b < V1) {
8099
- return S0 + (a - L0) * N_COUNT + (b - V0) * T_COUNT;
8100
- } else if (is_hangul(a) && b > T0 && b < T1 && (a - S0) % T_COUNT == 0) {
8101
- return a + (b - T0);
8102
- } else {
8103
- let recomp = RECOMP.get(a);
8104
- if (recomp) {
8105
- recomp = recomp.get(b);
8106
- if (recomp) {
8107
- return recomp;
8108
- }
8109
- }
8110
- return -1;
8111
- }
7836
+ // https://unicode.org/reports/tr15/
7837
+ // for reference implementation
7838
+ // see: /derive/nf.js
7839
+
7840
+
7841
+ // algorithmic hangul
7842
+ // https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf (page 144)
7843
+ const S0 = 0xAC00;
7844
+ const L0 = 0x1100;
7845
+ const V0 = 0x1161;
7846
+ const T0 = 0x11A7;
7847
+ const L_COUNT = 19;
7848
+ const V_COUNT = 21;
7849
+ const T_COUNT = 28;
7850
+ const N_COUNT = V_COUNT * T_COUNT;
7851
+ const S_COUNT = L_COUNT * N_COUNT;
7852
+ const S1 = S0 + S_COUNT;
7853
+ const L1 = L0 + L_COUNT;
7854
+ const V1 = V0 + V_COUNT;
7855
+ const T1 = T0 + T_COUNT;
7856
+
7857
+ function unpack_cc(packed) {
7858
+ return (packed >> 24) & 0xFF;
7859
+ }
7860
+ function unpack_cp(packed) {
7861
+ return packed & 0xFFFFFF;
7862
+ }
7863
+
7864
+ let SHIFTED_RANK, EXCLUSIONS, DECOMP, RECOMP;
7865
+
7866
+ function init$1() {
7867
+ //console.time('nf');
7868
+ let r = read_compressed_payload(COMPRESSED);
7869
+ SHIFTED_RANK = new Map(read_sorted_arrays(r).flatMap((v, i) => v.map(x => [x, (i+1) << 24]))); // pre-shifted
7870
+ EXCLUSIONS = new Set(read_sorted(r));
7871
+ DECOMP = new Map();
7872
+ RECOMP = new Map();
7873
+ for (let [cp, cps] of read_mapped(r)) {
7874
+ if (!EXCLUSIONS.has(cp) && cps.length == 2) {
7875
+ let [a, b] = cps;
7876
+ let bucket = RECOMP.get(a);
7877
+ if (!bucket) {
7878
+ bucket = new Map();
7879
+ RECOMP.set(a, bucket);
7880
+ }
7881
+ bucket.set(b, cp);
7882
+ }
7883
+ DECOMP.set(cp, cps.reverse()); // stored reversed
7884
+ }
7885
+ //console.timeEnd('nf');
7886
+ // 20230905: 11ms
7887
+ }
7888
+
7889
+ function is_hangul(cp) {
7890
+ return cp >= S0 && cp < S1;
7891
+ }
7892
+
7893
+ function compose_pair(a, b) {
7894
+ if (a >= L0 && a < L1 && b >= V0 && b < V1) {
7895
+ return S0 + (a - L0) * N_COUNT + (b - V0) * T_COUNT;
7896
+ } else if (is_hangul(a) && b > T0 && b < T1 && (a - S0) % T_COUNT == 0) {
7897
+ return a + (b - T0);
7898
+ } else {
7899
+ let recomp = RECOMP.get(a);
7900
+ if (recomp) {
7901
+ recomp = recomp.get(b);
7902
+ if (recomp) {
7903
+ return recomp;
7904
+ }
7905
+ }
7906
+ return -1;
7907
+ }
7908
+ }
7909
+
7910
+ function decomposed(cps) {
7911
+ if (!SHIFTED_RANK) init$1();
7912
+ let ret = [];
7913
+ let buf = [];
7914
+ let check_order = false;
7915
+ function add(cp) {
7916
+ let cc = SHIFTED_RANK.get(cp);
7917
+ if (cc) {
7918
+ check_order = true;
7919
+ cp |= cc;
7920
+ }
7921
+ ret.push(cp);
7922
+ }
7923
+ for (let cp of cps) {
7924
+ while (true) {
7925
+ if (cp < 0x80) {
7926
+ ret.push(cp);
7927
+ } else if (is_hangul(cp)) {
7928
+ let s_index = cp - S0;
7929
+ let l_index = s_index / N_COUNT | 0;
7930
+ let v_index = (s_index % N_COUNT) / T_COUNT | 0;
7931
+ let t_index = s_index % T_COUNT;
7932
+ add(L0 + l_index);
7933
+ add(V0 + v_index);
7934
+ if (t_index > 0) add(T0 + t_index);
7935
+ } else {
7936
+ let mapped = DECOMP.get(cp);
7937
+ if (mapped) {
7938
+ buf.push(...mapped);
7939
+ } else {
7940
+ add(cp);
7941
+ }
7942
+ }
7943
+ if (!buf.length) break;
7944
+ cp = buf.pop();
7945
+ }
7946
+ }
7947
+ if (check_order && ret.length > 1) {
7948
+ let prev_cc = unpack_cc(ret[0]);
7949
+ for (let i = 1; i < ret.length; i++) {
7950
+ let cc = unpack_cc(ret[i]);
7951
+ if (cc == 0 || prev_cc <= cc) {
7952
+ prev_cc = cc;
7953
+ continue;
7954
+ }
7955
+ let j = i-1;
7956
+ while (true) {
7957
+ let tmp = ret[j+1];
7958
+ ret[j+1] = ret[j];
7959
+ ret[j] = tmp;
7960
+ if (!j) break;
7961
+ prev_cc = unpack_cc(ret[--j]);
7962
+ if (prev_cc <= cc) break;
7963
+ }
7964
+ prev_cc = unpack_cc(ret[i]);
7965
+ }
7966
+ }
7967
+ return ret;
7968
+ }
7969
+
7970
+ function composed_from_decomposed(v) {
7971
+ let ret = [];
7972
+ let stack = [];
7973
+ let prev_cp = -1;
7974
+ let prev_cc = 0;
7975
+ for (let packed of v) {
7976
+ let cc = unpack_cc(packed);
7977
+ let cp = unpack_cp(packed);
7978
+ if (prev_cp == -1) {
7979
+ if (cc == 0) {
7980
+ prev_cp = cp;
7981
+ } else {
7982
+ ret.push(cp);
7983
+ }
7984
+ } else if (prev_cc > 0 && prev_cc >= cc) {
7985
+ if (cc == 0) {
7986
+ ret.push(prev_cp, ...stack);
7987
+ stack.length = 0;
7988
+ prev_cp = cp;
7989
+ } else {
7990
+ stack.push(cp);
7991
+ }
7992
+ prev_cc = cc;
7993
+ } else {
7994
+ let composed = compose_pair(prev_cp, cp);
7995
+ if (composed >= 0) {
7996
+ prev_cp = composed;
7997
+ } else if (prev_cc == 0 && cc == 0) {
7998
+ ret.push(prev_cp);
7999
+ prev_cp = cp;
8000
+ } else {
8001
+ stack.push(cp);
8002
+ prev_cc = cc;
8003
+ }
8004
+ }
8005
+ }
8006
+ if (prev_cp >= 0) {
8007
+ ret.push(prev_cp, ...stack);
8008
+ }
8009
+ return ret;
8010
+ }
8011
+
8012
+ // note: cps can be iterable
8013
+ function nfd(cps) {
8014
+ return decomposed(cps).map(unpack_cp);
8015
+ }
8016
+ function nfc(cps) {
8017
+ return composed_from_decomposed(decomposed(cps));
8112
8018
  }
8113
8019
 
8114
- function decomposed(cps) {
8115
- if (!SHIFTED_RANK) init$1();
8116
- let ret = [];
8117
- let buf = [];
8118
- let check_order = false;
8119
- function add(cp) {
8120
- let cc = SHIFTED_RANK.get(cp);
8121
- if (cc) {
8122
- check_order = true;
8123
- cp |= cc;
8124
- }
8125
- ret.push(cp);
8126
- }
8127
- for (let cp of cps) {
8128
- while (true) {
8129
- if (cp < 0x80) {
8130
- ret.push(cp);
8131
- } else if (is_hangul(cp)) {
8132
- let s_index = cp - S0;
8133
- let l_index = s_index / N_COUNT | 0;
8134
- let v_index = (s_index % N_COUNT) / T_COUNT | 0;
8135
- let t_index = s_index % T_COUNT;
8136
- add(L0 + l_index);
8137
- add(V0 + v_index);
8138
- if (t_index > 0) add(T0 + t_index);
8139
- } else {
8140
- let mapped = DECOMP.get(cp);
8141
- if (mapped) {
8142
- buf.push(...mapped);
8143
- } else {
8144
- add(cp);
8145
- }
8146
- }
8147
- if (!buf.length) break;
8148
- cp = buf.pop();
8149
- }
8150
- }
8151
- if (check_order && ret.length > 1) {
8152
- let prev_cc = unpack_cc(ret[0]);
8153
- for (let i = 1; i < ret.length; i++) {
8154
- let cc = unpack_cc(ret[i]);
8155
- if (cc == 0 || prev_cc <= cc) {
8156
- prev_cc = cc;
8157
- continue;
8158
- }
8159
- let j = i-1;
8160
- while (true) {
8161
- let tmp = ret[j+1];
8162
- ret[j+1] = ret[j];
8163
- ret[j] = tmp;
8164
- if (!j) break;
8165
- prev_cc = unpack_cc(ret[--j]);
8166
- if (prev_cc <= cc) break;
8167
- }
8168
- prev_cc = unpack_cc(ret[i]);
8169
- }
8170
- }
8171
- return ret;
8172
- }
8173
-
8174
- function composed_from_decomposed(v) {
8175
- let ret = [];
8176
- let stack = [];
8177
- let prev_cp = -1;
8178
- let prev_cc = 0;
8179
- for (let packed of v) {
8180
- let cc = unpack_cc(packed);
8181
- let cp = unpack_cp(packed);
8182
- if (prev_cp == -1) {
8183
- if (cc == 0) {
8184
- prev_cp = cp;
8185
- } else {
8186
- ret.push(cp);
8187
- }
8188
- } else if (prev_cc > 0 && prev_cc >= cc) {
8189
- if (cc == 0) {
8190
- ret.push(prev_cp, ...stack);
8191
- stack.length = 0;
8192
- prev_cp = cp;
8193
- } else {
8194
- stack.push(cp);
8195
- }
8196
- prev_cc = cc;
8197
- } else {
8198
- let composed = compose_pair(prev_cp, cp);
8199
- if (composed >= 0) {
8200
- prev_cp = composed;
8201
- } else if (prev_cc == 0 && cc == 0) {
8202
- ret.push(prev_cp);
8203
- prev_cp = cp;
8204
- } else {
8205
- stack.push(cp);
8206
- prev_cc = cc;
8207
- }
8208
- }
8209
- }
8210
- if (prev_cp >= 0) {
8211
- ret.push(prev_cp, ...stack);
8212
- }
8213
- return ret;
8214
- }
8215
-
8216
- // note: cps can be iterable
8217
- function nfd(cps) {
8218
- return decomposed(cps).map(unpack_cp);
8219
- }
8220
- function nfc(cps) {
8221
- return composed_from_decomposed(decomposed(cps));
8222
- }
8223
-
8224
- const HYPHEN = 0x2D;
8225
- const STOP_CH = '.';
8226
- const FE0F = 0xFE0F;
8227
- const UNIQUE_PH = 1;
8228
-
8229
- // 20230913: replace [...v] with Array_from(v) to avoid large spreads
8230
- const Array_from = x => Array.from(x); // Array.from.bind(Array);
8231
-
8232
- function group_has_cp(g, cp) {
8233
- // 20230913: keep primary and secondary distinct instead of creating valid union
8234
- return g.P.has(cp) || g.Q.has(cp);
8235
- }
8236
-
8237
- class Emoji extends Array {
8238
- get is_emoji() { return true; } // free tagging system
8239
- }
8240
-
8241
- let MAPPED, IGNORED, CM, NSM, ESCAPE, GROUPS, WHOLE_VALID, WHOLE_MAP, VALID, EMOJI_LIST, EMOJI_ROOT;
8242
-
8243
- function init() {
8244
- if (MAPPED) return;
8245
-
8246
- let r = read_compressed_payload(COMPRESSED$1);
8247
- const read_sorted_array = () => read_sorted(r);
8248
- const read_sorted_set = () => new Set(read_sorted_array());
8249
- const set_add_many = (set, v) => v.forEach(x => set.add(x));
8250
-
8251
- MAPPED = new Map(read_mapped(r));
8252
- IGNORED = read_sorted_set(); // ignored characters are not valid, so just read raw codepoints
8253
-
8254
- /*
8255
- // direct include from payload is smaller than the decompression code
8256
- const FENCED = new Map(read_array_while(() => {
8257
- let cp = r();
8258
- if (cp) return [cp, read_str(r())];
8259
- }));
8260
- */
8261
- // 20230217: we still need all CM for proper error formatting
8262
- // but norm only needs NSM subset that are potentially-valid
8263
- CM = read_sorted_array();
8264
- NSM = new Set(read_sorted_array().map(i => CM[i]));
8265
- CM = new Set(CM);
8266
-
8267
- ESCAPE = read_sorted_set(); // characters that should not be printed
8268
- read_sorted_set(); // only needed to illustrate ens_tokenize() transformations
8269
-
8270
- let chunks = read_sorted_arrays(r);
8271
- let unrestricted = r();
8272
- //const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array()));
8273
- const read_chunked = () => {
8274
- // 20230921: build set in parts, 2x faster
8275
- let set = new Set();
8276
- read_sorted_array().forEach(i => set_add_many(set, chunks[i]));
8277
- set_add_many(set, read_sorted_array());
8278
- return set;
8279
- };
8280
- GROUPS = read_array_while(i => {
8281
- // minifier property mangling seems unsafe
8282
- // so these are manually renamed to single chars
8283
- let N = read_array_while(r).map(x => x+0x60);
8284
- if (N.length) {
8285
- let R = i >= unrestricted; // unrestricted then restricted
8286
- N[0] -= 32; // capitalize
8287
- N = str_from_cps(N);
8288
- if (R) N=`Restricted[${N}]`;
8289
- let P = read_chunked(); // primary
8290
- let Q = read_chunked(); // secondary
8291
- let M = !r(); // not-whitelisted, check for NSM
8292
- // *** this code currently isn't needed ***
8293
- /*
8294
- let V = [...P, ...Q].sort((a, b) => a-b); // derive: sorted valid
8295
- let M = r()-1; // number of combining mark
8296
- if (M < 0) { // whitelisted
8297
- M = new Map(read_array_while(() => {
8298
- let i = r();
8299
- if (i) return [V[i-1], read_array_while(() => {
8300
- let v = read_array_while(r);
8301
- if (v.length) return v.map(x => x-1);
8302
- })];
8303
- }));
8304
- }*/
8305
- return {N, P, Q, M, R};
8306
- }
8307
- });
8308
-
8309
- // decode compressed wholes
8310
- WHOLE_VALID = read_sorted_set();
8311
- WHOLE_MAP = new Map();
8312
- let wholes = read_sorted_array().concat(Array_from(WHOLE_VALID)).sort((a, b) => a-b); // must be sorted
8313
- wholes.forEach((cp, i) => {
8314
- let d = r();
8315
- let w = wholes[i] = d ? wholes[i-d] : {V: [], M: new Map()};
8316
- w.V.push(cp); // add to member set
8317
- if (!WHOLE_VALID.has(cp)) {
8318
- WHOLE_MAP.set(cp, w); // register with whole map
8319
- }
8320
- });
8321
-
8322
- // compute confusable-extent complements
8323
- // usage: WHOLE_MAP.get(cp).M.get(cp) = complement set
8324
- for (let {V, M} of new Set(WHOLE_MAP.values())) {
8325
- // connect all groups that have each whole character
8326
- let recs = [];
8327
- for (let cp of V) {
8328
- let gs = GROUPS.filter(g => group_has_cp(g, cp));
8329
- let rec = recs.find(({G}) => gs.some(g => G.has(g)));
8330
- if (!rec) {
8331
- rec = {G: new Set(), V: []};
8332
- recs.push(rec);
8333
- }
8334
- rec.V.push(cp);
8335
- set_add_many(rec.G, gs);
8336
- }
8337
- // per character cache groups which are not a member of the extent
8338
- let union = recs.flatMap(x => Array_from(x.G)); // all of the groups used by this whole
8339
- for (let {G, V} of recs) {
8340
- let complement = new Set(union.filter(g => !G.has(g))); // groups not covered by the extent
8341
- for (let cp of V) {
8342
- M.set(cp, complement); // this is the same reference
8343
- }
8344
- }
8345
- }
8346
-
8347
- // compute valid set
8348
- // 20230924: VALID was union but can be re-used
8349
- VALID = new Set(); // exists in 1+ groups
8350
- let multi = new Set(); // exists in 2+ groups
8351
- const add_to_union = cp => VALID.has(cp) ? multi.add(cp) : VALID.add(cp);
8352
- for (let g of GROUPS) {
8353
- for (let cp of g.P) add_to_union(cp);
8354
- for (let cp of g.Q) add_to_union(cp);
8355
- }
8356
- // dual purpose WHOLE_MAP: return placeholder if unique non-confusable
8357
- for (let cp of VALID) {
8358
- if (!WHOLE_MAP.has(cp) && !multi.has(cp)) {
8359
- WHOLE_MAP.set(cp, UNIQUE_PH);
8360
- }
8361
- }
8362
- // add all decomposed parts
8363
- // see derive: "Valid is Closed (via Brute-force)"
8364
- set_add_many(VALID, nfd(VALID));
8365
-
8366
- // decode emoji
8367
- // 20230719: emoji are now fully-expanded to avoid quirk logic
8368
- EMOJI_LIST = read_trie(r).map(v => Emoji.from(v)).sort(compare_arrays);
8369
- EMOJI_ROOT = new Map(); // this has approx 7K nodes (2+ per emoji)
8370
- for (let cps of EMOJI_LIST) {
8371
- // 20230719: change to *slightly* stricter algorithm which disallows
8372
- // insertion of misplaced FE0F in emoji sequences (matching ENSIP-15)
8373
- // example: beautified [A B] (eg. flag emoji)
8374
- // before: allow: [A FE0F B], error: [A FE0F FE0F B]
8375
- // after: error: both
8376
- // note: this code now matches ENSNormalize.{cs,java} logic
8377
- let prev = [EMOJI_ROOT];
8378
- for (let cp of cps) {
8379
- let next = prev.map(node => {
8380
- let child = node.get(cp);
8381
- if (!child) {
8382
- // should this be object?
8383
- // (most have 1-2 items, few have many)
8384
- // 20230719: no, v8 default map is 4?
8385
- child = new Map();
8386
- node.set(cp, child);
8387
- }
8388
- return child;
8389
- });
8390
- if (cp === FE0F) {
8391
- prev.push(...next); // less than 20 elements
8392
- } else {
8393
- prev = next;
8394
- }
8395
- }
8396
- for (let x of prev) {
8397
- x.V = cps;
8398
- }
8399
- }
8400
- }
8401
-
8402
- // if escaped: {HEX}
8403
- // else: "x" {HEX}
8404
- function quoted_cp(cp) {
8405
- return (should_escape(cp) ? '' : `${bidi_qq(safe_str_from_cps([cp]))} `) + quote_cp(cp);
8406
- }
8407
-
8408
- // 20230211: some messages can be mixed-directional and result in spillover
8409
- // use 200E after a quoted string to force the remainder of a string from
8410
- // acquring the direction of the quote
8411
- // https://www.w3.org/International/questions/qa-bidi-unicode-controls#exceptions
8412
- function bidi_qq(s) {
8413
- return `"${s}"\u200E`; // strong LTR
8414
- }
8415
-
8416
- function check_label_extension(cps) {
8417
- if (cps.length >= 4 && cps[2] == HYPHEN && cps[3] == HYPHEN) {
8418
- throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`); // this can only be ascii so cant be bidi
8419
- }
8420
- }
8421
- function check_leading_underscore(cps) {
8422
- const UNDERSCORE = 0x5F;
8423
- for (let i = cps.lastIndexOf(UNDERSCORE); i > 0; ) {
8424
- if (cps[--i] !== UNDERSCORE) {
8425
- throw new Error('underscore allowed only at start');
8426
- }
8427
- }
8428
- }
8429
- // check that a fenced cp is not leading, trailing, or touching another fenced cp
8430
- function check_fenced(cps) {
8431
- let cp = cps[0];
8432
- let prev = FENCED.get(cp);
8433
- if (prev) throw error_placement(`leading ${prev}`);
8434
- let n = cps.length;
8435
- let last = -1; // prevents trailing from throwing
8436
- for (let i = 1; i < n; i++) {
8437
- cp = cps[i];
8438
- let match = FENCED.get(cp);
8439
- if (match) {
8440
- // since cps[0] isn't fenced, cps[1] cannot throw
8441
- if (last == i) throw error_placement(`${prev} + ${match}`);
8442
- last = i + 1;
8443
- prev = match;
8444
- }
8445
- }
8446
- if (last == n) throw error_placement(`trailing ${prev}`);
8447
- }
8448
-
8449
- // create a safe to print string
8450
- // invisibles are escaped
8451
- // leading cm uses placeholder
8452
- // if cps exceed max, middle truncate with ellipsis
8453
- // quoter(cp) => string, eg. 3000 => "{3000}"
8454
- // note: in html, you'd call this function then replace [<>&] with entities
8455
- function safe_str_from_cps(cps, max = Infinity, quoter = quote_cp) {
8456
- //if (Number.isInteger(cps)) cps = [cps];
8457
- //if (!Array.isArray(cps)) throw new TypeError(`expected codepoints`);
8458
- let buf = [];
8459
- if (is_combining_mark(cps[0])) buf.push('◌');
8460
- if (cps.length > max) {
8461
- max >>= 1;
8462
- cps = [...cps.slice(0, max), 0x2026, ...cps.slice(-max)];
8463
- }
8464
- let prev = 0;
8465
- let n = cps.length;
8466
- for (let i = 0; i < n; i++) {
8467
- let cp = cps[i];
8468
- if (should_escape(cp)) {
8469
- buf.push(str_from_cps(cps.slice(prev, i)));
8470
- buf.push(quoter(cp));
8471
- prev = i + 1;
8472
- }
8473
- }
8474
- buf.push(str_from_cps(cps.slice(prev, n)));
8475
- return buf.join('');
8476
- }
8477
-
8478
- // note: set(s) cannot be exposed because they can be modified
8479
- // note: Object.freeze() doesn't work
8480
- function is_combining_mark(cp) {
8481
- init();
8482
- return CM.has(cp);
8483
- }
8484
- function should_escape(cp) {
8485
- init();
8486
- return ESCAPE.has(cp);
8487
- }
8488
-
8489
- function ens_normalize(name) {
8490
- return flatten(split(name, nfc, filter_fe0f));
8491
- }
8492
-
8493
- function split(name, nf, ef) {
8494
- if (!name) return []; // 20230719: empty name allowance
8495
- init();
8496
- let offset = 0;
8497
- // https://unicode.org/reports/tr46/#Validity_Criteria
8498
- // 4.) "The label must not contain a U+002E ( . ) FULL STOP."
8499
- return name.split(STOP_CH).map(label => {
8500
- let input = explode_cp(label);
8501
- let info = {
8502
- input,
8503
- offset, // codepoint, not substring!
8504
- };
8505
- offset += input.length + 1; // + stop
8506
- try {
8507
- // 1.) "The label must be in Unicode Normalization Form NFC"
8508
- let tokens = info.tokens = tokens_from_str(input, nf, ef);
8509
- let token_count = tokens.length;
8510
- let type;
8511
- if (!token_count) { // the label was effectively empty (could of had ignored characters)
8512
- //norm = [];
8513
- //type = 'None'; // use this instead of next match, "ASCII"
8514
- // 20230120: change to strict
8515
- // https://discuss.ens.domains/t/ens-name-normalization-2nd/14564/59
8516
- throw new Error(`empty label`);
8517
- }
8518
- let norm = info.output = tokens.flat();
8519
- check_leading_underscore(norm);
8520
- let emoji = info.emoji = token_count > 1 || tokens[0].is_emoji; // same as: tokens.some(x => x.is_emoji);
8521
- if (!emoji && norm.every(cp => cp < 0x80)) { // special case for ascii
8522
- // 20230123: matches matches WHATWG, see note 3.3
8523
- check_label_extension(norm); // only needed for ascii
8524
- // cant have fenced
8525
- // cant have cm
8526
- // cant have wholes
8527
- // see derive: "Fastpath ASCII"
8528
- type = 'ASCII';
8529
- } else {
8530
- let chars = tokens.flatMap(x => x.is_emoji ? [] : x); // all of the nfc tokens concat together
8531
- if (!chars.length) { // theres no text, just emoji
8532
- type = 'Emoji';
8533
- } else {
8534
- // 5.) "The label must not begin with a combining mark, that is: General_Category=Mark."
8535
- if (CM.has(norm[0])) throw error_placement('leading combining mark');
8536
- for (let i = 1; i < token_count; i++) { // we've already checked the first token
8537
- let cps = tokens[i];
8538
- if (!cps.is_emoji && CM.has(cps[0])) { // every text token has emoji neighbors, eg. EtEEEtEt...
8539
- // bidi_qq() not needed since emoji is LTR and cps is a CM
8540
- throw error_placement(`emoji + combining mark: "${str_from_cps(tokens[i-1])} + ${safe_str_from_cps([cps[0]])}"`);
8541
- }
8542
- }
8543
- check_fenced(norm);
8544
- let unique = Array_from(new Set(chars));
8545
- let [g] = determine_group(unique); // take the first match
8546
- // see derive: "Matching Groups have Same CM Style"
8547
- // alternative: could form a hybrid type: Latin/Japanese/...
8548
- check_group(g, chars); // need text in order
8549
- check_whole(g, unique); // only need unique text (order would be required for multiple-char confusables)
8550
- type = g.N;
8551
- // 20230121: consider exposing restricted flag
8552
- // it's simpler to just check for 'Restricted'
8553
- // or even better: type.endsWith(']')
8554
- //if (g.R) info.restricted = true;
8555
- }
8556
- }
8557
- info.type = type;
8558
- } catch (err) {
8559
- info.error = err; // use full error object
8560
- }
8561
- return info;
8562
- });
8563
- }
8564
-
8565
- function check_whole(group, unique) {
8566
- let maker;
8567
- let shared = [];
8568
- for (let cp of unique) {
8569
- let whole = WHOLE_MAP.get(cp);
8570
- if (whole === UNIQUE_PH) return; // unique, non-confusable
8571
- if (whole) {
8572
- let set = whole.M.get(cp); // groups which have a character that look-like this character
8573
- maker = maker ? maker.filter(g => set.has(g)) : Array_from(set);
8574
- if (!maker.length) return; // confusable intersection is empty
8575
- } else {
8576
- shared.push(cp);
8577
- }
8578
- }
8579
- if (maker) {
8580
- // we have 1+ confusable
8581
- // check if any of the remaining groups
8582
- // contain the shared characters too
8583
- for (let g of maker) {
8584
- if (shared.every(cp => group_has_cp(g, cp))) {
8585
- throw new Error(`whole-script confusable: ${group.N}/${g.N}`);
8586
- }
8587
- }
8588
- }
8589
- }
8590
-
8591
- // assumption: unique.size > 0
8592
- // returns list of matching groups
8593
- function determine_group(unique) {
8594
- let groups = GROUPS;
8595
- for (let cp of unique) {
8596
- // note: we need to dodge CM that are whitelisted
8597
- // but that code isn't currently necessary
8598
- let gs = groups.filter(g => group_has_cp(g, cp));
8599
- if (!gs.length) {
8600
- if (!GROUPS.some(g => group_has_cp(g, cp))) {
8601
- // the character was composed of valid parts
8602
- // but it's NFC form is invalid
8603
- // 20230716: change to more exact statement, see: ENSNormalize.{cs,java}
8604
- // note: this doesn't have to be a composition
8605
- // 20230720: change to full check
8606
- throw error_disallowed(cp); // this should be rare
8607
- } else {
8608
- // there is no group that contains all these characters
8609
- // throw using the highest priority group that matched
8610
- // https://www.unicode.org/reports/tr39/#mixed_script_confusables
8611
- throw error_group_member(groups[0], cp);
8612
- }
8613
- }
8614
- groups = gs;
8615
- if (gs.length == 1) break; // there is only one group left
8616
- }
8617
- // there are at least 1 group(s) with all of these characters
8618
- return groups;
8619
- }
8620
-
8621
- // throw on first error
8622
- function flatten(split) {
8623
- return split.map(({input, error, output}) => {
8624
- if (error) {
8625
- // don't print label again if just a single label
8626
- let msg = error.message;
8627
- // bidi_qq() only necessary if msg is digits
8628
- throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input, 63))}: ${msg}`);
8629
- }
8630
- return str_from_cps(output);
8631
- }).join(STOP_CH);
8632
- }
8633
-
8634
- function error_disallowed(cp) {
8635
- // TODO: add cp to error?
8636
- return new Error(`disallowed character: ${quoted_cp(cp)}`);
8637
- }
8638
- function error_group_member(g, cp) {
8639
- let quoted = quoted_cp(cp);
8640
- let gg = GROUPS.find(g => g.P.has(cp)); // only check primary
8641
- if (gg) {
8642
- quoted = `${gg.N} ${quoted}`;
8643
- }
8644
- return new Error(`illegal mixture: ${g.N} + ${quoted}`);
8645
- }
8646
- function error_placement(where) {
8647
- return new Error(`illegal placement: ${where}`);
8648
- }
8649
-
8650
- // assumption: cps.length > 0
8651
- // assumption: cps[0] isn't a CM
8652
- // assumption: the previous character isn't an emoji
8653
- function check_group(g, cps) {
8654
- for (let cp of cps) {
8655
- if (!group_has_cp(g, cp)) {
8656
- // for whitelisted scripts, this will throw illegal mixture on invalid cm, eg. "e{300}{300}"
8657
- // at the moment, it's unnecessary to introduce an extra error type
8658
- // until there exists a whitelisted multi-character
8659
- // eg. if (M < 0 && is_combining_mark(cp)) { ... }
8660
- // there are 3 cases:
8661
- // 1. illegal cm for wrong group => mixture error
8662
- // 2. illegal cm for same group => cm error
8663
- // requires set of whitelist cm per group:
8664
- // eg. new Set([...g.P, ...g.Q].flatMap(nfc).filter(cp => CM.has(cp)))
8665
- // 3. wrong group => mixture error
8666
- throw error_group_member(g, cp);
8667
- }
8668
- }
8669
- //if (M >= 0) { // we have a known fixed cm count
8670
- if (g.M) { // we need to check for NSM
8671
- let decomposed = nfd(cps);
8672
- for (let i = 1, e = decomposed.length; i < e; i++) { // see: assumption
8673
- // 20230210: bugfix: using cps instead of decomposed h/t Carbon225
8674
- /*
8675
- if (CM.has(decomposed[i])) {
8676
- let j = i + 1;
8677
- while (j < e && CM.has(decomposed[j])) j++;
8678
- if (j - i > M) {
8679
- throw new Error(`too many combining marks: ${g.N} ${bidi_qq(str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${M})`);
8680
- }
8681
- i = j;
8682
- }
8683
- */
8684
- // 20230217: switch to NSM counting
8685
- // https://www.unicode.org/reports/tr39/#Optional_Detection
8686
- if (NSM.has(decomposed[i])) {
8687
- let j = i + 1;
8688
- for (let cp; j < e && NSM.has(cp = decomposed[j]); j++) {
8689
- // a. Forbid sequences of the same nonspacing mark.
8690
- for (let k = i; k < j; k++) { // O(n^2) but n < 100
8691
- if (decomposed[k] == cp) {
8692
- throw new Error(`duplicate non-spacing marks: ${quoted_cp(cp)}`);
8693
- }
8694
- }
8695
- }
8696
- // parse to end so we have full nsm count
8697
- // b. Forbid sequences of more than 4 nonspacing marks (gc=Mn or gc=Me).
8698
- if (j - i > NSM_MAX) {
8699
- // note: this slice starts with a base char or spacing-mark cm
8700
- throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${NSM_MAX})`);
8701
- }
8702
- i = j;
8703
- }
8704
- }
8705
- }
8706
- // *** this code currently isn't needed ***
8707
- /*
8708
- let cm_whitelist = M instanceof Map;
8709
- for (let i = 0, e = cps.length; i < e; ) {
8710
- let cp = cps[i++];
8711
- let seqs = cm_whitelist && M.get(cp);
8712
- if (seqs) {
8713
- // list of codepoints that can follow
8714
- // if this exists, this will always be 1+
8715
- let j = i;
8716
- while (j < e && CM.has(cps[j])) j++;
8717
- let cms = cps.slice(i, j);
8718
- let match = seqs.find(seq => !compare_arrays(seq, cms));
8719
- if (!match) throw new Error(`disallowed combining mark sequence: "${safe_str_from_cps([cp, ...cms])}"`);
8720
- i = j;
8721
- } else if (!V.has(cp)) {
8722
- // https://www.unicode.org/reports/tr39/#mixed_script_confusables
8723
- let quoted = quoted_cp(cp);
8724
- for (let cp of cps) {
8725
- let u = UNIQUE.get(cp);
8726
- if (u && u !== g) {
8727
- // if both scripts are restricted this error is confusing
8728
- // because we don't differentiate RestrictedA from RestrictedB
8729
- if (!u.R) quoted = `${quoted} is ${u.N}`;
8730
- break;
8731
- }
8732
- }
8733
- throw new Error(`disallowed ${g.N} character: ${quoted}`);
8734
- //throw new Error(`disallowed character: ${quoted} (expected ${g.N})`);
8735
- //throw new Error(`${g.N} does not allow: ${quoted}`);
8736
- }
8737
- }
8738
- if (!cm_whitelist) {
8739
- let decomposed = nfd(cps);
8740
- for (let i = 1, e = decomposed.length; i < e; i++) { // we know it can't be cm leading
8741
- if (CM.has(decomposed[i])) {
8742
- let j = i + 1;
8743
- while (j < e && CM.has(decomposed[j])) j++;
8744
- if (j - i > M) {
8745
- throw new Error(`too many combining marks: "${str_from_cps(decomposed.slice(i-1, j))}" (${j-i}/${M})`);
8746
- }
8747
- i = j;
8748
- }
8749
- }
8750
- }
8751
- */
8752
- }
8753
-
8754
- // given a list of codepoints
8755
- // returns a list of lists, where emoji are a fully-qualified (as Array subclass)
8756
- // eg. explode_cp("abc💩d") => [[61, 62, 63], Emoji[1F4A9, FE0F], [64]]
8757
- // 20230818: rename for 'process' name collision h/t Javarome
8758
- // https://github.com/adraffy/ens-normalize.js/issues/23
8759
- function tokens_from_str(input, nf, ef) {
8760
- let ret = [];
8761
- let chars = [];
8762
- input = input.slice().reverse(); // flip so we can pop
8763
- while (input.length) {
8764
- let emoji = consume_emoji_reversed(input);
8765
- if (emoji) {
8766
- if (chars.length) {
8767
- ret.push(nf(chars));
8768
- chars = [];
8769
- }
8770
- ret.push(ef(emoji));
8771
- } else {
8772
- let cp = input.pop();
8773
- if (VALID.has(cp)) {
8774
- chars.push(cp);
8775
- } else {
8776
- let cps = MAPPED.get(cp);
8777
- if (cps) {
8778
- chars.push(...cps); // less than 10 elements
8779
- } else if (!IGNORED.has(cp)) {
8780
- // 20230912: unicode 15.1 changed the order of processing such that
8781
- // disallowed parts are only rejected after NFC
8782
- // https://unicode.org/reports/tr46/#Validity_Criteria
8783
- // this doesn't impact normalization as of today
8784
- // technically, this error can be removed as the group logic will apply similar logic
8785
- // however the error type might be less clear
8786
- throw error_disallowed(cp);
8787
- }
8788
- }
8789
- }
8790
- }
8791
- if (chars.length) {
8792
- ret.push(nf(chars));
8793
- }
8794
- return ret;
8795
- }
8796
-
8797
- function filter_fe0f(cps) {
8798
- return cps.filter(cp => cp != FE0F);
8799
- }
8800
-
8801
- // given array of codepoints
8802
- // returns the longest valid emoji sequence (or undefined if no match)
8803
- // *MUTATES* the supplied array
8804
- // disallows interleaved ignored characters
8805
- // fills (optional) eaten array with matched codepoints
8806
- function consume_emoji_reversed(cps, eaten) {
8807
- let node = EMOJI_ROOT;
8808
- let emoji;
8809
- let pos = cps.length;
8810
- while (pos) {
8811
- node = node.get(cps[--pos]);
8812
- if (!node) break;
8813
- let {V} = node;
8814
- if (V) { // this is a valid emoji (so far)
8815
- emoji = V;
8816
- cps.length = pos; // truncate
8817
- }
8818
- }
8819
- return emoji;
8020
+ const HYPHEN = 0x2D;
8021
+ const STOP_CH = '.';
8022
+ const FE0F = 0xFE0F;
8023
+ const UNIQUE_PH = 1;
8024
+
8025
+ // 20230913: replace [...v] with Array_from(v) to avoid large spreads
8026
+ const Array_from = x => Array.from(x); // Array.from.bind(Array);
8027
+
8028
+ function group_has_cp(g, cp) {
8029
+ // 20230913: keep primary and secondary distinct instead of creating valid union
8030
+ return g.P.has(cp) || g.Q.has(cp);
8031
+ }
8032
+
8033
+ class Emoji extends Array {
8034
+ get is_emoji() { return true; } // free tagging system
8035
+ }
8036
+
8037
+ let MAPPED, IGNORED, CM, NSM, ESCAPE, GROUPS, WHOLE_VALID, WHOLE_MAP, VALID, EMOJI_LIST, EMOJI_ROOT;
8038
+
8039
+ function init() {
8040
+ if (MAPPED) return;
8041
+
8042
+ let r = read_compressed_payload(COMPRESSED$1);
8043
+ const read_sorted_array = () => read_sorted(r);
8044
+ const read_sorted_set = () => new Set(read_sorted_array());
8045
+ const set_add_many = (set, v) => v.forEach(x => set.add(x));
8046
+
8047
+ MAPPED = new Map(read_mapped(r));
8048
+ IGNORED = read_sorted_set(); // ignored characters are not valid, so just read raw codepoints
8049
+
8050
+ /*
8051
+ // direct include from payload is smaller than the decompression code
8052
+ const FENCED = new Map(read_array_while(() => {
8053
+ let cp = r();
8054
+ if (cp) return [cp, read_str(r())];
8055
+ }));
8056
+ */
8057
+ // 20230217: we still need all CM for proper error formatting
8058
+ // but norm only needs NSM subset that are potentially-valid
8059
+ CM = read_sorted_array();
8060
+ NSM = new Set(read_sorted_array().map(i => CM[i]));
8061
+ CM = new Set(CM);
8062
+
8063
+ ESCAPE = read_sorted_set(); // characters that should not be printed
8064
+ read_sorted_set(); // only needed to illustrate ens_tokenize() transformations
8065
+
8066
+ let chunks = read_sorted_arrays(r);
8067
+ let unrestricted = r();
8068
+ //const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array()));
8069
+ const read_chunked = () => {
8070
+ // 20230921: build set in parts, 2x faster
8071
+ let set = new Set();
8072
+ read_sorted_array().forEach(i => set_add_many(set, chunks[i]));
8073
+ set_add_many(set, read_sorted_array());
8074
+ return set;
8075
+ };
8076
+ GROUPS = read_array_while(i => {
8077
+ // minifier property mangling seems unsafe
8078
+ // so these are manually renamed to single chars
8079
+ let N = read_array_while(r).map(x => x+0x60);
8080
+ if (N.length) {
8081
+ let R = i >= unrestricted; // unrestricted then restricted
8082
+ N[0] -= 32; // capitalize
8083
+ N = str_from_cps(N);
8084
+ if (R) N=`Restricted[${N}]`;
8085
+ let P = read_chunked(); // primary
8086
+ let Q = read_chunked(); // secondary
8087
+ let M = !r(); // not-whitelisted, check for NSM
8088
+ // *** this code currently isn't needed ***
8089
+ /*
8090
+ let V = [...P, ...Q].sort((a, b) => a-b); // derive: sorted valid
8091
+ let M = r()-1; // number of combining mark
8092
+ if (M < 0) { // whitelisted
8093
+ M = new Map(read_array_while(() => {
8094
+ let i = r();
8095
+ if (i) return [V[i-1], read_array_while(() => {
8096
+ let v = read_array_while(r);
8097
+ if (v.length) return v.map(x => x-1);
8098
+ })];
8099
+ }));
8100
+ }*/
8101
+ return {N, P, Q, M, R};
8102
+ }
8103
+ });
8104
+
8105
+ // decode compressed wholes
8106
+ WHOLE_VALID = read_sorted_set();
8107
+ WHOLE_MAP = new Map();
8108
+ let wholes = read_sorted_array().concat(Array_from(WHOLE_VALID)).sort((a, b) => a-b); // must be sorted
8109
+ wholes.forEach((cp, i) => {
8110
+ let d = r();
8111
+ let w = wholes[i] = d ? wholes[i-d] : {V: [], M: new Map()};
8112
+ w.V.push(cp); // add to member set
8113
+ if (!WHOLE_VALID.has(cp)) {
8114
+ WHOLE_MAP.set(cp, w); // register with whole map
8115
+ }
8116
+ });
8117
+
8118
+ // compute confusable-extent complements
8119
+ // usage: WHOLE_MAP.get(cp).M.get(cp) = complement set
8120
+ for (let {V, M} of new Set(WHOLE_MAP.values())) {
8121
+ // connect all groups that have each whole character
8122
+ let recs = [];
8123
+ for (let cp of V) {
8124
+ let gs = GROUPS.filter(g => group_has_cp(g, cp));
8125
+ let rec = recs.find(({G}) => gs.some(g => G.has(g)));
8126
+ if (!rec) {
8127
+ rec = {G: new Set(), V: []};
8128
+ recs.push(rec);
8129
+ }
8130
+ rec.V.push(cp);
8131
+ set_add_many(rec.G, gs);
8132
+ }
8133
+ // per character cache groups which are not a member of the extent
8134
+ let union = recs.flatMap(x => Array_from(x.G)); // all of the groups used by this whole
8135
+ for (let {G, V} of recs) {
8136
+ let complement = new Set(union.filter(g => !G.has(g))); // groups not covered by the extent
8137
+ for (let cp of V) {
8138
+ M.set(cp, complement); // this is the same reference
8139
+ }
8140
+ }
8141
+ }
8142
+
8143
+ // compute valid set
8144
+ // 20230924: VALID was union but can be re-used
8145
+ VALID = new Set(); // exists in 1+ groups
8146
+ let multi = new Set(); // exists in 2+ groups
8147
+ const add_to_union = cp => VALID.has(cp) ? multi.add(cp) : VALID.add(cp);
8148
+ for (let g of GROUPS) {
8149
+ for (let cp of g.P) add_to_union(cp);
8150
+ for (let cp of g.Q) add_to_union(cp);
8151
+ }
8152
+ // dual purpose WHOLE_MAP: return placeholder if unique non-confusable
8153
+ for (let cp of VALID) {
8154
+ if (!WHOLE_MAP.has(cp) && !multi.has(cp)) {
8155
+ WHOLE_MAP.set(cp, UNIQUE_PH);
8156
+ }
8157
+ }
8158
+ // add all decomposed parts
8159
+ // see derive: "Valid is Closed (via Brute-force)"
8160
+ set_add_many(VALID, nfd(VALID));
8161
+
8162
+ // decode emoji
8163
+ // 20230719: emoji are now fully-expanded to avoid quirk logic
8164
+ EMOJI_LIST = read_trie(r).map(v => Emoji.from(v)).sort(compare_arrays);
8165
+ EMOJI_ROOT = new Map(); // this has approx 7K nodes (2+ per emoji)
8166
+ for (let cps of EMOJI_LIST) {
8167
+ // 20230719: change to *slightly* stricter algorithm which disallows
8168
+ // insertion of misplaced FE0F in emoji sequences (matching ENSIP-15)
8169
+ // example: beautified [A B] (eg. flag emoji)
8170
+ // before: allow: [A FE0F B], error: [A FE0F FE0F B]
8171
+ // after: error: both
8172
+ // note: this code now matches ENSNormalize.{cs,java} logic
8173
+ let prev = [EMOJI_ROOT];
8174
+ for (let cp of cps) {
8175
+ let next = prev.map(node => {
8176
+ let child = node.get(cp);
8177
+ if (!child) {
8178
+ // should this be object?
8179
+ // (most have 1-2 items, few have many)
8180
+ // 20230719: no, v8 default map is 4?
8181
+ child = new Map();
8182
+ node.set(cp, child);
8183
+ }
8184
+ return child;
8185
+ });
8186
+ if (cp === FE0F) {
8187
+ prev.push(...next); // less than 20 elements
8188
+ } else {
8189
+ prev = next;
8190
+ }
8191
+ }
8192
+ for (let x of prev) {
8193
+ x.V = cps;
8194
+ }
8195
+ }
8196
+ }
8197
+
8198
+ // if escaped: {HEX}
8199
+ // else: "x" {HEX}
8200
+ function quoted_cp(cp) {
8201
+ return (should_escape(cp) ? '' : `${bidi_qq(safe_str_from_cps([cp]))} `) + quote_cp(cp);
8202
+ }
8203
+
8204
+ // 20230211: some messages can be mixed-directional and result in spillover
8205
+ // use 200E after a quoted string to force the remainder of a string from
8206
+ // acquring the direction of the quote
8207
+ // https://www.w3.org/International/questions/qa-bidi-unicode-controls#exceptions
8208
+ function bidi_qq(s) {
8209
+ return `"${s}"\u200E`; // strong LTR
8210
+ }
8211
+
8212
+ function check_label_extension(cps) {
8213
+ if (cps.length >= 4 && cps[2] == HYPHEN && cps[3] == HYPHEN) {
8214
+ throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`); // this can only be ascii so cant be bidi
8215
+ }
8216
+ }
8217
+ function check_leading_underscore(cps) {
8218
+ const UNDERSCORE = 0x5F;
8219
+ for (let i = cps.lastIndexOf(UNDERSCORE); i > 0; ) {
8220
+ if (cps[--i] !== UNDERSCORE) {
8221
+ throw new Error('underscore allowed only at start');
8222
+ }
8223
+ }
8224
+ }
8225
+ // check that a fenced cp is not leading, trailing, or touching another fenced cp
8226
+ function check_fenced(cps) {
8227
+ let cp = cps[0];
8228
+ let prev = FENCED.get(cp);
8229
+ if (prev) throw error_placement(`leading ${prev}`);
8230
+ let n = cps.length;
8231
+ let last = -1; // prevents trailing from throwing
8232
+ for (let i = 1; i < n; i++) {
8233
+ cp = cps[i];
8234
+ let match = FENCED.get(cp);
8235
+ if (match) {
8236
+ // since cps[0] isn't fenced, cps[1] cannot throw
8237
+ if (last == i) throw error_placement(`${prev} + ${match}`);
8238
+ last = i + 1;
8239
+ prev = match;
8240
+ }
8241
+ }
8242
+ if (last == n) throw error_placement(`trailing ${prev}`);
8243
+ }
8244
+
8245
+ // create a safe to print string
8246
+ // invisibles are escaped
8247
+ // leading cm uses placeholder
8248
+ // if cps exceed max, middle truncate with ellipsis
8249
+ // quoter(cp) => string, eg. 3000 => "{3000}"
8250
+ // note: in html, you'd call this function then replace [<>&] with entities
8251
+ function safe_str_from_cps(cps, max = Infinity, quoter = quote_cp) {
8252
+ //if (Number.isInteger(cps)) cps = [cps];
8253
+ //if (!Array.isArray(cps)) throw new TypeError(`expected codepoints`);
8254
+ let buf = [];
8255
+ if (is_combining_mark(cps[0])) buf.push('◌');
8256
+ if (cps.length > max) {
8257
+ max >>= 1;
8258
+ cps = [...cps.slice(0, max), 0x2026, ...cps.slice(-max)];
8259
+ }
8260
+ let prev = 0;
8261
+ let n = cps.length;
8262
+ for (let i = 0; i < n; i++) {
8263
+ let cp = cps[i];
8264
+ if (should_escape(cp)) {
8265
+ buf.push(str_from_cps(cps.slice(prev, i)));
8266
+ buf.push(quoter(cp));
8267
+ prev = i + 1;
8268
+ }
8269
+ }
8270
+ buf.push(str_from_cps(cps.slice(prev, n)));
8271
+ return buf.join('');
8272
+ }
8273
+
8274
+ // note: set(s) cannot be exposed because they can be modified
8275
+ // note: Object.freeze() doesn't work
8276
+ function is_combining_mark(cp) {
8277
+ init();
8278
+ return CM.has(cp);
8279
+ }
8280
+ function should_escape(cp) {
8281
+ init();
8282
+ return ESCAPE.has(cp);
8283
+ }
8284
+
8285
+ function ens_normalize(name) {
8286
+ return flatten(split(name, nfc, filter_fe0f));
8287
+ }
8288
+
8289
+ function split(name, nf, ef) {
8290
+ if (!name) return []; // 20230719: empty name allowance
8291
+ init();
8292
+ let offset = 0;
8293
+ // https://unicode.org/reports/tr46/#Validity_Criteria
8294
+ // 4.) "The label must not contain a U+002E ( . ) FULL STOP."
8295
+ return name.split(STOP_CH).map(label => {
8296
+ let input = explode_cp(label);
8297
+ let info = {
8298
+ input,
8299
+ offset, // codepoint, not substring!
8300
+ };
8301
+ offset += input.length + 1; // + stop
8302
+ try {
8303
+ // 1.) "The label must be in Unicode Normalization Form NFC"
8304
+ let tokens = info.tokens = tokens_from_str(input, nf, ef);
8305
+ let token_count = tokens.length;
8306
+ let type;
8307
+ if (!token_count) { // the label was effectively empty (could of had ignored characters)
8308
+ //norm = [];
8309
+ //type = 'None'; // use this instead of next match, "ASCII"
8310
+ // 20230120: change to strict
8311
+ // https://discuss.ens.domains/t/ens-name-normalization-2nd/14564/59
8312
+ throw new Error(`empty label`);
8313
+ }
8314
+ let norm = info.output = tokens.flat();
8315
+ check_leading_underscore(norm);
8316
+ let emoji = info.emoji = token_count > 1 || tokens[0].is_emoji; // same as: tokens.some(x => x.is_emoji);
8317
+ if (!emoji && norm.every(cp => cp < 0x80)) { // special case for ascii
8318
+ // 20230123: matches matches WHATWG, see note 3.3
8319
+ check_label_extension(norm); // only needed for ascii
8320
+ // cant have fenced
8321
+ // cant have cm
8322
+ // cant have wholes
8323
+ // see derive: "Fastpath ASCII"
8324
+ type = 'ASCII';
8325
+ } else {
8326
+ let chars = tokens.flatMap(x => x.is_emoji ? [] : x); // all of the nfc tokens concat together
8327
+ if (!chars.length) { // theres no text, just emoji
8328
+ type = 'Emoji';
8329
+ } else {
8330
+ // 5.) "The label must not begin with a combining mark, that is: General_Category=Mark."
8331
+ if (CM.has(norm[0])) throw error_placement('leading combining mark');
8332
+ for (let i = 1; i < token_count; i++) { // we've already checked the first token
8333
+ let cps = tokens[i];
8334
+ if (!cps.is_emoji && CM.has(cps[0])) { // every text token has emoji neighbors, eg. EtEEEtEt...
8335
+ // bidi_qq() not needed since emoji is LTR and cps is a CM
8336
+ throw error_placement(`emoji + combining mark: "${str_from_cps(tokens[i-1])} + ${safe_str_from_cps([cps[0]])}"`);
8337
+ }
8338
+ }
8339
+ check_fenced(norm);
8340
+ let unique = Array_from(new Set(chars));
8341
+ let [g] = determine_group(unique); // take the first match
8342
+ // see derive: "Matching Groups have Same CM Style"
8343
+ // alternative: could form a hybrid type: Latin/Japanese/...
8344
+ check_group(g, chars); // need text in order
8345
+ check_whole(g, unique); // only need unique text (order would be required for multiple-char confusables)
8346
+ type = g.N;
8347
+ // 20230121: consider exposing restricted flag
8348
+ // it's simpler to just check for 'Restricted'
8349
+ // or even better: type.endsWith(']')
8350
+ //if (g.R) info.restricted = true;
8351
+ }
8352
+ }
8353
+ info.type = type;
8354
+ } catch (err) {
8355
+ info.error = err; // use full error object
8356
+ }
8357
+ return info;
8358
+ });
8359
+ }
8360
+
8361
+ function check_whole(group, unique) {
8362
+ let maker;
8363
+ let shared = [];
8364
+ for (let cp of unique) {
8365
+ let whole = WHOLE_MAP.get(cp);
8366
+ if (whole === UNIQUE_PH) return; // unique, non-confusable
8367
+ if (whole) {
8368
+ let set = whole.M.get(cp); // groups which have a character that look-like this character
8369
+ maker = maker ? maker.filter(g => set.has(g)) : Array_from(set);
8370
+ if (!maker.length) return; // confusable intersection is empty
8371
+ } else {
8372
+ shared.push(cp);
8373
+ }
8374
+ }
8375
+ if (maker) {
8376
+ // we have 1+ confusable
8377
+ // check if any of the remaining groups
8378
+ // contain the shared characters too
8379
+ for (let g of maker) {
8380
+ if (shared.every(cp => group_has_cp(g, cp))) {
8381
+ throw new Error(`whole-script confusable: ${group.N}/${g.N}`);
8382
+ }
8383
+ }
8384
+ }
8385
+ }
8386
+
8387
+ // assumption: unique.size > 0
8388
+ // returns list of matching groups
8389
+ function determine_group(unique) {
8390
+ let groups = GROUPS;
8391
+ for (let cp of unique) {
8392
+ // note: we need to dodge CM that are whitelisted
8393
+ // but that code isn't currently necessary
8394
+ let gs = groups.filter(g => group_has_cp(g, cp));
8395
+ if (!gs.length) {
8396
+ if (!GROUPS.some(g => group_has_cp(g, cp))) {
8397
+ // the character was composed of valid parts
8398
+ // but it's NFC form is invalid
8399
+ // 20230716: change to more exact statement, see: ENSNormalize.{cs,java}
8400
+ // note: this doesn't have to be a composition
8401
+ // 20230720: change to full check
8402
+ throw error_disallowed(cp); // this should be rare
8403
+ } else {
8404
+ // there is no group that contains all these characters
8405
+ // throw using the highest priority group that matched
8406
+ // https://www.unicode.org/reports/tr39/#mixed_script_confusables
8407
+ throw error_group_member(groups[0], cp);
8408
+ }
8409
+ }
8410
+ groups = gs;
8411
+ if (gs.length == 1) break; // there is only one group left
8412
+ }
8413
+ // there are at least 1 group(s) with all of these characters
8414
+ return groups;
8415
+ }
8416
+
8417
+ // throw on first error
8418
+ function flatten(split) {
8419
+ return split.map(({input, error, output}) => {
8420
+ if (error) {
8421
+ // don't print label again if just a single label
8422
+ let msg = error.message;
8423
+ // bidi_qq() only necessary if msg is digits
8424
+ throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input, 63))}: ${msg}`);
8425
+ }
8426
+ return str_from_cps(output);
8427
+ }).join(STOP_CH);
8428
+ }
8429
+
8430
+ function error_disallowed(cp) {
8431
+ // TODO: add cp to error?
8432
+ return new Error(`disallowed character: ${quoted_cp(cp)}`);
8433
+ }
8434
+ function error_group_member(g, cp) {
8435
+ let quoted = quoted_cp(cp);
8436
+ let gg = GROUPS.find(g => g.P.has(cp)); // only check primary
8437
+ if (gg) {
8438
+ quoted = `${gg.N} ${quoted}`;
8439
+ }
8440
+ return new Error(`illegal mixture: ${g.N} + ${quoted}`);
8441
+ }
8442
+ function error_placement(where) {
8443
+ return new Error(`illegal placement: ${where}`);
8444
+ }
8445
+
8446
+ // assumption: cps.length > 0
8447
+ // assumption: cps[0] isn't a CM
8448
+ // assumption: the previous character isn't an emoji
8449
+ function check_group(g, cps) {
8450
+ for (let cp of cps) {
8451
+ if (!group_has_cp(g, cp)) {
8452
+ // for whitelisted scripts, this will throw illegal mixture on invalid cm, eg. "e{300}{300}"
8453
+ // at the moment, it's unnecessary to introduce an extra error type
8454
+ // until there exists a whitelisted multi-character
8455
+ // eg. if (M < 0 && is_combining_mark(cp)) { ... }
8456
+ // there are 3 cases:
8457
+ // 1. illegal cm for wrong group => mixture error
8458
+ // 2. illegal cm for same group => cm error
8459
+ // requires set of whitelist cm per group:
8460
+ // eg. new Set([...g.P, ...g.Q].flatMap(nfc).filter(cp => CM.has(cp)))
8461
+ // 3. wrong group => mixture error
8462
+ throw error_group_member(g, cp);
8463
+ }
8464
+ }
8465
+ //if (M >= 0) { // we have a known fixed cm count
8466
+ if (g.M) { // we need to check for NSM
8467
+ let decomposed = nfd(cps);
8468
+ for (let i = 1, e = decomposed.length; i < e; i++) { // see: assumption
8469
+ // 20230210: bugfix: using cps instead of decomposed h/t Carbon225
8470
+ /*
8471
+ if (CM.has(decomposed[i])) {
8472
+ let j = i + 1;
8473
+ while (j < e && CM.has(decomposed[j])) j++;
8474
+ if (j - i > M) {
8475
+ throw new Error(`too many combining marks: ${g.N} ${bidi_qq(str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${M})`);
8476
+ }
8477
+ i = j;
8478
+ }
8479
+ */
8480
+ // 20230217: switch to NSM counting
8481
+ // https://www.unicode.org/reports/tr39/#Optional_Detection
8482
+ if (NSM.has(decomposed[i])) {
8483
+ let j = i + 1;
8484
+ for (let cp; j < e && NSM.has(cp = decomposed[j]); j++) {
8485
+ // a. Forbid sequences of the same nonspacing mark.
8486
+ for (let k = i; k < j; k++) { // O(n^2) but n < 100
8487
+ if (decomposed[k] == cp) {
8488
+ throw new Error(`duplicate non-spacing marks: ${quoted_cp(cp)}`);
8489
+ }
8490
+ }
8491
+ }
8492
+ // parse to end so we have full nsm count
8493
+ // b. Forbid sequences of more than 4 nonspacing marks (gc=Mn or gc=Me).
8494
+ if (j - i > NSM_MAX) {
8495
+ // note: this slice starts with a base char or spacing-mark cm
8496
+ throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${NSM_MAX})`);
8497
+ }
8498
+ i = j;
8499
+ }
8500
+ }
8501
+ }
8502
+ // *** this code currently isn't needed ***
8503
+ /*
8504
+ let cm_whitelist = M instanceof Map;
8505
+ for (let i = 0, e = cps.length; i < e; ) {
8506
+ let cp = cps[i++];
8507
+ let seqs = cm_whitelist && M.get(cp);
8508
+ if (seqs) {
8509
+ // list of codepoints that can follow
8510
+ // if this exists, this will always be 1+
8511
+ let j = i;
8512
+ while (j < e && CM.has(cps[j])) j++;
8513
+ let cms = cps.slice(i, j);
8514
+ let match = seqs.find(seq => !compare_arrays(seq, cms));
8515
+ if (!match) throw new Error(`disallowed combining mark sequence: "${safe_str_from_cps([cp, ...cms])}"`);
8516
+ i = j;
8517
+ } else if (!V.has(cp)) {
8518
+ // https://www.unicode.org/reports/tr39/#mixed_script_confusables
8519
+ let quoted = quoted_cp(cp);
8520
+ for (let cp of cps) {
8521
+ let u = UNIQUE.get(cp);
8522
+ if (u && u !== g) {
8523
+ // if both scripts are restricted this error is confusing
8524
+ // because we don't differentiate RestrictedA from RestrictedB
8525
+ if (!u.R) quoted = `${quoted} is ${u.N}`;
8526
+ break;
8527
+ }
8528
+ }
8529
+ throw new Error(`disallowed ${g.N} character: ${quoted}`);
8530
+ //throw new Error(`disallowed character: ${quoted} (expected ${g.N})`);
8531
+ //throw new Error(`${g.N} does not allow: ${quoted}`);
8532
+ }
8533
+ }
8534
+ if (!cm_whitelist) {
8535
+ let decomposed = nfd(cps);
8536
+ for (let i = 1, e = decomposed.length; i < e; i++) { // we know it can't be cm leading
8537
+ if (CM.has(decomposed[i])) {
8538
+ let j = i + 1;
8539
+ while (j < e && CM.has(decomposed[j])) j++;
8540
+ if (j - i > M) {
8541
+ throw new Error(`too many combining marks: "${str_from_cps(decomposed.slice(i-1, j))}" (${j-i}/${M})`);
8542
+ }
8543
+ i = j;
8544
+ }
8545
+ }
8546
+ }
8547
+ */
8548
+ }
8549
+
8550
+ // given a list of codepoints
8551
+ // returns a list of lists, where emoji are a fully-qualified (as Array subclass)
8552
+ // eg. explode_cp("abc💩d") => [[61, 62, 63], Emoji[1F4A9, FE0F], [64]]
8553
+ // 20230818: rename for 'process' name collision h/t Javarome
8554
+ // https://github.com/adraffy/ens-normalize.js/issues/23
8555
+ function tokens_from_str(input, nf, ef) {
8556
+ let ret = [];
8557
+ let chars = [];
8558
+ input = input.slice().reverse(); // flip so we can pop
8559
+ while (input.length) {
8560
+ let emoji = consume_emoji_reversed(input);
8561
+ if (emoji) {
8562
+ if (chars.length) {
8563
+ ret.push(nf(chars));
8564
+ chars = [];
8565
+ }
8566
+ ret.push(ef(emoji));
8567
+ } else {
8568
+ let cp = input.pop();
8569
+ if (VALID.has(cp)) {
8570
+ chars.push(cp);
8571
+ } else {
8572
+ let cps = MAPPED.get(cp);
8573
+ if (cps) {
8574
+ chars.push(...cps); // less than 10 elements
8575
+ } else if (!IGNORED.has(cp)) {
8576
+ // 20230912: unicode 15.1 changed the order of processing such that
8577
+ // disallowed parts are only rejected after NFC
8578
+ // https://unicode.org/reports/tr46/#Validity_Criteria
8579
+ // this doesn't impact normalization as of today
8580
+ // technically, this error can be removed as the group logic will apply similar logic
8581
+ // however the error type might be less clear
8582
+ throw error_disallowed(cp);
8583
+ }
8584
+ }
8585
+ }
8586
+ }
8587
+ if (chars.length) {
8588
+ ret.push(nf(chars));
8589
+ }
8590
+ return ret;
8591
+ }
8592
+
8593
+ function filter_fe0f(cps) {
8594
+ return cps.filter(cp => cp != FE0F);
8595
+ }
8596
+
8597
+ // given array of codepoints
8598
+ // returns the longest valid emoji sequence (or undefined if no match)
8599
+ // *MUTATES* the supplied array
8600
+ // disallows interleaved ignored characters
8601
+ // fills (optional) eaten array with matched codepoints
8602
+ function consume_emoji_reversed(cps, eaten) {
8603
+ let node = EMOJI_ROOT;
8604
+ let emoji;
8605
+ let pos = cps.length;
8606
+ while (pos) {
8607
+ node = node.get(cps[--pos]);
8608
+ if (!node) break;
8609
+ let {V} = node;
8610
+ if (V) { // this is a valid emoji (so far)
8611
+ emoji = V;
8612
+ cps.length = pos; // truncate
8613
+ }
8614
+ }
8615
+ return emoji;
8820
8616
  }
8821
8617
 
8822
8618
  const Zeros = new Uint8Array(32);
@@ -19235,7 +19031,6 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
19235
19031
  address: a.address,
19236
19032
  nonce: toQuantity(a.nonce),
19237
19033
  chainId: toQuantity(a.chainId),
19238
- yParity: toQuantity(a.signature.yParity),
19239
19034
  r: toQuantity(a.signature.r),
19240
19035
  s: toQuantity(a.signature.s),
19241
19036
  };
@@ -20550,7 +20345,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
20550
20345
  else {
20551
20346
  pass = toUtf8String(_password);
20552
20347
  }
20553
- let wal = qcsdk.deserializeEncryptedWallet(json, pass);
20348
+ let wal = quantumCoinJsSdk.deserializeEncryptedWallet(json, pass);
20554
20349
  let privKey = wal.privateKey;
20555
20350
  let ks = {
20556
20351
  address: wal.address,
@@ -20570,13 +20365,13 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
20570
20365
  const signingKey = new SigningKey(account.privateKey);
20571
20366
  const privateKey = getBytes(signingKey.privateKey);
20572
20367
  const publicKey = getBytes(signingKey.publicKey);
20573
- const wal = new qcsdk.Wallet(account.address, privateKey, publicKey);
20368
+ const wal = new quantumCoinJsSdk.Wallet(account.address, privateKey, publicKey);
20574
20369
  if (typeof password === 'string') {
20575
- return qcsdk.serializeEncryptedWallet(wal, password);
20370
+ return quantumCoinJsSdk.serializeEncryptedWallet(wal, password);
20576
20371
  }
20577
20372
  else {
20578
20373
  let passPhrase = toUtf8String(password);
20579
- return qcsdk.serializeEncryptedWallet(wal, passPhrase);
20374
+ return quantumCoinJsSdk.serializeEncryptedWallet(wal, passPhrase);
20580
20375
  }
20581
20376
  }
20582
20377
 
@@ -20672,7 +20467,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
20672
20467
  * If there is no crytographic random source, this will throw.
20673
20468
  */
20674
20469
  static createRandom(provider) {
20675
- let wal = qcsdk.newWallet();
20470
+ let wal = quantumCoinJsSdk.newWallet();
20676
20471
  let privKey = wal.privateKey;
20677
20472
  return new Wallet(hexlify(privKey));
20678
20473
  }
@@ -20962,6 +20757,10 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
20962
20757
 
20963
20758
  /////////////////////////////
20964
20759
  //
20760
+ async function initQuantum() {
20761
+ let clientConfigVal = new quantumCoinJsSdk.Config("https://sdk.readrelay.quantumcoinapi.com", "https://sdk.writerelay.quantumcoinapi.com", 123123, "", ""); //Mainnet
20762
+ return await quantumCoinJsSdk.initialize(clientConfigVal);
20763
+ }
20965
20764
  // dummy change; to pick-up ws security issue changes
20966
20765
 
20967
20766
  var quantumcoin = /*#__PURE__*/Object.freeze({
@@ -21090,6 +20889,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
21090
20889
  hashMessage: hashMessage,
21091
20890
  hexlify: hexlify,
21092
20891
  id: id,
20892
+ initQuantum: initQuantum,
21093
20893
  isAddress: isAddress,
21094
20894
  isAddressable: isAddressable,
21095
20895
  isBytesLike: isBytesLike,
@@ -21264,6 +21064,7 @@ const __$G = (typeof globalThis !== 'undefined' ? globalThis: typeof window !==
21264
21064
  exports.hashMessage = hashMessage;
21265
21065
  exports.hexlify = hexlify;
21266
21066
  exports.id = id;
21067
+ exports.initQuantum = initQuantum;
21267
21068
  exports.isAddress = isAddress;
21268
21069
  exports.isAddressable = isAddressable;
21269
21070
  exports.isBytesLike = isBytesLike;